From d62f51665bc46bdc5be5772bef8d33c13b45bbb6 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 13 Feb 2022 02:09:28 +0900 Subject: [PATCH] Implement User::outbox_collection07() --- plume-models/src/users.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index ebd44867..9b305e54 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -12,7 +12,9 @@ use activitypub::{ Activity, CustomObject, Endpoint, }; 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 diesel::{self, BelongingToDsl, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl}; @@ -449,6 +451,19 @@ impl User { .set_total_items_u64(self.get_activities_count(conn) as u64)?; Ok(coll) } + pub fn outbox_collection07(&self, conn: &Connection) -> Result { + 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::()?); + coll.set_last(last.parse::()?); + coll.set_total_items(self.get_activities_count(conn) as u64); + Ok(coll) + } pub fn outbox_page( &self, conn: &Connection,