diff --git a/upub/core/src/model/attachment.rs b/upub/core/src/model/attachment.rs index cabea9cc..97851f5b 100644 --- a/upub/core/src/model/attachment.rs +++ b/upub/core/src/model/attachment.rs @@ -12,7 +12,6 @@ pub struct Model { pub document_type: DocumentType, pub name: Option, pub media_type: String, - pub published: ChronoDateTimeUtc, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -42,6 +41,5 @@ impl Model { .set_document_type(Some(self.document_type)) .set_media_type(Some(&self.media_type)) .set_name(self.name.as_deref()) - .set_published(Some(self.published)) } } diff --git a/upub/core/src/model/hashtag.rs b/upub/core/src/model/hashtag.rs index bcd603ba..5318579f 100644 --- a/upub/core/src/model/hashtag.rs +++ b/upub/core/src/model/hashtag.rs @@ -7,7 +7,6 @@ pub struct Model { pub internal: i64, pub object: i64, pub name: String, - pub published: ChronoDateTimeUtc, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/upub/core/src/model/mention.rs b/upub/core/src/model/mention.rs index f08cb043..b2a3a9c6 100644 --- a/upub/core/src/model/mention.rs +++ b/upub/core/src/model/mention.rs @@ -7,7 +7,6 @@ pub struct Model { pub internal: i64, pub object: i64, pub actor: String, - pub published: ChronoDateTimeUtc, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/upub/core/src/traits/normalize.rs b/upub/core/src/traits/normalize.rs index 929c581d..0f01dce5 100644 --- a/upub/core/src/traits/normalize.rs +++ b/upub/core/src/traits/normalize.rs @@ -25,7 +25,6 @@ pub trait Normalizer { impl Normalizer for crate::Context { async fn insert_object(&self, object: impl apb::Object, tx: &impl ConnectionTrait) -> Result { - let now = chrono::Utc::now(); let mut object_model = AP::object(&object)?; // make sure content only contains a safe subset of html @@ -87,7 +86,6 @@ impl Normalizer for crate::Context { document_type: Set(apb::DocumentType::Page), name: Set(l.name().str()), media_type: Set(l.media_type().unwrap_or("link").to_string()), - published: Set(now), }, Node::Object(o) => AP::attachment_q(o.as_document()?, object_model.internal, None)?, @@ -133,7 +131,6 @@ impl Normalizer for crate::Context { internal: NotSet, object: Set(object_model.internal), actor: Set(l.href().to_string()), - published: Set(now), }; crate::model::mention::Entity::insert(model) .exec(tx) @@ -147,7 +144,6 @@ impl Normalizer for crate::Context { internal: NotSet, object: Set(object_model.internal), name: Set(hashtag), - published: Set(now), }; crate::model::hashtag::Entity::insert(model) .exec(tx) @@ -273,7 +269,6 @@ impl AP { document_type: document.as_document().map_or(apb::DocumentType::Document, |x| x.document_type().unwrap_or(apb::DocumentType::Page)), name: document.name().str(), media_type: document.media_type().unwrap_or("link").to_string(), - published: document.published().unwrap_or_else(|_| chrono::Utc::now()), }) } diff --git a/upub/migrations/src/m20240524_000005_create_attachments_tags_mentions.rs b/upub/migrations/src/m20240524_000005_create_attachments_tags_mentions.rs index e3c6eee7..934efca0 100644 --- a/upub/migrations/src/m20240524_000005_create_attachments_tags_mentions.rs +++ b/upub/migrations/src/m20240524_000005_create_attachments_tags_mentions.rs @@ -11,7 +11,6 @@ pub enum Attachments { Object, Name, MediaType, - Published, } #[derive(DeriveIden)] @@ -20,7 +19,6 @@ pub enum Mentions { Internal, Object, Actor, - Published, } #[derive(DeriveIden)] @@ -29,7 +27,6 @@ pub enum Hashtags { Internal, Object, Name, - Published, } #[derive(DeriveMigrationName)] @@ -63,7 +60,6 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(Attachments::DocumentType).string().not_null()) .col(ColumnDef::new(Attachments::Name).string().null()) .col(ColumnDef::new(Attachments::MediaType).string().not_null()) - .col(ColumnDef::new(Attachments::Published).timestamp_with_time_zone().not_null().default(Expr::current_timestamp())) .to_owned() ) .await?; @@ -116,14 +112,7 @@ impl MigrationTrait for Migration { .await?; manager - .create_index( - Index::create() - .name("index-mentions-actor-published") - .table(Mentions::Table) - .col(Mentions::Actor) - .col((Mentions::Published, IndexOrder::Desc)) - .to_owned() - ) + .create_index(Index::create().name("index-mentions-actor").table(Mentions::Table).col(Mentions::Actor).to_owned()) .await?; manager @@ -148,7 +137,6 @@ impl MigrationTrait for Migration { .on_delete(ForeignKeyAction::Cascade) ) .col(ColumnDef::new(Hashtags::Name).string().not_null()) - .col(ColumnDef::new(Hashtags::Published).timestamp_with_time_zone().not_null().default(Expr::current_timestamp())) .to_owned() ) .await?; @@ -158,14 +146,7 @@ impl MigrationTrait for Migration { .await?; manager - .create_index( - Index::create() - .name("index-hashtags-name-published") - .table(Hashtags::Table) - .col(Hashtags::Name) - .col((Hashtags::Published, IndexOrder::Desc)) - .to_owned() - ) + .create_index(Index::create().name("index-hashtags-name").table(Hashtags::Table).col(Hashtags::Name).to_owned()) .await?; Ok(())