fediverse_outbound_queue.rs 51 lignes · 1949 octets
//! SeaORM entity for the `fediverse_outbound_queue` table (RFC 0011).
//!
//! Persistent journal of ActivityPub activities that must be delivered
//! to remote inboxes by [`crate::services::fediverse_outbound_service::OutboundWorker`].

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

/// Persistent record of one outbound delivery (one-to-one with the
/// `fediverse_outbound_queue` row).
#[derive(Clone, Debug, Serialize, Deserialize, DeriveEntityModel)]
#[sea_orm(table_name = "fediverse_outbound_queue")]
pub struct Model {
    /// Stable PK.
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    /// Canonical AP `id` of the activity being delivered.
    pub activity_id: String,
    /// Pre-rendered JSON-LD body posted to `target_inbox`.
    pub payload_json: String,
    /// Remote inbox URL.
    pub target_inbox: String,
    /// Domain the inbox belongs to (used for trust checks).
    pub target_domain: String,
    /// `pending`, `delivered`, `failed`, or `dead`.
    pub status: String,
    /// Number of delivery attempts already performed.
    pub attempts: i32,
    /// Maximum attempts before the row is moved to `dead`.
    pub max_attempts: i32,
    /// Last delivery error (truncated).
    pub last_error: Option<String>,
    /// Earliest moment the row is eligible for re-delivery.
    pub next_retry_at: Option<DateTime<Utc>>,
    /// Insertion timestamp.
    pub created_at: DateTime<Utc>,
    /// Successful delivery timestamp.
    pub delivered_at: Option<DateTime<Utc>>,
    /// Local user the activity is sent on behalf of (used for HTTP-Sig
    /// signing in RFC 0010; nullable while only `NoopDelivery` is
    /// shipped).
    pub actor_user_id: Option<Uuid>,
}

/// SeaORM relations (none for this table).
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}