Federate avatars
This commit is contained in:
parent
8ac6b8307a
commit
820516bfe5
@ -1,7 +1,8 @@
|
|||||||
use activitypub::{
|
use activitypub::{
|
||||||
Activity, Actor, Object, Endpoint, CustomObject,
|
Activity, Actor, Object, Endpoint, CustomObject,
|
||||||
actor::Person,
|
actor::Person,
|
||||||
collection::OrderedCollection
|
collection::OrderedCollection,
|
||||||
|
object::Image,
|
||||||
};
|
};
|
||||||
use bcrypt;
|
use bcrypt;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
@ -416,7 +417,7 @@ impl User {
|
|||||||
PKey::from_rsa(Rsa::private_key_from_pem(self.private_key.clone().unwrap().as_ref()).unwrap()).unwrap()
|
PKey::from_rsa(Rsa::private_key_from_pem(self.private_key.clone().unwrap().as_ref()).unwrap()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_activity(&self, _conn: &PgConnection) -> CustomPerson {
|
pub fn into_activity(&self, conn: &PgConnection) -> CustomPerson {
|
||||||
let mut actor = Person::default();
|
let mut actor = Person::default();
|
||||||
actor.object_props.set_id_string(self.ap_url.clone()).expect("User::into_activity: id error");
|
actor.object_props.set_id_string(self.ap_url.clone()).expect("User::into_activity: id error");
|
||||||
actor.object_props.set_name_string(self.display_name.clone()).expect("User::into_activity: name error");
|
actor.object_props.set_name_string(self.display_name.clone()).expect("User::into_activity: name error");
|
||||||
@ -438,6 +439,11 @@ impl User {
|
|||||||
let mut ap_signature = ApSignature::default();
|
let mut ap_signature = ApSignature::default();
|
||||||
ap_signature.set_public_key_publickey(public_key).expect("User::into_activity: publicKey error");
|
ap_signature.set_public_key_publickey(public_key).expect("User::into_activity: publicKey error");
|
||||||
|
|
||||||
|
let mut avatar = Image::default();
|
||||||
|
avatar.object_props.set_url_string(self.avatar_id.and_then(|id| Media::get(conn, id).map(|m| m.url(conn))).unwrap_or(String::new()))
|
||||||
|
.expect("User::into_activity: icon.url error");
|
||||||
|
actor.object_props.set_icon_object(avatar).expect("User::into_activity: icon error");
|
||||||
|
|
||||||
CustomPerson::new(actor, ap_signature)
|
CustomPerson::new(actor, ap_signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user