From eab1862e9a4382b758416f6160174c8e0087a202 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 17 Sep 2023 23:38:07 -0400 Subject: [PATCH 01/10] Make deleted and removed comments show when they have childern --- crates/db_views/src/comment_view.rs | 41 +++++++++++------------------ 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index b93f12842..d06bccc92 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -1,37 +1,20 @@ use crate::structs::{CommentView, LocalUserView}; use diesel::{ - pg::Pg, - result::Error, - BoolExpressionMethods, - ExpressionMethods, - JoinOnDsl, - NullableExpressionMethods, - PgTextExpressionMethods, - QueryDsl, + pg::Pg, result::Error, BoolExpressionMethods, ExpressionMethods, JoinOnDsl, + NullableExpressionMethods, PgTextExpressionMethods, QueryDsl, }; use diesel_async::RunQueryDsl; use diesel_ltree::{nlevel, subpath, Ltree, LtreeExtensions}; use lemmy_db_schema::{ newtypes::{CommentId, CommunityId, LocalUserId, PersonId, PostId}, schema::{ - comment, - comment_aggregates, - comment_like, - comment_saved, - community, - community_block, - community_follower, - community_moderator, - community_person_ban, - local_user_language, - person, - person_block, - post, + comment, comment_aggregates, comment_like, comment_saved, community, community_block, + community_follower, community_moderator, community_person_ban, local_user_language, person, + person_block, post, }, source::community::CommunityFollower, utils::{fuzzy_search, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn}, - CommentSortType, - ListingType, + CommentSortType, ListingType, }; fn queries<'a>() -> Queries< @@ -193,7 +176,11 @@ fn queries<'a>() -> Queries< let is_creator = options.creator_id == options.local_user.map(|l| l.person.id); // only show deleted comments to creator if !is_creator { - query = query.filter(comment::deleted.eq(false)); + query = query.filter( + comment::deleted + .eq(false) + .or(comment_aggregates::child_count.gt(0)), + ); } let is_admin = options @@ -202,7 +189,11 @@ fn queries<'a>() -> Queries< .unwrap_or(false); // only show removed comments to admin when viewing user profile if !(options.is_profile_view && is_admin) { - query = query.filter(comment::removed.eq(false)); + query = query.filter( + comment::removed + .eq(false) + .or(comment_aggregates::child_count.gt(0)), + ); } if !options From 05b1ebdc7cbd90a1b5ec8bb66151da85f33fe420 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 18 Sep 2023 02:59:59 -0400 Subject: [PATCH 02/10] Fix comments created by ser not showing up --- crates/db_views/src/comment_view.rs | 41 ++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index d06bccc92..4f76f0e41 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -1,20 +1,37 @@ use crate::structs::{CommentView, LocalUserView}; use diesel::{ - pg::Pg, result::Error, BoolExpressionMethods, ExpressionMethods, JoinOnDsl, - NullableExpressionMethods, PgTextExpressionMethods, QueryDsl, + pg::Pg, + result::Error, + BoolExpressionMethods, + ExpressionMethods, + JoinOnDsl, + NullableExpressionMethods, + PgTextExpressionMethods, + QueryDsl, }; use diesel_async::RunQueryDsl; use diesel_ltree::{nlevel, subpath, Ltree, LtreeExtensions}; use lemmy_db_schema::{ newtypes::{CommentId, CommunityId, LocalUserId, PersonId, PostId}, schema::{ - comment, comment_aggregates, comment_like, comment_saved, community, community_block, - community_follower, community_moderator, community_person_ban, local_user_language, person, - person_block, post, + comment, + comment_aggregates, + comment_like, + comment_saved, + community, + community_block, + community_follower, + community_moderator, + community_person_ban, + local_user_language, + person, + person_block, + post, }, source::community::CommunityFollower, utils::{fuzzy_search, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn}, - CommentSortType, ListingType, + CommentSortType, + ListingType, }; fn queries<'a>() -> Queries< @@ -173,9 +190,15 @@ fn queries<'a>() -> Queries< query = query.filter(comment_like::score.eq(-1)); } - let is_creator = options.creator_id == options.local_user.map(|l| l.person.id); - // only show deleted comments to creator - if !is_creator { + // only show deleted comments to creator, or if they have children + if let Some(local_user) = options.local_user { + query = query.filter( + comment::deleted + .eq(false) + .or(comment::creator_id.eq(local_user.person.id)) + .or(comment_aggregates::child_count.gt(0)), + ); + } else { query = query.filter( comment::deleted .eq(false) From 6d02a9914c9813216aa91f9ac724fd8a9d1589e0 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 18 Sep 2023 07:38:00 -0400 Subject: [PATCH 03/10] Update translation --- crates/utils/translations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/utils/translations b/crates/utils/translations index 1c42c5794..839f1097d 160000 --- a/crates/utils/translations +++ b/crates/utils/translations @@ -1 +1 @@ -Subproject commit 1c42c579460871de7b4ea18e58dc25543b80d289 +Subproject commit 839f1097d07ba9d730e31f58c892de491442e490 From 7118200cabc645d18fbe387704122adcfd338d6f Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 18 Sep 2023 07:55:38 -0400 Subject: [PATCH 04/10] Use up to date default UI container for dev --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3a68ea131..e8a305b76 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -55,7 +55,7 @@ services: lemmy-ui: # use "image" to pull down an already compiled lemmy-ui. make sure to comment out "build". - image: dessalines/lemmy-ui:0.18.1 + image: dessalines/lemmy-ui:0.18.4 # platform: linux/x86_64 # no arm64 support. uncomment platform if using m1. # use "build" to build your local lemmy ui image for development. make sure to comment out "image". # run: docker compose up --build From f93d08a147ab22d1685679b31174b78199cff5f1 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 18 Sep 2023 19:09:17 -0400 Subject: [PATCH 05/10] Make moderators be able to see removed comments in communities they moderate --- crates/db_views/src/comment_view.rs | 48 ++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 4f76f0e41..4fa5b5b95 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -28,7 +28,7 @@ use lemmy_db_schema::{ person_block, post, }, - source::community::CommunityFollower, + source::{community::CommunityFollower, person::Person}, utils::{fuzzy_search, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn}, CommentSortType, ListingType, @@ -190,33 +190,51 @@ fn queries<'a>() -> Queries< query = query.filter(comment_like::score.eq(-1)); } + let is_admin = options + .local_user + .map(|l| l.local_user.admin) + .unwrap_or(false); + // only show deleted comments to creator, or if they have children - if let Some(local_user) = options.local_user { + if let Some(LocalUserView { + person: Person { id, .. }, + .. + }) = options.local_user + { query = query.filter( comment::deleted .eq(false) - .or(comment::creator_id.eq(local_user.person.id)) + .or(comment::creator_id.eq(id)) .or(comment_aggregates::child_count.gt(0)), ); + + if !is_admin { + query = query.filter( + comment::removed + .eq(false) + .or(comment_aggregates::child_count.gt(0)) + .or( + post::id + .eq(comment::post_id) + .and(post::community_id.eq(community_moderator::community_id)) + .and(community_moderator::person_id.eq(id)), + ), + ); + } } else { query = query.filter( comment::deleted .eq(false) .or(comment_aggregates::child_count.gt(0)), ); - } - let is_admin = options - .local_user - .map(|l| l.local_user.admin) - .unwrap_or(false); - // only show removed comments to admin when viewing user profile - if !(options.is_profile_view && is_admin) { - query = query.filter( - comment::removed - .eq(false) - .or(comment_aggregates::child_count.gt(0)), - ); + if !is_admin { + query = query.filter( + comment::removed + .eq(false) + .or(comment_aggregates::child_count.gt(0)), + ); + } } if !options From be961075c79416525c55fbd78100e88d1fed26b2 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 18 Sep 2023 19:31:12 -0400 Subject: [PATCH 06/10] Do not filter removed and deleted comments on the backend --- crates/db_views/src/comment_view.rs | 47 ----------------------------- 1 file changed, 47 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 4fa5b5b95..54c693b4a 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -190,53 +190,6 @@ fn queries<'a>() -> Queries< query = query.filter(comment_like::score.eq(-1)); } - let is_admin = options - .local_user - .map(|l| l.local_user.admin) - .unwrap_or(false); - - // only show deleted comments to creator, or if they have children - if let Some(LocalUserView { - person: Person { id, .. }, - .. - }) = options.local_user - { - query = query.filter( - comment::deleted - .eq(false) - .or(comment::creator_id.eq(id)) - .or(comment_aggregates::child_count.gt(0)), - ); - - if !is_admin { - query = query.filter( - comment::removed - .eq(false) - .or(comment_aggregates::child_count.gt(0)) - .or( - post::id - .eq(comment::post_id) - .and(post::community_id.eq(community_moderator::community_id)) - .and(community_moderator::person_id.eq(id)), - ), - ); - } - } else { - query = query.filter( - comment::deleted - .eq(false) - .or(comment_aggregates::child_count.gt(0)), - ); - - if !is_admin { - query = query.filter( - comment::removed - .eq(false) - .or(comment_aggregates::child_count.gt(0)), - ); - } - } - if !options .local_user .map(|l| l.local_user.show_bot_accounts) From 671676d7e453234847356b06d4aa686245b004ef Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 18 Sep 2023 19:40:01 -0400 Subject: [PATCH 07/10] Remove unused import --- crates/db_views/src/comment_view.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 54c693b4a..3f3e800d5 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -28,7 +28,7 @@ use lemmy_db_schema::{ person_block, post, }, - source::{community::CommunityFollower, person::Person}, + source::community::CommunityFollower, utils::{fuzzy_search, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn}, CommentSortType, ListingType, From dc6dee61b96f4b63a0040127ba27cf0355036edd Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 18 Sep 2023 21:19:08 -0400 Subject: [PATCH 08/10] Force update --- src/code_migrations.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/code_migrations.rs b/src/code_migrations.rs index e274ca940..4f4ba0223 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -1,4 +1,5 @@ // This is for db migrations that require code + use activitypub_federation::http_signatures::generate_actor_keypair; use diesel::{ sql_types::{Nullable, Text}, From 3812c8bf8157c3526324daab3203c5ae78c25d7b Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 18 Sep 2023 21:20:06 -0400 Subject: [PATCH 09/10] Force update 2 --- src/code_migrations.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/code_migrations.rs b/src/code_migrations.rs index 4f4ba0223..e274ca940 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -1,5 +1,4 @@ // This is for db migrations that require code - use activitypub_federation::http_signatures::generate_actor_keypair; use diesel::{ sql_types::{Nullable, Text}, From 553c5bda8809f001fdb4691e31245cd11abb287c Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 18 Sep 2023 22:07:31 -0400 Subject: [PATCH 10/10] Update versions to correct version --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 24 ++++++++++++------------ docker/docker-compose.yml | 2 +- docker/federation/docker-compose.yml | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb72acb69..ffd7e54b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2606,7 +2606,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lemmy_api" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2635,7 +2635,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2667,7 +2667,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2688,7 +2688,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2725,7 +2725,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "async-trait", @@ -2761,7 +2761,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.18.1" +version = "0.18.4" dependencies = [ "actix-web", "diesel", @@ -2779,7 +2779,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.18.1" +version = "0.18.4" dependencies = [ "chrono", "diesel", @@ -2792,7 +2792,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.18.1" +version = "0.18.4" dependencies = [ "diesel", "diesel-async", @@ -2804,7 +2804,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "anyhow", @@ -2836,7 +2836,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2861,7 +2861,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.18.1" +version = "0.18.4" dependencies = [ "activitypub_federation", "actix-cors", @@ -2907,7 +2907,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.18.1" +version = "0.18.4" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 72ab87d4f..02210e6c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.18.1" +version = "0.18.4" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -58,16 +58,16 @@ members = [ ] [workspace.dependencies] -lemmy_api = { version = "=0.18.1", path = "./crates/api" } -lemmy_api_crud = { version = "=0.18.1", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.18.1", path = "./crates/apub" } -lemmy_utils = { version = "=0.18.1", path = "./crates/utils" } -lemmy_db_schema = { version = "=0.18.1", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.18.1", path = "./crates/api_common" } -lemmy_routes = { version = "=0.18.1", path = "./crates/routes" } -lemmy_db_views = { version = "=0.18.1", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.18.1", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.18.1", path = "./crates/db_views_moderator" } +lemmy_api = { version = "=0.18.4", path = "./crates/api" } +lemmy_api_crud = { version = "=0.18.4", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.18.4", path = "./crates/apub" } +lemmy_utils = { version = "=0.18.4", path = "./crates/utils" } +lemmy_db_schema = { version = "=0.18.4", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.18.4", path = "./crates/api_common" } +lemmy_routes = { version = "=0.18.4", path = "./crates/routes" } +lemmy_db_views = { version = "=0.18.4", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.18.4", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.18.4", path = "./crates/db_views_moderator" } activitypub_federation = { version = "0.5.0-beta.3", default-features = false, features = [ "actix-web", ] } @@ -167,4 +167,4 @@ chrono = { workspace = true } prometheus = { version = "0.13.3", features = ["process"], optional = true } actix-web-prom = { version = "0.6.0", optional = true } clap = { version = "4.3.19", features = ["derive"] } -lemmy_federate = { version = "0.18.1", path = "crates/federate" } +lemmy_federate = { version = "0.18.4", path = "crates/federate" } diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e8a305b76..a61f25973 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -25,7 +25,7 @@ services: lemmy: # use "image" to pull down an already compiled lemmy. make sure to comment out "build". - # image: dessalines/lemmy:0.18.1 + # image: dessalines/lemmy:0.18.4 # platform: linux/x86_64 # no arm64 support. uncomment platform if using m1. # use "build" to build your local lemmy server image for development. make sure to comment out "image". # run: docker compose up --build diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 39ff95248..2545e4201 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.7" x-ui-default: &ui-default init: true - image: dessalines/lemmy-ui:0.18.1 + image: dessalines/lemmy-ui:0.18.4 # assuming lemmy-ui is cloned besides lemmy directory # build: # context: ../../../lemmy-ui