//! Entity representing a follower relationship.
//!
//! Tracks which remote actors follow which local actors. The follow_activity_id
//! is the ActivityPub Follow activity's id, used for matching Undo(Follow).

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "ap_followers")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    pub local_actor_id: i64,
    pub remote_actor_id: i64,
    pub follow_activity_id: String,
    pub created_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::ap_remote_actors::Entity",
        from = "Column::RemoteActorId",
        to = "super::ap_remote_actors::Column::Id"
    )]
    ApRemoteActors,
}

impl Related<super::ap_remote_actors::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::ApRemoteActors.def()
    }
}

impl ActiveModelBehavior for ActiveModel {}
