From 2ca4bfedc423770815674ab1f68cb374fc3af1f2 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 29 May 2024 04:33:19 +0200 Subject: [PATCH] fix!: eh make it a string it breaks object.ap() which is used a lot deep, i dont want to have to deal with that now tbh --- ...0524_000001_create_actor_activity_object_tables.rs | 8 ++++---- src/model/object.rs | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs b/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs index afb659cb..318aa2bf 100644 --- a/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs +++ b/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs @@ -46,7 +46,7 @@ pub enum Objects { Table, Internal, Id, - Instance, + Domain, ObjectType, AttributedTo, Name, @@ -201,12 +201,12 @@ impl MigrationTrait for Migration { .auto_increment() ) .col(ColumnDef::new(Objects::Id).string().not_null().unique_key()) - .col(ColumnDef::new(Objects::Instance).big_integer().not_null()) + .col(ColumnDef::new(Objects::Domain).string().not_null()) .foreign_key( ForeignKey::create() .name("fkey-objects-instances") - .from(Objects::Table, Objects::Instance) - .to(Instances::Table, Instances::Internal) + .from(Objects::Table, Objects::Domain) + .to(Instances::Table, Instances::Domain) .on_update(ForeignKeyAction::Cascade) ) .col(ColumnDef::new(Objects::ObjectType).string().not_null()) diff --git a/src/model/object.rs b/src/model/object.rs index c2f85e26..94389564 100644 --- a/src/model/object.rs +++ b/src/model/object.rs @@ -12,7 +12,7 @@ pub struct Model { pub internal: i64, #[sea_orm(unique)] pub id: String, - pub instance: i64, + pub domain: String, pub object_type: ObjectType, pub attributed_to: Option, pub name: Option, @@ -55,8 +55,8 @@ pub enum Relation { Hashtags, #[sea_orm( belongs_to = "super::instance::Entity", - from = "Column::Instance", - to = "super::instance::Column::Internal", + from = "Column::Domain", + to = "super::instance::Column::Domain", on_update = "Cascade", on_delete = "NoAction" )] @@ -160,9 +160,12 @@ impl Entity { impl ActiveModel { pub fn new(object: &impl apb::Object) -> Result { + let ap_id = object.id().ok_or(super::FieldError("id"))?.to_string(); + let domain = crate::server::Context::server(&ap_id); Ok(ActiveModel { internal: sea_orm::ActiveValue::NotSet, - id: sea_orm::ActiveValue::Set(object.id().ok_or(super::FieldError("id"))?.to_string()), + domain: sea_orm::ActiveValue::Set(domain), + id: sea_orm::ActiveValue::Set(ap_id), object_type: sea_orm::ActiveValue::Set(object.object_type().ok_or(super::FieldError("type"))?), attributed_to: sea_orm::ActiveValue::Set(object.attributed_to().id()), name: sea_orm::ActiveValue::Set(object.name().map(|x| x.to_string())),