fix: add compat options to add target to likes
this is a nastier compat option: lemmy sends likes anonymously by design (you can't see who upvoted/downvoted you). however mastodon likes are intended to be seen (as mastodon shows every like as public on their frontend). issue is: they both come with completely empty addressing! thanks mastodon... so this compat option makes likes addressed to local objects always address the object author. this restores mastodon likes behavior but "leaks" lemmy votes. i don't know how to fix it: maybe do some weird magic checking what is in `@context`??? disgusting but at least i can stop leaking lemmy's likes...
This commit is contained in:
parent
77bf9d17a1
commit
2bbc1270a1
2 changed files with 8 additions and 2 deletions
|
@ -105,6 +105,8 @@ pub struct CompatibilityConfig {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub fix_attachment_images_media_type: bool,
|
pub fix_attachment_images_media_type: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub add_explicit_target_to_likes_if_local: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
|
|
@ -98,6 +98,7 @@ pub async fn create(ctx: &crate::Context, activity: impl apb::Activity, tx: &Dat
|
||||||
pub async fn like(ctx: &crate::Context, activity: impl apb::Activity, tx: &DatabaseTransaction) -> Result<(), ProcessorError> {
|
pub async fn like(ctx: &crate::Context, activity: impl apb::Activity, tx: &DatabaseTransaction) -> Result<(), ProcessorError> {
|
||||||
let actor = ctx.fetch_user(activity.actor().id()?, tx).await?;
|
let actor = ctx.fetch_user(activity.actor().id()?, tx).await?;
|
||||||
let obj = ctx.fetch_object(activity.object().id()?, tx).await?;
|
let obj = ctx.fetch_object(activity.object().id()?, tx).await?;
|
||||||
|
let likes_local_object = obj.attributed_to.as_ref().map(|x| ctx.is_local(x)).unwrap_or_default();
|
||||||
if crate::model::like::Entity::find_by_uid_oid(actor.internal, obj.internal)
|
if crate::model::like::Entity::find_by_uid_oid(actor.internal, obj.internal)
|
||||||
.any(tx)
|
.any(tx)
|
||||||
.await?
|
.await?
|
||||||
|
@ -120,8 +121,11 @@ pub async fn like(ctx: &crate::Context, activity: impl apb::Activity, tx: &Datab
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// likes without addressing are "silent likes", process them but dont store activity or notify
|
// likes without addressing are "silent likes", process them but dont store activity or notify
|
||||||
if !activity.addressed().is_empty() {
|
if likes_local_object || !activity.addressed().is_empty() {
|
||||||
let activity_model = ctx.insert_activity(activity, tx).await?;
|
let mut activity_model = ctx.insert_activity(activity, tx).await?;
|
||||||
|
if likes_local_object {
|
||||||
|
activity_model.to.0.push(obj.attributed_to.clone().unwrap_or_default());
|
||||||
|
}
|
||||||
ctx.address((Some(&activity_model), None), tx).await?;
|
ctx.address((Some(&activity_model), None), tx).await?;
|
||||||
|
|
||||||
// TODO check that object author is in this like addressing!!! otherwise skip notification
|
// TODO check that object author is in this like addressing!!! otherwise skip notification
|
||||||
|
|
Loading…
Reference in a new issue