add gateways

This commit is contained in:
doesnm 2024-06-14 15:16:37 +03:00
parent 50a7d1aa42
commit cce2e85648
No known key found for this signature in database

View file

@ -49,6 +49,7 @@ type Actor struct {
OnFollow func(map[string]interface{}) OnFollow func(map[string]interface{})
OnReceiveContent func(map[string]interface{}) OnReceiveContent func(map[string]interface{})
attachment []interface {} attachment []interface {}
gateways []interface {}
} }
// ActorToSave is a stripped down actor representation // ActorToSave is a stripped down actor representation
@ -69,6 +70,8 @@ func MakeActor(name, summary, actorType string) (Actor, error) {
following := make(map[string]interface{}) following := make(map[string]interface{})
rejected := make(map[string]interface{}) rejected := make(map[string]interface{})
requested := make(map[string]interface{}) requested := make(map[string]interface{})
gateways := make([]interface{},0)
gateways = append(gateways,baseURL)
attachment := make([]interface{},0) attachment := make([]interface{},0)
actor := Actor{ actor := Actor{
Name: name, Name: name,
@ -211,6 +214,7 @@ func LoadActor(key string) (Actor, error) {
attachment: jsonData["Attachment"].([]interface{}), attachment: jsonData["Attachment"].([]interface{}),
ed25519PublicKey: decodeEd2PublicKey, ed25519PublicKey: decodeEd2PublicKey,
ed25519PrivateKey: decodeEd2PrivateKey, ed25519PrivateKey: decodeEd2PrivateKey,
gateways: jsonData["Attachment"].([]interface{}),
} }
actor.OnFollow = func(activity map[string]interface{}) { actor.Accept(activity) } actor.OnFollow = func(activity map[string]interface{}) { actor.Accept(activity) }
@ -269,7 +273,7 @@ func (a *Actor) whoAmI() string {
self["type"] = a.actorType self["type"] = a.actorType
self["id"] = baseURL + ".well-known/apgateway/" + encoded + "/actor" self["id"] = baseURL + ".well-known/apgateway/" + encoded + "/actor"
self["name"] = nil self["name"] = nil
self["preferredUsername"] = a.Name self["preferredUsername"] = encoded
self["summary"] = a.summary self["summary"] = a.summary
self["inbox"] = baseURL + ".well-known/apgateway/" + encoded + "/inbox" self["inbox"] = baseURL + ".well-known/apgateway/" + encoded + "/inbox"
self["outbox"] = baseURL + ".well-known/apgateway/" + encoded + "/outbox" self["outbox"] = baseURL + ".well-known/apgateway/" + encoded + "/outbox"
@ -281,6 +285,7 @@ func (a *Actor) whoAmI() string {
"owner": baseURL + ".well-known/apgateway/" + encoded + "/actor", "owner": baseURL + ".well-known/apgateway/" + encoded + "/actor",
"publicKeyPem": a.publicKeyPem, "publicKeyPem": a.publicKeyPem,
} }
self["gateways"] = a.gateways
selfString, _ := json.Marshal(self) selfString, _ := json.Marshal(self)
return string(selfString) return string(selfString)
} }