implemented federation

This commit is contained in:
2026-05-12 20:55:13 +02:00
parent e360f3697e
commit ab94775162
13 changed files with 874 additions and 30 deletions
+22
View File
@@ -2,6 +2,28 @@ 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"`
+4 -1
View File
@@ -49,5 +49,8 @@ func Run(engine *xorm.Engine) error {
if err := Run012(engine); err != nil {
return err
}
return Run013(engine)
if err := Run013(engine); err != nil {
return err
}
return Run014(engine)
}
@@ -0,0 +1,13 @@
package migrations
import (
"github.com/forgeo/forgebucket/internal/models"
"xorm.io/xorm"
)
func Run014(engine *xorm.Engine) error {
return engine.Sync2(
&models.FederationActivity{},
&models.RemoteActor{},
)
}