mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 10:12:26 -05:00
[feature] Account alias / move API + db models (#2518)
* [feature] Account alias / move API + db models * go fmt * fix little cherry-pick issues * update error checking, formatting * add and use new util functions to simplify alias logic
This commit is contained in:
parent
ebf550b7c1
commit
c36f9ac37b
23 changed files with 1243 additions and 39 deletions
|
|
@ -254,7 +254,7 @@ func (a *accountDB) getAccount(ctx context.Context, lookup string, dbQuery func(
|
|||
func (a *accountDB) PopulateAccount(ctx context.Context, account *gtsmodel.Account) error {
|
||||
var (
|
||||
err error
|
||||
errs = gtserror.NewMultiError(3)
|
||||
errs = gtserror.NewMultiError(5)
|
||||
)
|
||||
|
||||
if account.AvatarMediaAttachment == nil && account.AvatarMediaAttachmentID != "" {
|
||||
|
|
@ -279,6 +279,37 @@ func (a *accountDB) PopulateAccount(ctx context.Context, account *gtsmodel.Accou
|
|||
}
|
||||
}
|
||||
|
||||
if !account.AlsoKnownAsPopulated() {
|
||||
// Account alsoKnownAs accounts are
|
||||
// out-of-date with URIs, repopulate.
|
||||
alsoKnownAs := make([]*gtsmodel.Account, 0)
|
||||
for _, uri := range account.AlsoKnownAsURIs {
|
||||
akaAcct, err := a.state.DB.GetAccountByURI(
|
||||
gtscontext.SetBarebones(ctx),
|
||||
uri,
|
||||
)
|
||||
if err != nil {
|
||||
errs.Appendf("error populating also known as account %s: %w", uri, err)
|
||||
continue
|
||||
}
|
||||
|
||||
alsoKnownAs = append(alsoKnownAs, akaAcct)
|
||||
}
|
||||
|
||||
account.AlsoKnownAs = alsoKnownAs
|
||||
}
|
||||
|
||||
if account.MovedTo == nil && account.MovedToURI != "" {
|
||||
// Account movedTo is not set, fetch from database.
|
||||
account.MovedTo, err = a.state.DB.GetAccountByURI(
|
||||
gtscontext.SetBarebones(ctx),
|
||||
account.MovedToURI,
|
||||
)
|
||||
if err != nil {
|
||||
errs.Appendf("error populating moved to account: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if !account.EmojisPopulated() {
|
||||
// Account emojis are out-of-date with IDs, repopulate.
|
||||
account.Emojis, err = a.state.DB.GetEmojisByIDs(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue