]> Untitled Git - lemmy.git/commitdiff
Making community_follower.pending column not null.
authorDessalines <tyhou13@gmx.com>
Tue, 10 May 2022 18:14:01 +0000 (14:14 -0400)
committerNutomic <me@nutomic.com>
Fri, 20 May 2022 16:15:14 +0000 (16:15 +0000)
18 files changed:
api_tests/package.json
api_tests/yarn.lock
crates/api/src/community/ban.rs
crates/api/src/community/block.rs
crates/api/src/community/follow.rs
crates/api_crud/src/community/create.rs
crates/api_crud/src/user/create.rs
crates/apub/src/activities/block/block_user.rs
crates/apub/src/activities/following/follow.rs
crates/apub/src/activities/following/undo_follow.rs
crates/db_schema/src/aggregates/community_aggregates.rs
crates/db_schema/src/impls/community.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/community.rs
crates/db_views_actor/src/community_follower_view.rs
crates/db_views_actor/src/structs.rs
migrations/2022-05-10-173801_change_pending_to_notnull/down.sql [new file with mode: 0644]
migrations/2022-05-10-173801_change_pending_to_notnull/up.sql [new file with mode: 0644]

index 849b721e7daee62d5451b3c4f36fea02ccc73cfb..4deffe4f686896d65335512f6d9dbe577e11ca3d 100644 (file)
@@ -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",
index 8e07548633f8900f84cf7e8324154f1ac005ee03..3b198755d530b3bf376b1a0f51a9194131de22d0 100644 (file)
@@ -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"
index 60fd32270f76ae7db7022ea0fa32bbe2e2ba4477..f4a727ebe446d42e0c30111db90c9d9a4bffc032 100644 (file)
@@ -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)
index 4f740c916971182931600786dcfcbb24f000a5e2..a8672e3e2172a52a2090734218ca51d7f23fc97e 100644 (file)
@@ -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)
index a61383b219316bafccc19b1b2ddfe9702c54d96f..15a56b17b0ba50832beaefbea9bf8e0dd6340fa1 100644 (file)
@@ -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 {
index a7582d2ec5bbbf138512bd9850f5b8fd2ece64d1..451e9bfa0cbfad12b628331df20077359df44a27 100644 (file)
@@ -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);
index 456617043d7675bb7ae67723d3a008302f575258..6752dcc84344059f217b40c0c25a136be1742107 100644 (file)
@@ -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);
index bcab3148ac8b594b0e0e87180a7c28663d00ef44..c05f2f87a89d0b8eb2680c3dc7cfc2174c288811 100644 (file)
@@ -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)
index d46b3dc20f130049faa1ff97259d05bc0dae7a7b..eb70cb91f231f0a8c328590e8b6542b41dfeb651 100644 (file)
@@ -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.
index f70acdf2725912ebd57cbf041bd3b20ee13accb6..f579d2323fdfd06d7288110774c0ca4c62e95a57 100644 (file)
@@ -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.
index 950e68d3738a121ada292b373c8128af40afd9a9..fc8cf0b063c40ebd936b4580102af10f937cd273 100644 (file)
@@ -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();
index 14a670f51c58ad1c7e33263b582fd8a678f879cc..18619de6f07dab77c2bc2c9ffc6c5d939ae71b31 100644 (file)
@@ -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,
     };
 
index 666986a691cb9e5a476c98a0cf7fcc0132dd5c9b..74285e3c693360c12fad3c34c0c20bd85f6d9c65 100644 (file)
@@ -119,7 +119,7 @@ table! {
         community_id -> Int4,
         person_id -> Int4,
         published -> Timestamp,
-        pending -> Nullable<Bool>,
+        pending -> Bool,
     }
 }
 
index 7693f2f419c8d88ac335930632873e333d32bed2..9700e07a610a3bcc6c4c694592f8ffb31519e930 100644 (file)
@@ -128,7 +128,7 @@ pub struct CommunityFollower {
   pub community_id: CommunityId,
   pub person_id: PersonId,
   pub published: chrono::NaiveDateTime,
-  pub pending: Option<bool>,
+  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<bool>,
 }
index 7e37e446a774a83a84b2b95d2f0b2ecee9744c50..7bece59d353db42922a969ad1ae571c18ce5dfb9 100644 (file)
@@ -10,7 +10,7 @@ use lemmy_db_schema::{
   traits::{ToSafe, ViewToVec},
 };
 
-type CommunityFollowerViewTuple = (CommunitySafe, PersonSafe, Option<bool>);
+type CommunityFollowerViewTuple = (CommunitySafe, PersonSafe, bool);
 
 impl CommunityFollowerView {
   pub fn for_community(conn: &PgConnection, community_id: CommunityId) -> Result<Vec<Self>, Error> {
index 25d2c178e4163929175a850ae86d23a6a3106cbe..a0b1ad4bccc02ceef0ca94fd515a6982a944ffd0 100644 (file)
@@ -20,7 +20,7 @@ pub struct CommunityBlockView {
 pub struct CommunityFollowerView {
   pub community: CommunitySafe,
   pub follower: PersonSafe,
-  pub pending: Option<bool>,
+  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 (file)
index 0000000..4ef1387
--- /dev/null
@@ -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 (file)
index 0000000..c589ac6
--- /dev/null
@@ -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;
+