]> Untitled Git - lemmy.git/blobdiff - src/api/community.rs
Isomorphic docker (#1124)
[lemmy.git] / src / api / community.rs
similarity index 97%
rename from server/src/api/community.rs
rename to src/api/community.rs
index 8486861c4b38fb4d20a3aa3a355276b62997a8d1..7c8c93f14bd195736626c96aac0269e953c37196 100644 (file)
@@ -44,7 +44,7 @@ impl Perform for GetCommunity {
   async fn perform(
     &self,
     context: &Data<LemmyContext>,
-    websocket_id: Option<ConnectionId>,
+    _websocket_id: Option<ConnectionId>,
   ) -> Result<GetCommunityResponse, LemmyError> {
     let data: &GetCommunity = &self;
     let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
@@ -83,12 +83,6 @@ impl Perform for GetCommunity {
       Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
     };
 
-    if let Some(id) = websocket_id {
-      context
-        .chat_server()
-        .do_send(JoinCommunityRoom { community_id, id });
-    }
-
     let online = context
       .chat_server()
       .send(GetCommunityUsersOnline { community_id })
@@ -844,3 +838,25 @@ pub fn send_community_websocket(
     websocket_id,
   });
 }
+
+#[async_trait::async_trait(?Send)]
+impl Perform for CommunityJoin {
+  type Response = CommunityJoinResponse;
+
+  async fn perform(
+    &self,
+    context: &Data<LemmyContext>,
+    websocket_id: Option<ConnectionId>,
+  ) -> Result<CommunityJoinResponse, LemmyError> {
+    let data: &CommunityJoin = &self;
+
+    if let Some(ws_id) = websocket_id {
+      context.chat_server().do_send(JoinCommunityRoom {
+        community_id: data.community_id,
+        id: ws_id,
+      });
+    }
+
+    Ok(CommunityJoinResponse { joined: true })
+  }
+}