X-Git-Url: http://these/git/?a=blobdiff_plain;f=server%2Fsrc%2Fwebsocket%2Fserver.rs;h=0c606284537c4c6f3fa4de9b8edfca6d39a53a6d;hb=d932acad165f21f0cc7c952805596a60fc068627;hp=a26c8144e0fd805df43c379180a5b9dd92234b4c;hpb=420fb5a847cc549a46596407c32c9ad8d581b321;p=lemmy.git diff --git a/server/src/websocket/server.rs b/server/src/websocket/server.rs index a26c8144..0c606284 100644 --- a/server/src/websocket/server.rs +++ b/server/src/websocket/server.rs @@ -19,6 +19,7 @@ use crate::api::post::*; use crate::api::site::*; use crate::api::user::*; use crate::api::*; +use crate::apub::puller::*; use crate::websocket::UserOperation; use crate::Settings; @@ -486,7 +487,24 @@ fn parse_json_message(chat: &mut ChatServer, msg: StandardMessage) -> Result { let get_community: GetCommunity = serde_json::from_str(data)?; - let mut res = Oper::new(get_community).perform(&conn)?; + + let mut res = if Settings::get().federation_enabled { + if let Some(community_name) = get_community.name.to_owned() { + if community_name.contains('@') { + // TODO: need to support sort, filter etc for remote communities + get_remote_community(community_name)? + // TODO what is this about + // get_community.name = Some(name.replace("!", "")); + } else { + Oper::new(get_community).perform(&conn)? + } + } else { + Oper::new(get_community).perform(&conn)? + } + } else { + Oper::new(get_community).perform(&conn)? + }; + let community_id = res.community.id; chat.join_community_room(community_id, msg.id); @@ -500,7 +518,13 @@ fn parse_json_message(chat: &mut ChatServer, msg: StandardMessage) -> Result { - do_user_operation::(user_operation, data, &conn) + if Settings::get().federation_enabled { + let res = get_all_communities()?; + let val = ListCommunitiesResponse { communities: res }; + to_json_string(&user_operation, &val) + } else { + do_user_operation::(user_operation, data, &conn) + } } UserOperation::CreateCommunity => { chat.check_rate_limit_register(msg.id)?;