1 extern crate activitypub;
2 use self::activitypub::{actor::Person, context};
3 use crate::db::user::User_;
6 pub fn person(&self) -> Person {
7 use crate::{to_datetime_utc, Settings};
8 let base_url = &format!("{}/user/{}", Settings::get().api_endpoint(), self.name);
9 let mut person = Person::default();
10 person.object_props.set_context_object(context()).ok();
11 person.object_props.set_id_string(base_url.to_string()).ok();
14 .set_name_string(self.name.to_owned())
18 .set_published_utctime(to_datetime_utc(self.published))
20 if let Some(i) = self.updated {
23 .set_updated_utctime(to_datetime_utc(i))
26 // person.object_props.summary = self.summary;
30 .set_inbox_string(format!("{}/inbox", &base_url))
34 .set_outbox_string(format!("{}/outbox", &base_url))
38 .set_following_string(format!("{}/following", &base_url))
42 .set_liked_string(format!("{}/liked", &base_url))
44 if let Some(i) = &self.preferred_username {
47 .set_preferred_username_string(i.to_string())
62 let expected_user = User_ {
65 fedi_name: "rrf".into(),
66 preferred_username: None,
67 password_encrypted: "here".into(),
70 published: naive_now(),
75 theme: "darkly".into(),
78 let person = expected_user.person();
80 "rrr/api/v1/user/thom",
81 person.object_props.id_string().unwrap()
83 let json = serde_json::to_string_pretty(&person).unwrap();