Actually, we don't need to federate a Note
Mastodon supports Article, see 63f0979799/app/lib/activitypub/activity/create.rb (L191)
This commit is contained in:
parent
0de7859ca8
commit
d587d18cd4
@ -82,6 +82,15 @@ impl Object for Post {
|
||||
}
|
||||
|
||||
fn serialize(&self, conn: &PgConnection) -> serde_json::Value {
|
||||
let followers = self.get_authors(conn).into_iter().map(|a| a.get_followers(conn)).collect::<Vec<Vec<User>>>();
|
||||
let mut to = followers.into_iter().fold(vec![], |mut acc, f| {
|
||||
for x in f {
|
||||
acc.push(x.ap_url);
|
||||
}
|
||||
acc
|
||||
});
|
||||
to.push(PUBLIC_VISIBILTY.to_string());
|
||||
|
||||
json!({
|
||||
"type": "Article",
|
||||
"attributedTo": self.get_authors(conn).into_iter().map(|a| a.compute_id(conn)).collect::<Vec<String>>(),
|
||||
@ -94,43 +103,6 @@ impl Object for Post {
|
||||
"tag": [],
|
||||
// TODO: "updated": "updated",
|
||||
// TODO: "url": "url",
|
||||
"to": [ PUBLIC_VISIBILTY ]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// ActivityPub Object to make it possible to view posts in Mastodon/Pleroma
|
||||
/// and interact with them from there.
|
||||
pub struct PostNote {
|
||||
pub post: Post
|
||||
}
|
||||
|
||||
impl Object for PostNote {
|
||||
fn compute_id(&self, conn: &PgConnection) -> String {
|
||||
ap_url(format!("{}/{}/{}/note", BASE_URL.as_str(), self.post.get_blog(conn).actor_id, self.post.slug))
|
||||
}
|
||||
|
||||
fn serialize(&self, conn: &PgConnection) -> serde_json::Value {
|
||||
let followers = self.post.get_authors(conn).into_iter().map(|a| a.get_followers(conn)).collect::<Vec<Vec<User>>>();
|
||||
let mut to = followers.into_iter().fold(vec![], |mut acc, f| {
|
||||
for x in f {
|
||||
acc.push(x.ap_url);
|
||||
}
|
||||
acc
|
||||
});
|
||||
to.push(PUBLIC_VISIBILTY.to_string());
|
||||
json!({
|
||||
"type": "Note",
|
||||
"attributedTo": self.post.get_authors(conn).into_iter().map(|a| a.compute_id(conn)).collect::<Vec<String>>(),
|
||||
"content": format!("<b>{}</b> in {}", self.post.title, self.post.get_blog(conn).title),
|
||||
// TODO: "image": "image",
|
||||
// TODO: "preview": "preview",
|
||||
// TODO: "published": "published",
|
||||
// TODO: "replies": "replies",
|
||||
// TODO: "summary": "summary",
|
||||
"tag": [],
|
||||
// TODO: "updated": "updated",
|
||||
// TODO: "url": "url",
|
||||
"to": to
|
||||
})
|
||||
}
|
||||
|
@ -58,9 +58,5 @@ fn create(blog_name: String, data: Form<NewPostForm>, user: User, conn: DbConn)
|
||||
let act = Create::new(&user, &post, &*conn);
|
||||
broadcast(&*conn, &user, act, user.get_followers(&*conn));
|
||||
|
||||
let note_act = Create::new(&user, &PostNote { post: post }, &*conn);
|
||||
broadcast(&*conn, &user, note_act, user.get_followers(&*conn));
|
||||
|
||||
|
||||
Redirect::to(format!("/~/{}/{}", blog_name, slug).as_str())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user