diff --git a/api_tests/package.json b/api_tests/package.json index 849b721e7..4deffe4f6 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -16,7 +16,7 @@ "eslint": "^7.30.0", "eslint-plugin-jane": "^9.0.3", "jest": "^27.0.6", - "lemmy-js-client": "0.17.0-rc.2", + "lemmy-js-client": "0.17.0-rc.3", "node-fetch": "^2.6.1", "prettier": "^2.3.2", "ts-jest": "^27.0.3", diff --git a/api_tests/yarn.lock b/api_tests/yarn.lock index 8e0754863..3b198755d 100644 --- a/api_tests/yarn.lock +++ b/api_tests/yarn.lock @@ -3076,10 +3076,10 @@ language-tags@^1.0.5: dependencies: language-subtag-registry "~0.3.2" -lemmy-js-client@0.17.0-rc.2: - version "0.17.0-rc.2" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.2.tgz#4e6ff9a8d83ac922cd36eeaa01c657b3b93309e6" - integrity sha512-2YkZiAkq2ZUHPSl/B7pvMMkI19XRtTKwLFJ1u4NT2BlFkNdlvkvkOddnJ6aRwKAp/WBohxoKLoDHhlwePS5gqA== +lemmy-js-client@0.17.0-rc.3: + version "0.17.0-rc.3" + resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.3.tgz#3c9b3d5e3346eed8cb8096dad527e72096052223" + integrity sha512-VwKSkjqZhsTrtlKTKs9DEVaj9rlmMEjzn/BxkizU9v03Km7OIs9Z7cOEfperOR9A6q5gh2hWfTDp5eV/0kYkVg== leven@^3.1.0: version "3.1.0" diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index 60fd32270..f4a727ebe 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -76,7 +76,7 @@ impl Perform for BanFromCommunity { let community_follower_form = CommunityFollowerForm { community_id: data.community_id, person_id: banned_person_id, - pending: false, + pending: Some(false), }; blocking(context.pool(), move |conn: &'_ _| { CommunityFollower::unfollow(conn, &community_follower_form) diff --git a/crates/api/src/community/block.rs b/crates/api/src/community/block.rs index 4f740c916..a8672e3e2 100644 --- a/crates/api/src/community/block.rs +++ b/crates/api/src/community/block.rs @@ -47,7 +47,7 @@ impl Perform for BlockCommunity { let community_follower_form = CommunityFollowerForm { community_id: data.community_id, person_id, - pending: false, + pending: Some(false), }; blocking(context.pool(), move |conn: &'_ _| { CommunityFollower::unfollow(conn, &community_follower_form) diff --git a/crates/api/src/community/follow.rs b/crates/api/src/community/follow.rs index a61383b21..15a56b17b 100644 --- a/crates/api/src/community/follow.rs +++ b/crates/api/src/community/follow.rs @@ -47,7 +47,7 @@ impl Perform for FollowCommunity { let community_follower_form = CommunityFollowerForm { community_id: data.community_id, person_id: local_user_view.person.id, - pending: false, // Don't worry, this form isn't used for remote follows + pending: Some(false), // Don't worry, this form isn't used for remote follows }; if community.local { diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index a7582d2ec..451e9bfa0 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -123,7 +123,7 @@ impl PerformCrud for CreateCommunity { let community_follower_form = CommunityFollowerForm { community_id: inserted_community.id, person_id: local_user_view.person.id, - pending: false, + pending: Some(false), }; let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form); diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index 456617043..6752dcc84 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -232,7 +232,7 @@ impl PerformCrud for Register { let community_follower_form = CommunityFollowerForm { community_id: main_community.id, person_id: inserted_person.id, - pending: false, + pending: Some(false), }; let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form); diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index bcab3148a..c05f2f87a 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -200,7 +200,7 @@ impl ActivityHandler for BlockUser { let community_follower_form = CommunityFollowerForm { community_id: community.id, person_id: blocked_person.id, - pending: false, + pending: Some(false), }; blocking(context.pool(), move |conn: &'_ _| { CommunityFollower::unfollow(conn, &community_follower_form) diff --git a/crates/apub/src/activities/following/follow.rs b/crates/apub/src/activities/following/follow.rs index d46b3dc20..eb70cb91f 100644 --- a/crates/apub/src/activities/following/follow.rs +++ b/crates/apub/src/activities/following/follow.rs @@ -50,7 +50,7 @@ impl FollowCommunity { let community_follower_form = CommunityFollowerForm { community_id: community.id, person_id: actor.id, - pending: true, + pending: Some(true), }; blocking(context.pool(), move |conn| { CommunityFollower::follow(conn, &community_follower_form).ok() @@ -100,7 +100,7 @@ impl ActivityHandler for FollowCommunity { let community_follower_form = CommunityFollowerForm { community_id: community.id, person_id: person.id, - pending: false, + pending: Some(false), }; // This will fail if they're already a follower, but ignore the error. diff --git a/crates/apub/src/activities/following/undo_follow.rs b/crates/apub/src/activities/following/undo_follow.rs index f70acdf27..f579d2323 100644 --- a/crates/apub/src/activities/following/undo_follow.rs +++ b/crates/apub/src/activities/following/undo_follow.rs @@ -77,7 +77,7 @@ impl ActivityHandler for UndoFollowCommunity { let community_follower_form = CommunityFollowerForm { community_id: community.id, person_id: person.id, - pending: false, + pending: Some(false), }; // This will fail if they aren't a follower, but ignore the error. diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index 950e68d37..fc8cf0b06 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -66,7 +66,7 @@ mod tests { let first_person_follow = CommunityFollowerForm { community_id: inserted_community.id, person_id: inserted_person.id, - pending: false, + pending: Some(false), }; CommunityFollower::follow(&conn, &first_person_follow).unwrap(); @@ -74,7 +74,7 @@ mod tests { let second_person_follow = CommunityFollowerForm { community_id: inserted_community.id, person_id: another_inserted_person.id, - pending: false, + pending: Some(false), }; CommunityFollower::follow(&conn, &second_person_follow).unwrap(); @@ -82,7 +82,7 @@ mod tests { let another_community_follow = CommunityFollowerForm { community_id: another_inserted_community.id, person_id: inserted_person.id, - pending: false, + pending: Some(false), }; CommunityFollower::follow(&conn, &another_community_follow).unwrap(); diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 14a670f51..18619de6f 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -380,7 +380,7 @@ mod tests { let community_follower_form = CommunityFollowerForm { community_id: inserted_community.id, person_id: inserted_person.id, - pending: false, + pending: Some(false), }; let inserted_community_follower = @@ -390,7 +390,7 @@ mod tests { id: inserted_community_follower.id, community_id: inserted_community.id, person_id: inserted_person.id, - pending: Some(false), + pending: false, published: inserted_community_follower.published, }; diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 666986a69..74285e3c6 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -119,7 +119,7 @@ table! { community_id -> Int4, person_id -> Int4, published -> Timestamp, - pending -> Nullable, + pending -> Bool, } } diff --git a/crates/db_schema/src/source/community.rs b/crates/db_schema/src/source/community.rs index 7693f2f41..9700e07a6 100644 --- a/crates/db_schema/src/source/community.rs +++ b/crates/db_schema/src/source/community.rs @@ -128,7 +128,7 @@ pub struct CommunityFollower { pub community_id: CommunityId, pub person_id: PersonId, pub published: chrono::NaiveDateTime, - pub pending: Option, + pub pending: bool, } #[derive(Clone)] @@ -137,5 +137,5 @@ pub struct CommunityFollower { pub struct CommunityFollowerForm { pub community_id: CommunityId, pub person_id: PersonId, - pub pending: bool, + pub pending: Option, } diff --git a/crates/db_views_actor/src/community_follower_view.rs b/crates/db_views_actor/src/community_follower_view.rs index 7e37e446a..7bece59d3 100644 --- a/crates/db_views_actor/src/community_follower_view.rs +++ b/crates/db_views_actor/src/community_follower_view.rs @@ -10,7 +10,7 @@ use lemmy_db_schema::{ traits::{ToSafe, ViewToVec}, }; -type CommunityFollowerViewTuple = (CommunitySafe, PersonSafe, Option); +type CommunityFollowerViewTuple = (CommunitySafe, PersonSafe, bool); impl CommunityFollowerView { pub fn for_community(conn: &PgConnection, community_id: CommunityId) -> Result, Error> { diff --git a/crates/db_views_actor/src/structs.rs b/crates/db_views_actor/src/structs.rs index 25d2c178e..a0b1ad4bc 100644 --- a/crates/db_views_actor/src/structs.rs +++ b/crates/db_views_actor/src/structs.rs @@ -20,7 +20,7 @@ pub struct CommunityBlockView { pub struct CommunityFollowerView { pub community: CommunitySafe, pub follower: PersonSafe, - pub pending: Option, + pub pending: bool, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/migrations/2022-05-10-173801_change_pending_to_notnull/down.sql b/migrations/2022-05-10-173801_change_pending_to_notnull/down.sql new file mode 100644 index 000000000..4ef1387af --- /dev/null +++ b/migrations/2022-05-10-173801_change_pending_to_notnull/down.sql @@ -0,0 +1,5 @@ +-- This file should undo anything in `up.sql` + +alter table community_follower + alter column pending drop not null, + alter column pending set default false; diff --git a/migrations/2022-05-10-173801_change_pending_to_notnull/up.sql b/migrations/2022-05-10-173801_change_pending_to_notnull/up.sql new file mode 100644 index 000000000..c589ac62c --- /dev/null +++ b/migrations/2022-05-10-173801_change_pending_to_notnull/up.sql @@ -0,0 +1,8 @@ +-- Make the pending column not null + +update community_follower set pending = true where pending is null; + +alter table community_follower + alter column pending set not null, + alter column pending set default true; +