diff --git a/upub/cli/src/faker.rs b/upub/cli/src/faker.rs index ce4bd69..6e97ad2 100644 --- a/upub/cli/src/faker.rs +++ b/upub/cli/src/faker.rs @@ -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 { diff --git a/upub/core/src/model/config.rs b/upub/core/src/model/config.rs index 5335dec..c43d5e2 100644 --- a/upub/core/src/model/config.rs +++ b/upub/core/src/model/config.rs @@ -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)] diff --git a/upub/core/src/traits/admin.rs b/upub/core/src/traits/admin.rs index 3f52eb0..c669e83 100644 --- a/upub/core/src/traits/admin.rs +++ b/upub/core/src/traits/admin.rs @@ -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) diff --git a/upub/migrations/src/lib.rs b/upub/migrations/src/lib.rs index aa1cc06..254b390 100644 --- a/upub/migrations/src/lib.rs +++ b/upub/migrations/src/lib.rs @@ -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), ] } } diff --git a/upub/migrations/src/m20240524_000003_create_users_auth_and_config.rs b/upub/migrations/src/m20240524_000003_create_users_auth_and_config.rs index 96e328b..e746426 100644 --- a/upub/migrations/src/m20240524_000003_create_users_auth_and_config.rs +++ b/upub/migrations/src/m20240524_000003_create_users_auth_and_config.rs @@ -12,6 +12,7 @@ pub enum Configs { ShowFollowingCount, ShowFollowers, ShowFollowing, + ShowLikedObjects, // added with migration m20241226_000001 } #[derive(DeriveIden)] diff --git a/upub/migrations/src/m20241226_000001_add_show_likes_collection.rs b/upub/migrations/src/m20241226_000001_add_show_likes_collection.rs new file mode 100644 index 0000000..0a3e62d --- /dev/null +++ b/upub/migrations/src/m20241226_000001_add_show_likes_collection.rs @@ -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(()) + } +}