feat: add db option to show likes collection
This commit is contained in:
parent
9f8b6b8280
commit
5e7592c0aa
6 changed files with 43 additions and 15 deletions
|
@ -43,10 +43,11 @@ pub async fn faker(ctx: upub::Context, count: i64) -> Result<(), sea_orm::DbErr>
|
|||
internal: NotSet,
|
||||
actor: Set(test_user.id.clone()),
|
||||
accept_follow_requests: Set(true),
|
||||
show_followers: Set(true),
|
||||
show_following: Set(true),
|
||||
show_following_count: Set(true),
|
||||
show_followers_count: Set(true),
|
||||
show_followers: Set(false),
|
||||
show_following: Set(false),
|
||||
show_liked_objects: Set(false),
|
||||
}).exec(db).await?;
|
||||
|
||||
credential::Entity::insert(credential::ActiveModel {
|
||||
|
|
|
@ -12,19 +12,7 @@ pub struct Model {
|
|||
pub show_following_count: bool,
|
||||
pub show_followers: bool,
|
||||
pub show_following: bool,
|
||||
}
|
||||
|
||||
impl Default for Model {
|
||||
fn default() -> Self {
|
||||
Model {
|
||||
internal: 0, actor: "".into(),
|
||||
accept_follow_requests: true,
|
||||
show_following_count: true,
|
||||
show_following: true,
|
||||
show_followers_count: true,
|
||||
show_followers: true,
|
||||
}
|
||||
}
|
||||
pub show_liked_objects: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
@ -68,6 +68,7 @@ impl Administrable for crate::Context {
|
|||
show_following_count: Set(true),
|
||||
show_followers: Set(false),
|
||||
show_following: Set(false),
|
||||
show_liked_objects: Set(false),
|
||||
};
|
||||
|
||||
crate::model::config::Entity::insert(config_model)
|
||||
|
|
|
@ -20,6 +20,7 @@ mod m20240706_000001_add_error_to_jobs;
|
|||
mod m20240715_000001_add_quote_uri_to_objects;
|
||||
mod m20240715_000002_add_actors_fields_and_aliases;
|
||||
mod m20240811_000001_add_full_text_index;
|
||||
mod m20241226_000001_add_show_likes_collection;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
@ -47,6 +48,7 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20240715_000001_add_quote_uri_to_objects::Migration),
|
||||
Box::new(m20240715_000002_add_actors_fields_and_aliases::Migration),
|
||||
Box::new(m20240811_000001_add_full_text_index::Migration),
|
||||
Box::new(m20241226_000001_add_show_likes_collection::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ pub enum Configs {
|
|||
ShowFollowingCount,
|
||||
ShowFollowers,
|
||||
ShowFollowing,
|
||||
ShowLikedObjects, // added with migration m20241226_000001
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
|
||||
use crate::m20240524_000003_create_users_auth_and_config::Configs;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Configs::Table)
|
||||
.add_column(ColumnDef::new(Configs::ShowLikedObjects).boolean().not_null().default(false))
|
||||
.to_owned()
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Configs::Table)
|
||||
.drop_column(Configs::ShowLikedObjects)
|
||||
.to_owned()
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue