From 3c111b3062e69b19e68a9b537c23a7e61ae34e94 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 17 May 2022 14:02:48 -0400 Subject: [PATCH] Dropping default on pending column. --- crates/api/src/community/ban.rs | 2 +- crates/api/src/community/block.rs | 2 +- crates/api/src/community/follow.rs | 2 +- crates/api_crud/src/community/create.rs | 2 +- crates/api_crud/src/user/create.rs | 2 +- crates/apub/src/activities/block/block_user.rs | 2 +- crates/apub/src/activities/following/follow.rs | 4 ++-- crates/apub/src/activities/following/undo_follow.rs | 2 +- crates/db_schema/src/aggregates/community_aggregates.rs | 6 +++--- crates/db_schema/src/impls/community.rs | 2 +- crates/db_schema/src/source/community.rs | 2 +- .../2022-05-10-173801_change_pending_to_notnull/up.sql | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index f4a727eb..60fd3227 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: Some(false), + pending: 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 a8672e3e..4f740c91 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: Some(false), + pending: 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 15a56b17..a61383b2 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: Some(false), // Don't worry, this form isn't used for remote follows + pending: 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 451e9bfa..a7582d2e 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: Some(false), + pending: 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 6752dcc8..45661704 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: Some(false), + pending: 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 c05f2f87..bcab3148 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: Some(false), + pending: 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 eb70cb91..d46b3dc2 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: Some(true), + pending: 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: Some(false), + pending: 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 f579d232..f70acdf2 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: Some(false), + pending: 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 fc8cf0b0..950e68d3 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: Some(false), + pending: 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: Some(false), + pending: 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: Some(false), + pending: 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 18619de6..073255cd 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: Some(false), + pending: false, }; let inserted_community_follower = diff --git a/crates/db_schema/src/source/community.rs b/crates/db_schema/src/source/community.rs index 9700e07a..25766b40 100644 --- a/crates/db_schema/src/source/community.rs +++ b/crates/db_schema/src/source/community.rs @@ -137,5 +137,5 @@ pub struct CommunityFollower { pub struct CommunityFollowerForm { pub community_id: CommunityId, pub person_id: PersonId, - pub pending: Option, + pub pending: bool, } 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 index c589ac62..659f321b 100644 --- a/migrations/2022-05-10-173801_change_pending_to_notnull/up.sql +++ b/migrations/2022-05-10-173801_change_pending_to_notnull/up.sql @@ -4,5 +4,5 @@ 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; + alter column pending drop default; -- 2.44.1