package models

import "time"

// FederationActivity stores all inbound and outbound ActivityPub activities.
type FederationActivity struct {
	ID          int64     `xorm:"'id' pk autoincr"                json:"id"`
	ActorAPID   string    `xorm:"'actor_ap_id' notnull index varchar(500)" json:"actorApId"`
	Type        string    `xorm:"'type' notnull varchar(50)"      json:"type"`
	ObjectJSON  string    `xorm:"'object_json' text"              json:"objectJson"`
	Direction   string    `xorm:"'direction' notnull varchar(10)" json:"direction"` // inbound|outbound
	RemoteActor string    `xorm:"'remote_actor' varchar(500)"     json:"remoteActor"`
	Published   time.Time `xorm:"'published' index"               json:"published"`
	CreatedAt   time.Time `xorm:"'created_at' created"            json:"createdAt"`
}

// RemoteActor caches public actor documents fetched from remote instances.
type RemoteActor struct {
	ID        int64     `xorm:"'id' pk autoincr"`
	APID      string    `xorm:"'ap_id' notnull unique varchar(500)"`
	InboxURL  string    `xorm:"'inbox_url' varchar(500)"`
	PublicKey string    `xorm:"'public_key' text"`
	FetchedAt time.Time `xorm:"'fetched_at'"`
	CreatedAt time.Time `xorm:"'created_at' created"`
}

type FederationActor struct {
	ID         int64     `xorm:"'id' pk autoincr"                     json:"id"`
	UserID     int64     `xorm:"'user_id' notnull unique index"       json:"userId"`
	APID       string    `xorm:"'ap_id' notnull unique varchar(500)"  json:"apId"`
	InboxURL   string    `xorm:"'inbox_url' notnull varchar(500)"     json:"inboxUrl"`
	OutboxURL  string    `xorm:"'outbox_url' notnull varchar(500)"    json:"outboxUrl"`
	PublicKey  string    `xorm:"'public_key' text notnull"            json:"publicKey"`
	PrivateKey string    `xorm:"'private_key' text notnull"           json:"-"`
	CreatedAt  time.Time `xorm:"'created_at' created"                 json:"createdAt"`
	UpdatedAt  time.Time `xorm:"'updated_at' updated"                 json:"updatedAt"`
}
