From cce2e85648a39c71d18af9918709c92e46282e1c Mon Sep 17 00:00:00 2001 From: doesnm Date: Fri, 14 Jun 2024 15:16:37 +0300 Subject: [PATCH] add gateways --- actor.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/actor.go b/actor.go index c820f80..2a80990 100644 --- a/actor.go +++ b/actor.go @@ -49,6 +49,7 @@ type Actor struct { OnFollow func(map[string]interface{}) OnReceiveContent func(map[string]interface{}) attachment []interface {} + gateways []interface {} } // ActorToSave is a stripped down actor representation @@ -69,6 +70,8 @@ func MakeActor(name, summary, actorType string) (Actor, error) { following := make(map[string]interface{}) rejected := make(map[string]interface{}) requested := make(map[string]interface{}) + gateways := make([]interface{},0) + gateways = append(gateways,baseURL) attachment := make([]interface{},0) actor := Actor{ Name: name, @@ -211,6 +214,7 @@ func LoadActor(key string) (Actor, error) { attachment: jsonData["Attachment"].([]interface{}), ed25519PublicKey: decodeEd2PublicKey, ed25519PrivateKey: decodeEd2PrivateKey, + gateways: jsonData["Attachment"].([]interface{}), } actor.OnFollow = func(activity map[string]interface{}) { actor.Accept(activity) } @@ -269,7 +273,7 @@ func (a *Actor) whoAmI() string { self["type"] = a.actorType self["id"] = baseURL + ".well-known/apgateway/" + encoded + "/actor" self["name"] = nil - self["preferredUsername"] = a.Name + self["preferredUsername"] = encoded self["summary"] = a.summary self["inbox"] = baseURL + ".well-known/apgateway/" + encoded + "/inbox" self["outbox"] = baseURL + ".well-known/apgateway/" + encoded + "/outbox" @@ -281,6 +285,7 @@ func (a *Actor) whoAmI() string { "owner": baseURL + ".well-known/apgateway/" + encoded + "/actor", "publicKeyPem": a.publicKeyPem, } + self["gateways"] = a.gateways selfString, _ := json.Marshal(self) return string(selfString) }