Implement User::outbox_collection07()

This commit is contained in:
Kitaiti Makoto 2022-02-13 02:09:28 +09:00
parent e42aa6fe8e
commit d62f51665b

View File

@ -12,7 +12,9 @@ use activitypub::{
Activity, CustomObject, Endpoint, Activity, CustomObject, Endpoint,
}; };
use activitystreams::{ use activitystreams::{
activity::Delete as Delete07, actor::AsApActor, object::AsObject as _, prelude::*, activity::Delete as Delete07, actor::AsApActor,
collection::OrderedCollection as OrderedCollection07, iri_string::types::IriString,
object::AsObject as _, prelude::*,
}; };
use chrono::{NaiveDateTime, Utc}; use chrono::{NaiveDateTime, Utc};
use diesel::{self, BelongingToDsl, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl}; use diesel::{self, BelongingToDsl, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl};
@ -449,6 +451,19 @@ impl User {
.set_total_items_u64(self.get_activities_count(conn) as u64)?; .set_total_items_u64(self.get_activities_count(conn) as u64)?;
Ok(coll) Ok(coll)
} }
pub fn outbox_collection07(&self, conn: &Connection) -> Result<OrderedCollection07> {
let mut coll = OrderedCollection07::new();
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.set_first(first.parse::<IriString>()?);
coll.set_last(last.parse::<IriString>()?);
coll.set_total_items(self.get_activities_count(conn) as u64);
Ok(coll)
}
pub fn outbox_page( pub fn outbox_page(
&self, &self,
conn: &Connection, conn: &Connection,