diff options
author | Dessalines <tyhou13@gmx.com> | 2020-05-25 16:15:23 -0400 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-05-25 16:15:23 -0400 |
commit | a9af247f1eebf928c63f4127184c206287f6ead9 (patch) | |
tree | 9f6413653111f266da7664cb9133694827fb044d /server/src/apub/user.rs | |
parent | d1aca27126672f72d18b9749507a29040f4bfdd3 (diff) | |
parent | f88180650df8c8808cf0f9cd53053e49eb46fb54 (diff) |
Merge branch 'federated_embeds' into federation
Diffstat (limited to 'server/src/apub/user.rs')
-rw-r--r-- | server/src/apub/user.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/server/src/apub/user.rs b/server/src/apub/user.rs index a2958b15..0a651d1f 100644 --- a/server/src/apub/user.rs +++ b/server/src/apub/user.rs @@ -21,7 +21,7 @@ use activitystreams::{ actor::{properties::ApActorProperties, Person}, context, endpoint::EndpointProperties, - object::{properties::ObjectProperties, Tombstone}, + object::{properties::ObjectProperties, AnyImage, Image, Tombstone}, }; use activitystreams_ext::Ext2; use actix_web::{body::Body, web::Path, HttpResponse, Result}; @@ -56,6 +56,15 @@ impl ToApub for User_ { oprops.set_name_xsd_string(i.to_owned())?; } + if let Some(avatar_url) = &self.avatar { + let mut image = Image::new(); + image + .object_props + .set_url_xsd_any_uri(avatar_url.to_owned())?; + let any_image = AnyImage::from_concrete(image)?; + oprops.set_icon_any_image(any_image)?; + } + let mut endpoint_props = EndpointProperties::default(); endpoint_props.set_shared_inbox(self.get_shared_inbox_url())?; @@ -181,6 +190,16 @@ impl FromApub for UserForm { let aprops = &person.ext_one; let public_key: &PublicKey = &person.ext_two.public_key; + let avatar = match oprops.get_icon_any_image() { + Some(any_image) => any_image + .to_owned() + .into_concrete::<Image>()? + .object_props + .get_url_xsd_any_uri() + .map(|u| u.to_string()), + None => None, + }; + Ok(UserForm { name: oprops.get_name_xsd_string().unwrap().to_string(), preferred_username: aprops.get_preferred_username().map(|u| u.to_string()), @@ -188,7 +207,7 @@ impl FromApub for UserForm { admin: false, banned: false, email: None, - avatar: None, // -> icon, image + avatar, updated: oprops .get_updated() .map(|u| u.as_ref().to_owned().naive_local()), |