]> Untitled Git - lemmy.git/blob - crates/apub/src/activities/community/mod.rs
Merge apub, apub_receive crates (fixes #1621)
[lemmy.git] / crates / apub / src / activities / community / mod.rs
1 use lemmy_api_common::{blocking, community::CommunityResponse};
2 use lemmy_db_schema::CommunityId;
3 use lemmy_db_views_actor::community_view::CommunityView;
4 use lemmy_utils::LemmyError;
5 use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext};
6
7 pub mod add_mod;
8 pub mod announce;
9 pub mod block_user;
10 pub mod undo_block_user;
11 pub mod update;
12
13 pub(crate) async fn send_websocket_message<
14   OP: ToString + Send + lemmy_websocket::OperationType + 'static,
15 >(
16   community_id: CommunityId,
17   op: OP,
18   context: &LemmyContext,
19 ) -> Result<(), LemmyError> {
20   let community_view = blocking(context.pool(), move |conn| {
21     CommunityView::read(conn, community_id, None)
22   })
23   .await??;
24
25   let res = CommunityResponse { community_view };
26
27   context.chat_server().do_send(SendCommunityRoomMessage {
28     op,
29     response: res,
30     community_id,
31     websocket_id: None,
32   });
33
34   Ok(())
35 }