Attach icon field to User activity only whene it has avatar

This commit is contained in:
Kitaiti Makoto 2022-01-10 22:20:10 +09:00
parent 113722e4ba
commit 34c374de1a

View file

@ -775,13 +775,13 @@ impl User {
let mut ap_signature = ApSignature::default(); let mut ap_signature = ApSignature::default();
ap_signature.set_public_key_publickey(public_key)?; ap_signature.set_public_key_publickey(public_key)?;
let mut avatar = Image::default(); if let Some(avatar_id) = self.avatar_id {
avatar.object_props.set_url_string( let mut avatar = Image::default();
self.avatar_id avatar
.and_then(|id| Media::get(conn, id).and_then(|m| m.url()).ok()) .object_props
.unwrap_or_default(), .set_url_string(Media::get(conn, avatar_id)?.url()?)?;
)?; actor.object_props.set_icon_object(avatar)?;
actor.object_props.set_icon_object(avatar)?; }
Ok(CustomPerson::new(actor, ap_signature)) Ok(CustomPerson::new(actor, ap_signature))
} }