Use User::outbox07() instead of outbox()
This commit is contained in:
parent
68c794c54b
commit
fd341bdb22
@ -7,7 +7,6 @@ use crate::{
|
|||||||
use activitypub::{
|
use activitypub::{
|
||||||
activity::Delete,
|
activity::Delete,
|
||||||
actor::Person,
|
actor::Person,
|
||||||
collection::OrderedCollection,
|
|
||||||
object::{Image, Tombstone},
|
object::{Image, Tombstone},
|
||||||
Activity, CustomObject, Endpoint,
|
Activity, CustomObject, Endpoint,
|
||||||
};
|
};
|
||||||
@ -470,26 +469,9 @@ impl User {
|
|||||||
.load::<User>(conn)
|
.load::<User>(conn)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
}
|
}
|
||||||
pub fn outbox(&self, conn: &Connection) -> Result<ActivityStream<OrderedCollection>> {
|
|
||||||
Ok(ActivityStream::new(self.outbox_collection(conn)?))
|
|
||||||
}
|
|
||||||
pub fn outbox07(&self, conn: &Connection) -> Result<ActivityStream<OrderedCollection07>> {
|
pub fn outbox07(&self, conn: &Connection) -> Result<ActivityStream<OrderedCollection07>> {
|
||||||
Ok(ActivityStream::new(self.outbox_collection07(conn)?))
|
Ok(ActivityStream::new(self.outbox_collection07(conn)?))
|
||||||
}
|
}
|
||||||
pub fn outbox_collection(&self, conn: &Connection) -> Result<OrderedCollection> {
|
|
||||||
let mut coll = OrderedCollection::default();
|
|
||||||
let first = &format!("{}?page=1", &self.outbox_url);
|
|
||||||
let last = &format!(
|
|
||||||
"{}?page={}",
|
|
||||||
&self.outbox_url,
|
|
||||||
self.get_activities_count(conn) / i64::from(ITEMS_PER_PAGE) + 1
|
|
||||||
);
|
|
||||||
coll.collection_props.set_first_link(Id::new(first))?;
|
|
||||||
coll.collection_props.set_last_link(Id::new(last))?;
|
|
||||||
coll.collection_props
|
|
||||||
.set_total_items_u64(self.get_activities_count(conn) as u64)?;
|
|
||||||
Ok(coll)
|
|
||||||
}
|
|
||||||
pub fn outbox_collection07(&self, conn: &Connection) -> Result<OrderedCollection07> {
|
pub fn outbox_collection07(&self, conn: &Connection) -> Result<OrderedCollection07> {
|
||||||
let mut coll = OrderedCollection07::new();
|
let mut coll = OrderedCollection07::new();
|
||||||
let first = &format!("{}?page=1", &self.outbox_url);
|
let first = &format!("{}?page=1", &self.outbox_url);
|
||||||
@ -1770,28 +1752,6 @@ pub(crate) mod tests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn outbox_collection() {
|
|
||||||
let conn = db();
|
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
|
||||||
let (_pages, users, _blogs) = fill_pages(&conn);
|
|
||||||
let user = &users[0];
|
|
||||||
let act = user.outbox_collection(&conn)?;
|
|
||||||
|
|
||||||
let expected = json!({
|
|
||||||
"first": "https://plu.me/@/admin/outbox?page=1",
|
|
||||||
"items": null,
|
|
||||||
"last": "https://plu.me/@/admin/outbox?page=5",
|
|
||||||
"totalItems": 51,
|
|
||||||
"type": "OrderedCollection",
|
|
||||||
});
|
|
||||||
|
|
||||||
assert_json_eq!(to_value(act)?, expected);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn outbox_collection07() {
|
fn outbox_collection07() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use activitypub::collection::OrderedCollection;
|
use activitypub::collection::OrderedCollection;
|
||||||
use activitystreams::collection::OrderedCollectionPage;
|
use activitystreams::collection::{
|
||||||
|
OrderedCollection as OrderedCollection07, OrderedCollectionPage,
|
||||||
|
};
|
||||||
use diesel::SaveChangesDsl;
|
use diesel::SaveChangesDsl;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
http::{uri::Uri, ContentType, Cookies},
|
http::{uri::Uri, ContentType, Cookies},
|
||||||
@ -527,9 +529,9 @@ pub fn create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/@/<name>/outbox")]
|
#[get("/@/<name>/outbox")]
|
||||||
pub fn outbox(name: String, conn: DbConn) -> Option<ActivityStream<OrderedCollection>> {
|
pub fn outbox(name: String, conn: DbConn) -> Option<ActivityStream<OrderedCollection07>> {
|
||||||
let user = User::find_by_fqn(&conn, &name).ok()?;
|
let user = User::find_by_fqn(&conn, &name).ok()?;
|
||||||
user.outbox(&conn).ok()
|
user.outbox07(&conn).ok()
|
||||||
}
|
}
|
||||||
#[get("/@/<name>/outbox?<page>")]
|
#[get("/@/<name>/outbox?<page>")]
|
||||||
pub fn outbox_page(
|
pub fn outbox_page(
|
||||||
|
Loading…
Reference in New Issue
Block a user