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"`
Followers string `json:"followers"`
Following string `json:"following"`
ID string `json:"id"`
Id string `json:"id"`
Type string `json:"type"`
PreferredUsername string `json:"preferredUsername"`
Inbox string `json:"inbox"`

Wyświetl plik

@ -3,23 +3,28 @@ package activitypub
import (
"encoding/json"
"fmt"
"github.com/xeronith/diamante/utility"
)
type Follow struct {
Context string `json:"@context" validate:"activitystream"`
Id string `json:"id"`
Type string `json:"type"`
Actor string `json:"actor"`
Object string `json:"object"`
Context string `json:"@context" validate:"activitystream"`
UniqueIdentifier string `json:"-"`
Id string `json:"id"`
Type string `json:"type"`
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{
Context: ActivityStreams,
Id: fmt.Sprintf("%s#follow/%s", follower, uuid),
Type: TypeFollow,
Actor: follower,
Object: followee,
Context: ActivityStreams,
UniqueIdentifier: uuid,
Id: fmt.Sprintf("%s#follow/%s", follower, uuid),
Type: TypeFollow,
Actor: follower,
Object: followee,
}
}