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,
Internal,
Id,
Domain,
ObjectType,
AttributedTo,
Name,
@ -201,14 +200,6 @@ impl MigrationTrait for Migration {
.auto_increment()
)
.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::AttributedTo).string().null())
// .foreign_key(

View file

@ -27,8 +27,6 @@ pub enum Relation {
Actors,
#[sea_orm(has_many = "super::addressing::Entity")]
Addressing,
#[sea_orm(has_many = "super::object::Entity")]
Objects,
}
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 Entity {

View file

@ -12,7 +12,6 @@ pub struct Model {
pub internal: i64,
#[sea_orm(unique)]
pub id: String,
pub domain: String,
pub object_type: ObjectType,
pub attributed_to: Option<String>,
pub name: Option<String>,
@ -53,14 +52,6 @@ pub enum Relation {
Attachments,
#[sea_orm(has_many = "super::hashtag::Entity")]
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")]
Likes,
#[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 {
fn to() -> RelationDef {
Relation::Likes.def()
@ -160,12 +145,9 @@ impl Entity {
impl ActiveModel {
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 {
internal: sea_orm::ActiveValue::NotSet,
domain: sea_orm::ActiveValue::Set(domain),
id: sea_orm::ActiveValue::Set(ap_id),
id: sea_orm::ActiveValue::Set(object.id().ok_or(super::FieldError("id"))?.to_string()),
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())),