From 78b05350631c7a2d2cb71b6569f9b84251e37243 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 14 Feb 2022 02:38:13 +0900 Subject: [PATCH] Implement User::fetch_outbox_page07() --- plume-models/src/users.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 70e102c6..04241cd4 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -20,6 +20,7 @@ use activitystreams::{ OrderedCollection as OrderedCollection07, OrderedCollectionPage as OrderedCollectionPage07, }, iri_string::types::IriString, + markers::Activity as Activity07, object::{AsObject as _, Image as Image07, Tombstone as Tombstone07}, prelude::*, }; @@ -560,6 +561,23 @@ impl User { let next = json.get("next").map(|x| x.as_str().unwrap().to_owned()); Ok((items, next)) } + pub fn fetch_outbox_page07( + &self, + url: &str, + ) -> Result<(Vec, Option)> { + let mut res = get(url, Self::get_sender(), CONFIG.proxy().cloned())?; + let text = &res.text()?; + let json: serde_json::Value = serde_json::from_str(text)?; + let items = json["items"] + .as_array() + .unwrap_or(&vec![]) + .iter() + .filter_map(|j| serde_json::from_value(j.clone()).ok()) + .collect::>(); + + let next = json.get("next").map(|x| x.as_str().unwrap().to_owned()); + Ok((items, next)) + } pub fn fetch_outbox(&self) -> Result> { let mut res = get( &self.outbox_url[..],