From: Dessalines Date: Wed, 17 Apr 2019 15:50:44 +0000 (-0700) Subject: Community modlog doesn't show non-community actions. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/static/%7Bthis.props.icon%7D?a=commitdiff_plain;h=f17b181ea91690135a807dff33d09be4ef4b1a0d;p=lemmy.git Community modlog doesn't show non-community actions. Fixes #65 --- diff --git a/server/src/actions/post_view.rs b/server/src/actions/post_view.rs index 0ebcf40d..f95c0177 100644 --- a/server/src/actions/post_view.rs +++ b/server/src/actions/post_view.rs @@ -116,6 +116,9 @@ impl PostView { .order_by(score.desc()) }; + + // TODO make sure community removed isn't fetched either + query = query.filter(removed.eq(false)); query.load::(conn) diff --git a/server/src/websocket_server/server.rs b/server/src/websocket_server/server.rs index ef05f801..6b91a76b 100644 --- a/server/src/websocket_server/server.rs +++ b/server/src/websocket_server/server.rs @@ -1792,11 +1792,19 @@ impl Perform for GetModlog { let removed_posts = ModRemovePostView::list(&conn, self.community_id, self.mod_user_id, self.limit, self.page).unwrap(); let locked_posts = ModLockPostView::list(&conn, self.community_id, self.mod_user_id, self.limit, self.page).unwrap(); let removed_comments = ModRemoveCommentView::list(&conn, self.community_id, self.mod_user_id, self.limit, self.page).unwrap(); - let removed_communities = ModRemoveCommunityView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); let banned_from_community = ModBanFromCommunityView::list(&conn, self.community_id, self.mod_user_id, self.limit, self.page).unwrap(); - let banned = ModBanView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); let added_to_community = ModAddCommunityView::list(&conn, self.community_id, self.mod_user_id, self.limit, self.page).unwrap(); - let added = ModAddView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); + + // These arrays are only for the full modlog, when a community isn't given + let mut removed_communities = Vec::new(); + let mut banned = Vec::new(); + let mut added = Vec::new(); + + if self.community_id.is_none() { + removed_communities = ModRemoveCommunityView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); + banned = ModBanView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); + added = ModAddView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); + } // Return the jwt serde_json::to_string(