feat: broadcasts get sent to relays

This commit is contained in:
əlemi 2024-12-27 16:30:51 +01:00
parent 444ef5528f
commit 15f3188396
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -170,8 +170,21 @@ pub async fn process(ctx: Context, job: &model::job::Model) -> crate::JobResult<
// TODO very important that we limit Update activities!!! otherwise with .process() local users
// can change their document completely
let targets = activity.addressed();
let mut targets = activity.addressed();
let is_broadcast = activity.to().flat().into_iter().any(|x| apb::target::is_public(&x.id().unwrap_or_default()));
ctx.process(activity, &tx).await?;
if is_broadcast {
for relay in upub::Query::related(None, Some(ctx.actor().internal), false)
.select_only()
.select_column(upub::model::actor::Column::Id)
.into_tuple::<String>()
.all(&tx)
.await?
{
targets.push(relay);
}
}
ctx.deliver(targets, &job.activity, &job.actor, &tx).await?;
tx.commit().await?;