Add "manually_approves_followers" column to actor_profile table

This commit is contained in:
silverpill 2023-03-16 22:04:36 +00:00
parent 0b65e7473e
commit c80bfccd6a
7 changed files with 34 additions and 9 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE actor_profile ADD COLUMN manually_approves_followers BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE actor_profile ALTER COLUMN manually_approves_followers DROP DEFAULT;

View file

@ -26,6 +26,7 @@ CREATE TABLE actor_profile (
bio_source TEXT,
avatar JSONB,
banner JSONB,
manually_approves_followers BOOLEAN NOT NULL,
identity_proofs JSONB NOT NULL DEFAULT '[]',
payment_options JSONB NOT NULL DEFAULT '[]',
extra_fields JSONB NOT NULL DEFAULT '[]',

View file

@ -149,6 +149,7 @@ pub async fn create_remote_profile(
bio: actor.summary.clone(),
avatar: maybe_avatar,
banner: maybe_banner,
manually_approves_followers: actor.manually_approves_followers,
identity_proofs,
payment_options,
extra_fields,
@ -204,6 +205,7 @@ pub async fn update_remote_profile(
bio_source: actor.summary.clone(),
avatar: maybe_avatar,
banner: maybe_banner,
manually_approves_followers: actor.manually_approves_followers,
identity_proofs,
payment_options,
extra_fields,

View file

@ -132,6 +132,7 @@ impl Account {
.map(|image| get_file_url(base_url, &image.file_name));
let header_url = profile.banner
.map(|image| get_file_url(base_url, &image.file_name));
// TODO: use profile.manually_approves_followers
let is_locked = profile.actor_json
.map(|actor| actor.manually_approves_followers)
.unwrap_or(false);
@ -367,6 +368,7 @@ impl AccountUpdateData {
bio_source: self.note,
avatar,
banner,
manually_approves_followers: false,
identity_proofs,
payment_options,
extra_fields,

View file

@ -133,12 +133,21 @@ pub async fn create_profile(
transaction.execute(
"
INSERT INTO actor_profile (
id, username, hostname, display_name, bio, bio_source,
avatar, banner,
identity_proofs, payment_options, extra_fields,
id,
username,
hostname,
display_name,
bio,
bio_source,
avatar,
banner,
manually_approves_followers,
identity_proofs,
payment_options,
extra_fields,
actor_json
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
RETURNING actor_profile
",
&[
@ -150,6 +159,7 @@ pub async fn create_profile(
&profile_data.bio,
&profile_data.avatar,
&profile_data.banner,
&profile_data.manually_approves_followers,
&IdentityProofs(profile_data.identity_proofs),
&PaymentOptions(profile_data.payment_options),
&ExtraFields(profile_data.extra_fields),
@ -184,12 +194,13 @@ pub async fn update_profile(
bio_source = $3,
avatar = $4,
banner = $5,
identity_proofs = $6,
payment_options = $7,
extra_fields = $8,
actor_json = $9,
manually_approves_followers = $6,
identity_proofs = $7,
payment_options = $8,
extra_fields = $9,
actor_json = $10,
updated_at = CURRENT_TIMESTAMP
WHERE id = $10
WHERE id = $11
RETURNING actor_profile
",
&[
@ -198,6 +209,7 @@ pub async fn update_profile(
&profile_data.bio_source,
&profile_data.avatar,
&profile_data.banner,
&profile_data.manually_approves_followers,
&IdentityProofs(profile_data.identity_proofs),
&PaymentOptions(profile_data.payment_options),
&ExtraFields(profile_data.extra_fields),

View file

@ -333,6 +333,7 @@ pub struct DbActorProfile {
pub bio_source: Option<String>, // plaintext or markdown
pub avatar: Option<ProfileImage>,
pub banner: Option<ProfileImage>,
pub manually_approves_followers: bool,
pub identity_proofs: IdentityProofs,
pub payment_options: PaymentOptions,
pub extra_fields: ExtraFields,
@ -421,6 +422,7 @@ impl Default for DbActorProfile {
bio_source: None,
avatar: None,
banner: None,
manually_approves_followers: false,
identity_proofs: IdentityProofs(vec![]),
payment_options: PaymentOptions(vec![]),
extra_fields: ExtraFields(vec![]),
@ -446,6 +448,7 @@ pub struct ProfileCreateData {
pub bio: Option<String>,
pub avatar: Option<ProfileImage>,
pub banner: Option<ProfileImage>,
pub manually_approves_followers: bool,
pub identity_proofs: Vec<IdentityProof>,
pub payment_options: Vec<PaymentOption>,
pub extra_fields: Vec<ExtraField>,
@ -478,6 +481,7 @@ pub struct ProfileUpdateData {
pub bio_source: Option<String>,
pub avatar: Option<ProfileImage>,
pub banner: Option<ProfileImage>,
pub manually_approves_followers: bool,
pub identity_proofs: Vec<IdentityProof>,
pub payment_options: Vec<PaymentOption>,
pub extra_fields: Vec<ExtraField>,
@ -526,6 +530,7 @@ impl From<&DbActorProfile> for ProfileUpdateData {
bio_source: profile.bio_source,
avatar: profile.avatar,
banner: profile.banner,
manually_approves_followers: profile.manually_approves_followers,
identity_proofs: profile.identity_proofs.into_inner(),
payment_options: profile.payment_options.into_inner(),
extra_fields: profile.extra_fields.into_inner(),

View file

@ -114,6 +114,7 @@ pub async fn create_user(
bio: None,
avatar: None,
banner: None,
manually_approves_followers: false,
identity_proofs: vec![],
payment_options: vec![],
extra_fields: vec![],