Implement ap_followers using activitystreams
This commit is contained in:
parent
78a001ac89
commit
b17884681d
@ -1,6 +1,7 @@
|
|||||||
use activitypub::collection::OrderedCollection;
|
use activitystreams::{
|
||||||
use activitystreams::collection::{
|
collection::{OrderedCollection, OrderedCollectionPage},
|
||||||
OrderedCollection as OrderedCollection07, OrderedCollectionPage,
|
iri_string::types::IriString,
|
||||||
|
prelude::*,
|
||||||
};
|
};
|
||||||
use diesel::SaveChangesDsl;
|
use diesel::SaveChangesDsl;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
@ -18,7 +19,7 @@ use crate::routes::{
|
|||||||
};
|
};
|
||||||
use crate::template_utils::{IntoContext, Ructe};
|
use crate::template_utils::{IntoContext, Ructe};
|
||||||
use crate::utils::requires_login;
|
use crate::utils::requires_login;
|
||||||
use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest, CustomPerson, Id};
|
use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest, CustomPerson};
|
||||||
use plume_common::utils::md_to_html;
|
use plume_common::utils::md_to_html;
|
||||||
use plume_models::{
|
use plume_models::{
|
||||||
blogs::Blog,
|
blogs::Blog,
|
||||||
@ -529,7 +530,7 @@ pub fn create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/@/<name>/outbox")]
|
#[get("/@/<name>/outbox")]
|
||||||
pub fn outbox(name: String, conn: DbConn) -> Option<ActivityStream<OrderedCollection07>> {
|
pub fn outbox(name: String, conn: DbConn) -> Option<ActivityStream<OrderedCollection>> {
|
||||||
let user = User::find_by_fqn(&conn, &name).ok()?;
|
let user = User::find_by_fqn(&conn, &name).ok()?;
|
||||||
user.outbox(&conn).ok()
|
user.outbox(&conn).ok()
|
||||||
}
|
}
|
||||||
@ -564,17 +565,13 @@ pub fn ap_followers(
|
|||||||
.get_followers(&conn)
|
.get_followers(&conn)
|
||||||
.ok()?
|
.ok()?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|f| Id::new(f.ap_url))
|
.filter_map(|f| f.ap_url.parse::<IriString>().ok())
|
||||||
.collect::<Vec<Id>>();
|
.collect::<Vec<IriString>>();
|
||||||
|
|
||||||
let mut coll = OrderedCollection::default();
|
let mut coll = OrderedCollection::new();
|
||||||
coll.object_props
|
coll.set_id(user.followers_endpoint.parse::<IriString>().ok()?);
|
||||||
.set_id_string(user.followers_endpoint)
|
coll.set_total_items(followers.len() as u64);
|
||||||
.ok()?;
|
coll.set_many_items(followers);
|
||||||
coll.collection_props
|
|
||||||
.set_total_items_u64(followers.len() as u64)
|
|
||||||
.ok()?;
|
|
||||||
coll.collection_props.set_items_link_vec(followers).ok()?;
|
|
||||||
Some(ActivityStream::new(coll))
|
Some(ActivityStream::new(coll))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user