fediverse_resource_share.rs
45 lignes · 1849 octets
//! SeaORM entity for `fediverse_resource_shares` (RFC 0029). //! //! Records the grant of a permission level (`"read" | "write" | "admin"`) //! on a generic application resource (identified by the //! `(resource_type, resource_id)` pair in the core `resources` registry) //! to a remote ActivityPub identity. Companion of the core //! [`resource_share`](rustwarden_core::models::resource_share) but scoped //! to `remote_identities` instead of users / teams. //! //! Schema: see migration //! `m20260516_000002_remote_resource_shares`. A unique partial index on //! `(resource_id, remote_identity_id)` guarantees that the service //! [`crate::services::remote_resource_share_service::RemoteResourceShareService::share`] //! performs an upsert per pair. use chrono::{DateTime, Utc}; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use uuid::Uuid; /// Persistent record of one resource share with a remote identity. #[derive(Clone, Debug, Serialize, Deserialize, DeriveEntityModel)] #[sea_orm(table_name = "fediverse_resource_shares")] pub struct Model { /// Stable PK. #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, /// FK to `resources.id` (core resource registry). pub resource_id: Uuid, /// FK to `remote_identities.id` (grantee). pub remote_identity_id: Uuid, /// Permission level — `"read"`, `"write"` or `"admin"`. pub permission_level: String, /// FK to `users.id` of the local user who issued the share. pub shared_by_user_id: Uuid, /// Insertion timestamp. pub created_at: DateTime<Utc>, } /// SeaORM relations (none modelled here — cross-crate FKs are enforced /// by the migration but not surfaced as SeaORM relations). #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation {} impl ActiveModelBehavior for ActiveModel {}
GitRust