remote_identity.rs 60 lignes · 2356 octets
//! Remote ActivityPub identity SeaORM entity (RFC 0003).
//!
//! Local cache of remote actors resolved via WebFinger + actor fetch.
//! Created and maintained by
//! [`crate::services::remote_identity_service::RemoteIdentityService`].
//!

use chrono::{DateTime, Utc};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// `remote_identities` row.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, DeriveEntityModel)]
#[sea_orm(table_name = "remote_identities")]
pub struct Model {
    /// Stable internal identifier.
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    /// Canonical ActivityPub identifier of the actor (e.g.
    /// `https://other.tld/users/alice`). Unique.
    #[sea_orm(unique)]
    pub ap_id: String,
    /// Local part of the handle (`alice` in `@alice@other.tld`).
    pub username: String,
    /// Remote domain (`other.tld`).
    pub domain: String,
    /// Optional display name advertised by the actor.
    pub display_name: Option<String>,
    /// Optional bio in HTML.
    pub summary_html: Option<String>,
    /// Inbox URL where activities targeting this actor must be POSTed.
    pub inbox_url: String,
    /// Optional shared inbox (instance-wide fan-out optimisation).
    pub shared_inbox_url: Option<String>,
    /// PEM-encoded RSA public key used for HTTP signature verification.
    pub public_key_pem: String,
    /// Optional avatar URL.
    pub icon_url: Option<String>,
    /// `Person`, `Group`, `Service`, `Application`, `Organization`.
    pub actor_type: String,
    /// Raw JSON document fetched from the remote actor URL (kept for
    /// future re-processing if the protocol evolves).
    pub raw_json: Option<serde_json::Value>,
    /// Timestamp of the last successful fetch — used by the cache TTL check.
    pub last_fetched_at: DateTime<Utc>,
    /// Set when the remote IdP signals account deletion (`Delete{Actor}`).
    pub disabled_at: Option<DateTime<Utc>>,
    /// Row creation timestamp.
    pub created_at: DateTime<Utc>,
    /// Last row mutation timestamp.
    pub updated_at: DateTime<Utc>,
}

/// SeaORM relations for `remote_identities` (none yet — joined references
/// arrive with RFC 0008).
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}