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/astointernal.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/astointernal.go')
-rw-r--r-- | internal/typeutils/astointernal.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go index fa2ae6a62..b262030de 100644 --- a/internal/typeutils/astointernal.go +++ b/internal/typeutils/astointernal.go @@ -198,7 +198,25 @@ func (c *Converter) ASRepresentationToAccount(ctx context.Context, accountable a // TODO: FeaturedTagsURI - // TODO: alsoKnownAs + // Moved and AlsoKnownAsURIs, + // needed for account migrations. + movedToURI := ap.GetMovedTo(accountable) + if movedToURI != nil { + acct.MovedToURI = movedToURI.String() + } + + alsoKnownAsURIs := ap.GetAlsoKnownAs(accountable) + for i, uri := range alsoKnownAsURIs { + // Don't store more than + // 20 AKA URIs for remotes, + // to prevent people playing + // silly buggers. + if i >= 20 { + break + } + + acct.AlsoKnownAsURIs = append(acct.AlsoKnownAsURIs, uri.String()) + } // Extract account public key and verify ownership to account. pkey, pkeyURL, pkeyOwnerID, err := ap.ExtractPublicKey(accountable) |