feat: add content to activities

this way we can show emojis in like feeds
This commit is contained in:
əlemi 2025-01-15 02:27:03 +01:00
parent deedd23aa9
commit d1c43375cf
Signed by: alemi
GPG key ID: A4895B84D311642C
5 changed files with 44 additions and 0 deletions

View file

@ -14,6 +14,7 @@ pub struct Model {
pub actor: String,
pub object: Option<String>,
pub target: Option<String>,
pub content: Option<String>,
pub to: JsonVec<String>,
pub bto: JsonVec<String>,
pub cc: JsonVec<String>,
@ -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)

View file

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

View file

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

View file

@ -38,6 +38,7 @@ pub enum Activities {
Actor,
Object,
Target,
Content, // added with migration m20250115_000001
Cc,
Bcc,
To,

View file

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