mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 07:36:01 +00:00
parent
35db0dc8e7
commit
abe8b18ea8
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
activities::{generate_activity_id, send_lemmy_activity, verify_person_in_community},
|
||||
insert_received_activity,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
objects::{community::ApubCommunity, instance::ApubSite, person::ApubPerson},
|
||||
protocol::{activities::community::report::Report, InCommunity},
|
||||
PostOrComment,
|
||||
};
|
||||
|
@ -19,8 +19,9 @@ use lemmy_db_schema::{
|
|||
community::Community,
|
||||
person::Person,
|
||||
post_report::{PostReport, PostReportForm},
|
||||
site::Site,
|
||||
},
|
||||
traits::Reportable,
|
||||
traits::{Crud, Reportable},
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use url::Url;
|
||||
|
@ -44,18 +45,31 @@ impl Report {
|
|||
let report = Report {
|
||||
actor: actor.id().into(),
|
||||
to: [community.id().into()],
|
||||
object: object_id,
|
||||
object: object_id.clone(),
|
||||
summary: reason,
|
||||
kind,
|
||||
id: id.clone(),
|
||||
audience: Some(community.id().into()),
|
||||
};
|
||||
let inbox = if community.local {
|
||||
ActivitySendTargets::empty()
|
||||
} else {
|
||||
ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox())
|
||||
|
||||
// send report to the community where object was posted
|
||||
let mut inboxes = ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox());
|
||||
|
||||
// also send report to user's home instance if possible
|
||||
let object_creator_id = match object_id.dereference_local(&context).await? {
|
||||
PostOrComment::Post(p) => p.creator_id,
|
||||
PostOrComment::Comment(c) => c.creator_id,
|
||||
};
|
||||
send_lemmy_activity(&context, report, &actor, inbox, false).await
|
||||
let object_creator = Person::read(&mut context.pool(), object_creator_id).await?;
|
||||
let object_creator_site: Option<ApubSite> =
|
||||
Site::read_from_instance_id(&mut context.pool(), object_creator.instance_id)
|
||||
.await?
|
||||
.map(Into::into);
|
||||
if let Some(inbox) = object_creator_site.map(|s| s.shared_inbox_or_inbox()) {
|
||||
inboxes.add_inbox(inbox);
|
||||
}
|
||||
|
||||
send_lemmy_activity(&context, report, &actor, inboxes, false).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue