Making community_follower.pending column not null.

pull/2248/head
Dessalines 2 years ago committed by Nutomic
parent 763dc9668c
commit d4ee171b08

@ -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",

@ -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"

@ -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)

@ -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)

@ -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 {

@ -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);

@ -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);

@ -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)

@ -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.

@ -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.

@ -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();

@ -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,
};

@ -119,7 +119,7 @@ table! {
community_id -> Int4,
person_id -> Int4,
published -> Timestamp,
pending -> Nullable<Bool>,
pending -> Bool,
}
}

@ -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>,
}

@ -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> {

@ -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)]

@ -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;

@ -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;
Loading…
Cancel
Save