fix: treat lemmy images like attachments

This commit is contained in:
əlemi 2024-05-12 00:54:48 +02:00
parent b9f512a988
commit ab0300894f
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 14 additions and 0 deletions

View file

@ -297,6 +297,13 @@ async fn fetch_object_inner(ctx: &Context, id: &str, depth: usize) -> crate::Res
.exec(ctx.db())
.await?;
}
// lemmy sends us an image field in posts, treat it like an attachment i'd say
if let Some(img) = object.image().get() {
let attachment_model = model::attachment::ActiveModel::new(img, object_model.id.clone())?;
model::attachment::Entity::insert(attachment_model)
.exec(ctx.db())
.await?;
}
let expanded_addresses = ctx.expand_addressing(addressed).await?;
ctx.address_to(None, Some(&object_model.id), &expanded_addresses).await?;

View file

@ -59,6 +59,13 @@ impl apb::server::Inbox for Context {
.exec(self.db())
.await?;
}
// lemmy sends us an image field in posts, treat it like an attachment i'd say
if let Some(img) = object.image().get() {
let attachment_model = model::attachment::ActiveModel::new(img, object_model.id.clone())?;
model::attachment::Entity::insert(attachment_model)
.exec(ctx.db())
.await?;
}
// TODO can we even receive anonymous objects?
if let Some(object_author) = uid {
model::user::Entity::update_many()