]> Untitled Git - lemmy.git/blob - crates/apub/src/activities/post/mod.rs
Merge pull request #1660 from LemmyNet/merge-apub-crates
[lemmy.git] / crates / apub / src / activities / post / mod.rs
1 use lemmy_api_common::{blocking, post::PostResponse};
2 use lemmy_db_schema::PostId;
3 use lemmy_db_views::post_view::PostView;
4 use lemmy_utils::LemmyError;
5 use lemmy_websocket::{messages::SendPost, LemmyContext};
6
7 pub mod create;
8 pub mod update;
9
10 pub(crate) async fn send_websocket_message<
11   OP: ToString + Send + lemmy_websocket::OperationType + 'static,
12 >(
13   post_id: PostId,
14   op: OP,
15   context: &LemmyContext,
16 ) -> Result<(), LemmyError> {
17   let post_view = blocking(context.pool(), move |conn| {
18     PostView::read(conn, post_id, None)
19   })
20   .await??;
21
22   let res = PostResponse { post_view };
23
24   context.chat_server().do_send(SendPost {
25     op,
26     post: res,
27     websocket_id: None,
28   });
29
30   Ok(())
31 }