]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/collections/group_followers.rs
Check user accepted before sending jwt in password reset (fixes #2591) (#2597)
[lemmy.git] / crates / apub / src / protocol / collections / group_followers.rs
1 use crate::generate_followers_url;
2 use activitystreams_kinds::collection::CollectionType;
3 use lemmy_db_schema::source::community::Community;
4 use lemmy_db_views_actor::structs::CommunityFollowerView;
5 use lemmy_utils::error::LemmyError;
6 use lemmy_websocket::LemmyContext;
7 use serde::{Deserialize, Serialize};
8 use url::Url;
9
10 #[derive(Clone, Debug, Deserialize, Serialize)]
11 #[serde(rename_all = "camelCase")]
12 pub(crate) struct GroupFollowers {
13   id: Url,
14   r#type: CollectionType,
15   total_items: i32,
16   items: Vec<()>,
17 }
18
19 impl GroupFollowers {
20   pub(crate) async fn new(
21     community: Community,
22     context: &LemmyContext,
23   ) -> Result<GroupFollowers, LemmyError> {
24     let community_id = community.id;
25     let community_followers =
26       CommunityFollowerView::for_community(context.pool(), community_id).await?;
27
28     Ok(GroupFollowers {
29       id: generate_followers_url(&community.actor_id)?.into(),
30       r#type: CollectionType::Collection,
31       total_items: community_followers.len() as i32,
32       items: vec![],
33     })
34   }
35 }