feat: process quote_url

This commit is contained in:
əlemi 2024-07-15 01:32:15 +02:00
parent 83b3db8e75
commit 902aabe36b
Signed by: alemi
GPG key ID: A4895B84D311642C
6 changed files with 53 additions and 3 deletions

View file

@ -78,6 +78,7 @@ pub async fn faker(ctx: upub::Context, count: i64) -> Result<(), sea_orm::DbErr>
summary: Set(None),
context: Set(Some(context.clone())),
in_reply_to: Set(None),
quote: Set(None),
content: Set(Some(format!("[{i}] Tic(k). Quasiparticle of intensive multiplicity. Tics (or ticks) are intrinsically several components of autonomously numbering anorganic populations, propagating by contagion between segmentary divisions in the order of nature. Ticks - as nonqualitative differentially-decomposable counting marks - each designate a multitude comprehended as a singular variation in tic(k)-density."))),
image: Set(None),
published: Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i as u64)),

View file

@ -16,6 +16,7 @@ pub struct Model {
pub summary: Option<String>,
pub content: Option<String>,
pub image: Option<String>,
pub quote: Option<String>,
pub sensitive: bool,
pub in_reply_to: Option<String>,
pub url: Option<String>,
@ -63,10 +64,18 @@ pub enum Relation {
belongs_to = "Entity",
from = "Column::InReplyTo",
to = "Column::Id",
on_update = "Cascade",
on_update = "NoAction",
on_delete = "NoAction"
)]
Objects,
ObjectsReply,
#[sea_orm(
belongs_to = "Entity",
from = "Column::Quote",
to = "Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
ObjectsQuote,
}
impl Related<super::activity::Entity> for Entity {
@ -125,7 +134,7 @@ impl Related<super::mention::Entity> for Entity {
impl Related<Entity> for Entity {
fn to() -> RelationDef {
Relation::Objects.def()
Relation::ObjectsReply.def()
}
}
@ -168,6 +177,7 @@ impl Model {
.set_context(apb::Node::maybe_link(self.context.clone()))
.set_conversation(apb::Node::maybe_link(self.context.clone())) // duplicate context for mastodon
.set_in_reply_to(apb::Node::maybe_link(self.in_reply_to.clone()))
.set_quote_url(apb::Node::maybe_link(self.quote.clone()))
.set_published(Some(self.published))
.set_updated(if self.updated != self.published { Some(self.updated) } else { None })
.set_audience(apb::Node::maybe_link(self.audience))

View file

@ -276,6 +276,7 @@ impl AP {
image: object.image().get().and_then(|x| x.url().id().str()),
context: object.context().id().str(),
in_reply_to: object.in_reply_to().id().str(),
quote: object.quote_url().id().str(),
published: object.published().unwrap_or_else(|_| chrono::Utc::now()),
updated: object.updated().unwrap_or_else(|_| chrono::Utc::now()),
url: object.url().id().str(),

View file

@ -17,6 +17,7 @@ mod m20240628_000002_add_credentials_activated;
mod m20240703_000001_add_audience_index;
mod m20240703_000002_add_image_to_objects;
mod m20240706_000001_add_error_to_jobs;
mod m20240715_000001_add_quote_uri_to_objects;
pub struct Migrator;
@ -41,6 +42,7 @@ impl MigratorTrait for Migrator {
Box::new(m20240703_000001_add_audience_index::Migration),
Box::new(m20240703_000002_add_image_to_objects::Migration),
Box::new(m20240706_000001_add_error_to_jobs::Migration),
Box::new(m20240715_000001_add_quote_uri_to_objects::Migration),
]
}
}

View file

@ -60,6 +60,7 @@ pub enum Objects {
Replies,
Context,
InReplyTo,
Quote, // added with migration m20240715_000001
Cc,
Bcc,
To,

View file

@ -0,0 +1,35 @@
use sea_orm_migration::prelude::*;
use crate::m20240524_000001_create_actor_activity_object_tables::Objects;
#[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(Objects::Table)
.add_column(ColumnDef::new(Objects::Quote).string().null())
.to_owned()
)
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Objects::Table)
.drop_column(Objects::Quote)
.to_owned()
)
.await?;
Ok(())
}
}