refactor(activitypub): 🎨 improve structure

master
Xeronith 2023-07-17 17:09:41 +03:30
rodzic 9f1a7b3d43
commit e2ec053ce3
2 zmienionych plików z 17 dodań i 12 usunięć

Wyświetl plik

@ -9,7 +9,7 @@ type Actor struct {
Context []interface{} `json:"@context"` Context []interface{} `json:"@context"`
Followers string `json:"followers"` Followers string `json:"followers"`
Following string `json:"following"` Following string `json:"following"`
ID string `json:"id"` Id string `json:"id"`
Type string `json:"type"` Type string `json:"type"`
PreferredUsername string `json:"preferredUsername"` PreferredUsername string `json:"preferredUsername"`
Inbox string `json:"inbox"` Inbox string `json:"inbox"`

Wyświetl plik

@ -3,23 +3,28 @@ package activitypub
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/xeronith/diamante/utility"
) )
type Follow struct { type Follow struct {
Context string `json:"@context" validate:"activitystream"` Context string `json:"@context" validate:"activitystream"`
Id string `json:"id"` UniqueIdentifier string `json:"-"`
Type string `json:"type"` Id string `json:"id"`
Actor string `json:"actor"` Type string `json:"type"`
Object string `json:"object"` Actor string `json:"actor"`
Object string `json:"object"`
} }
func NewFollow(follower, followee, uuid string) *Follow { func NewFollow(follower, followee string) *Follow {
uuid := utility.GenerateUUID()
return &Follow{ return &Follow{
Context: ActivityStreams, Context: ActivityStreams,
Id: fmt.Sprintf("%s#follow/%s", follower, uuid), UniqueIdentifier: uuid,
Type: TypeFollow, Id: fmt.Sprintf("%s#follow/%s", follower, uuid),
Actor: follower, Type: TypeFollow,
Object: followee, Actor: follower,
Object: followee,
} }
} }