diff --git a/upub/core/src/model/activity.rs b/upub/core/src/model/activity.rs index 13091e0..85b6392 100644 --- a/upub/core/src/model/activity.rs +++ b/upub/core/src/model/activity.rs @@ -14,6 +14,7 @@ pub struct Model { pub actor: String, pub object: Option, pub target: Option, + pub content: Option, pub to: JsonVec, pub bto: JsonVec, pub cc: JsonVec, @@ -111,6 +112,7 @@ impl crate::ext::IntoActivityPub for Model { .set_actor(apb::Node::link(self.actor)) .set_object(apb::Node::maybe_link(self.object)) .set_target(apb::Node::maybe_link(self.target)) + .set_content(self.content) .set_published(Some(self.published)) .set_to(apb::Node::links(self.to.0.clone())) .set_bto(apb::Node::Empty) diff --git a/upub/core/src/traits/normalize.rs b/upub/core/src/traits/normalize.rs index c706ff7..9cebcf5 100644 --- a/upub/core/src/traits/normalize.rs +++ b/upub/core/src/traits/normalize.rs @@ -245,6 +245,7 @@ impl AP { actor: activity.actor().id()?.to_string(), object: activity.object().id().ok(), target: activity.target().id().ok(), + content: activity.content().ok(), published: activity.published().unwrap_or(chrono::Utc::now()), to: activity.to().all_ids().into(), bto: activity.bto().all_ids().into(), diff --git a/upub/migrations/src/lib.rs b/upub/migrations/src/lib.rs index 17a6488..8b284f8 100644 --- a/upub/migrations/src/lib.rs +++ b/upub/migrations/src/lib.rs @@ -23,6 +23,7 @@ mod m20240811_000001_add_full_text_index; mod m20241226_000001_add_show_likes_collection; mod m20241226_000002_add_like_activities; mod m20241226_000003_create_downtime_table; +mod m20250115_000001_add_content_to_activities; pub struct Migrator; @@ -53,6 +54,7 @@ impl MigratorTrait for Migrator { Box::new(m20241226_000001_add_show_likes_collection::Migration), Box::new(m20241226_000002_add_like_activities::Migration), Box::new(m20241226_000003_create_downtime_table::Migration), + Box::new(m20250115_000001_add_content_to_activities::Migration), ] } } diff --git a/upub/migrations/src/m20240524_000001_create_actor_activity_object_tables.rs b/upub/migrations/src/m20240524_000001_create_actor_activity_object_tables.rs index e414ef9..5f39348 100644 --- a/upub/migrations/src/m20240524_000001_create_actor_activity_object_tables.rs +++ b/upub/migrations/src/m20240524_000001_create_actor_activity_object_tables.rs @@ -38,6 +38,7 @@ pub enum Activities { Actor, Object, Target, + Content, // added with migration m20250115_000001 Cc, Bcc, To, diff --git a/upub/migrations/src/m20250115_000001_add_content_to_activities.rs b/upub/migrations/src/m20250115_000001_add_content_to_activities.rs new file mode 100644 index 0000000..c06c7bb --- /dev/null +++ b/upub/migrations/src/m20250115_000001_add_content_to_activities.rs @@ -0,0 +1,38 @@ +use sea_orm_migration::prelude::*; + +use crate::m20240524_000001_create_actor_activity_object_tables::Activities; + +#[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(Activities::Table) + .add_column(ColumnDef::new(Activities::Content).string().null()) + .to_owned() + ) + .await?; + + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + + manager + .alter_table( + Table::alter() + .table(Activities::Table) + .drop_column(Activities::Content) + .to_owned() + ) + .await?; + + Ok(()) + } +} +