1 use crate::{check_is_apub_id_valid, CommunityType};
2 use itertools::Itertools;
3 use lemmy_api_common::{blocking, community::CommunityResponse};
4 use lemmy_db_schema::{source::community::Community, CommunityId};
5 use lemmy_db_views_actor::community_view::CommunityView;
6 use lemmy_utils::{settings::structs::Settings, LemmyError};
7 use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext};
13 pub mod undo_block_user;
16 pub(crate) async fn send_websocket_message<
17 OP: ToString + Send + lemmy_websocket::OperationType + 'static,
19 community_id: CommunityId,
21 context: &LemmyContext,
22 ) -> Result<(), LemmyError> {
23 let community_view = blocking(context.pool(), move |conn| {
24 CommunityView::read(conn, community_id, None)
28 let res = CommunityResponse { community_view };
30 context.chat_server().do_send(SendCommunityRoomMessage {
40 async fn list_community_follower_inboxes(
41 community: &Community,
42 additional_inboxes: Vec<Url>,
43 context: &LemmyContext,
44 ) -> Result<Vec<Url>, LemmyError> {
47 community.get_follower_inboxes(context.pool()).await?,
53 .filter(|inbox| inbox.host_str() != Some(&Settings::get().hostname()))
54 .filter(|inbox| check_is_apub_id_valid(inbox, false).is_ok())
55 .map(|inbox| inbox.to_owned())