diff options
author | 2024-02-06 10:45:46 +0100 | |
---|---|---|
committer | 2024-02-06 09:45:46 +0000 | |
commit | aa396c78d30c129bb2145765d3990571dbc025bb (patch) | |
tree | c2046f00c80b029d4f44a1eaf97ca2e960a492cf /internal/typeutils/internaltoas.go | |
parent | [chore]: Bump github.com/miekg/dns from 1.1.57 to 1.1.58 (#2606) (diff) | |
download | gotosocial-aa396c78d30c129bb2145765d3990571dbc025bb.tar.xz |
[feature] serdes for moved/also_known_as (#2600)
* [feature] serdes for moved/also_known_as
* document `alsoKnownAs` and `movedTo` properties
* only implicitly populate AKA uris from DB for local accounts
* don't let remotes store more than 20 AKA uris to avoid shenanigans
Diffstat (limited to 'internal/typeutils/internaltoas.go')
-rw-r--r-- | internal/typeutils/internaltoas.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go index dc25babaa..a795541d0 100644 --- a/internal/typeutils/internaltoas.go +++ b/internal/typeutils/internaltoas.go @@ -171,7 +171,30 @@ func (c *Converter) AccountToAS(ctx context.Context, a *gtsmodel.Account) (vocab // alsoKnownAs // Required for Move activity. - // TODO: NOT IMPLEMENTED **YET** -- this needs to be added as an activitypub extension to https://github.com/go-fed/activity, see https://github.com/go-fed/activity/tree/master/astool + if l := len(a.AlsoKnownAsURIs); l != 0 { + alsoKnownAsURIs := make([]*url.URL, l) + for i, rawURL := range a.AlsoKnownAsURIs { + uri, err := url.Parse(rawURL) + if err != nil { + return nil, err + } + + alsoKnownAsURIs[i] = uri + } + + ap.SetAlsoKnownAs(person, alsoKnownAsURIs) + } + + // movedTo + // Required for Move activity. + if a.MovedToURI != "" { + movedTo, err := url.Parse(a.MovedToURI) + if err != nil { + return nil, err + } + + ap.SetMovedTo(person, movedTo) + } // publicKey // Required for signatures. |