[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
This commit is contained in:
tobi
2024-02-06 10:45:46 +01:00
committed by GitHub
parent 3cc51d5072
commit aa396c78d3
11 changed files with 392 additions and 22 deletions

View File

@ -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)