fix!: actually no i can join users and filter there

This commit is contained in:
əlemi 2024-05-29 04:42:26 +02:00
parent 2ca4bfedc4
commit e6a687d427
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 1 additions and 36 deletions

View file

@ -46,7 +46,6 @@ pub enum Objects {
Table, Table,
Internal, Internal,
Id, Id,
Domain,
ObjectType, ObjectType,
AttributedTo, AttributedTo,
Name, Name,
@ -201,14 +200,6 @@ impl MigrationTrait for Migration {
.auto_increment() .auto_increment()
) )
.col(ColumnDef::new(Objects::Id).string().not_null().unique_key()) .col(ColumnDef::new(Objects::Id).string().not_null().unique_key())
.col(ColumnDef::new(Objects::Domain).string().not_null())
.foreign_key(
ForeignKey::create()
.name("fkey-objects-instances")
.from(Objects::Table, Objects::Domain)
.to(Instances::Table, Instances::Domain)
.on_update(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Objects::ObjectType).string().not_null()) .col(ColumnDef::new(Objects::ObjectType).string().not_null())
.col(ColumnDef::new(Objects::AttributedTo).string().null()) .col(ColumnDef::new(Objects::AttributedTo).string().null())
// .foreign_key( // .foreign_key(

View file

@ -27,8 +27,6 @@ pub enum Relation {
Actors, Actors,
#[sea_orm(has_many = "super::addressing::Entity")] #[sea_orm(has_many = "super::addressing::Entity")]
Addressing, Addressing,
#[sea_orm(has_many = "super::object::Entity")]
Objects,
} }
impl Related<super::actor::Entity> for Entity { impl Related<super::actor::Entity> for Entity {
@ -43,12 +41,6 @@ impl Related<super::addressing::Entity> for Entity {
} }
} }
impl Related<super::object::Entity> for Entity {
fn to() -> RelationDef {
Relation::Objects.def()
}
}
impl ActiveModelBehavior for ActiveModel {} impl ActiveModelBehavior for ActiveModel {}
impl Entity { impl Entity {

View file

@ -12,7 +12,6 @@ pub struct Model {
pub internal: i64, pub internal: i64,
#[sea_orm(unique)] #[sea_orm(unique)]
pub id: String, pub id: String,
pub domain: String,
pub object_type: ObjectType, pub object_type: ObjectType,
pub attributed_to: Option<String>, pub attributed_to: Option<String>,
pub name: Option<String>, pub name: Option<String>,
@ -53,14 +52,6 @@ pub enum Relation {
Attachments, Attachments,
#[sea_orm(has_many = "super::hashtag::Entity")] #[sea_orm(has_many = "super::hashtag::Entity")]
Hashtags, Hashtags,
#[sea_orm(
belongs_to = "super::instance::Entity",
from = "Column::Domain",
to = "super::instance::Column::Domain",
on_update = "Cascade",
on_delete = "NoAction"
)]
Instances,
#[sea_orm(has_many = "super::like::Entity")] #[sea_orm(has_many = "super::like::Entity")]
Likes, Likes,
#[sea_orm(has_many = "super::mention::Entity")] #[sea_orm(has_many = "super::mention::Entity")]
@ -111,12 +102,6 @@ impl Related<super::hashtag::Entity> for Entity {
} }
} }
impl Related<super::instance::Entity> for Entity {
fn to() -> RelationDef {
Relation::Instances.def()
}
}
impl Related<super::like::Entity> for Entity { impl Related<super::like::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::Likes.def() Relation::Likes.def()
@ -160,12 +145,9 @@ impl Entity {
impl ActiveModel { impl ActiveModel {
pub fn new(object: &impl apb::Object) -> Result<Self, super::FieldError> { pub fn new(object: &impl apb::Object) -> Result<Self, super::FieldError> {
let ap_id = object.id().ok_or(super::FieldError("id"))?.to_string();
let domain = crate::server::Context::server(&ap_id);
Ok(ActiveModel { Ok(ActiveModel {
internal: sea_orm::ActiveValue::NotSet, internal: sea_orm::ActiveValue::NotSet,
domain: sea_orm::ActiveValue::Set(domain), id: sea_orm::ActiveValue::Set(object.id().ok_or(super::FieldError("id"))?.to_string()),
id: sea_orm::ActiveValue::Set(ap_id),
object_type: sea_orm::ActiveValue::Set(object.object_type().ok_or(super::FieldError("type"))?), object_type: sea_orm::ActiveValue::Set(object.object_type().ok_or(super::FieldError("type"))?),
attributed_to: sea_orm::ActiveValue::Set(object.attributed_to().id()), attributed_to: sea_orm::ActiveValue::Set(object.attributed_to().id()),
name: sea_orm::ActiveValue::Set(object.name().map(|x| x.to_string())), name: sea_orm::ActiveValue::Set(object.name().map(|x| x.to_string())),