mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 10:12:26 -05:00
[bugfix] Punycode fixes (#1743)
Co-authored-by: kim <grufwub@gmail.com> Co-authored-by: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>
This commit is contained in:
parent
b7dd32da42
commit
37b4d9d179
11 changed files with 409 additions and 211 deletions
|
|
@ -27,9 +27,11 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtscontext"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
"github.com/uptrace/bun"
|
||||
"github.com/uptrace/bun/dialect"
|
||||
)
|
||||
|
|
@ -82,6 +84,15 @@ func (a *accountDB) GetAccountByURL(ctx context.Context, url string) (*gtsmodel.
|
|||
}
|
||||
|
||||
func (a *accountDB) GetAccountByUsernameDomain(ctx context.Context, username string, domain string) (*gtsmodel.Account, db.Error) {
|
||||
if domain != "" {
|
||||
// Normalize the domain as punycode
|
||||
var err error
|
||||
domain, err = util.Punify(domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return a.getAccount(
|
||||
ctx,
|
||||
"Username.Domain",
|
||||
|
|
@ -220,7 +231,10 @@ 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
|
||||
var (
|
||||
err error
|
||||
errs = make(gtserror.MultiError, 0, 3)
|
||||
)
|
||||
|
||||
if account.AvatarMediaAttachment == nil && account.AvatarMediaAttachmentID != "" {
|
||||
// Account avatar attachment is not set, fetch from database.
|
||||
|
|
@ -229,7 +243,7 @@ func (a *accountDB) PopulateAccount(ctx context.Context, account *gtsmodel.Accou
|
|||
account.AvatarMediaAttachmentID,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error populating account avatar: %w", err)
|
||||
errs.Append(fmt.Errorf("error populating account avatar: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +254,7 @@ func (a *accountDB) PopulateAccount(ctx context.Context, account *gtsmodel.Accou
|
|||
account.HeaderMediaAttachmentID,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error populating account header: %w", err)
|
||||
errs.Append(fmt.Errorf("error populating account header: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,11 +265,11 @@ func (a *accountDB) PopulateAccount(ctx context.Context, account *gtsmodel.Accou
|
|||
account.EmojiIDs,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error populating account emojis: %w", err)
|
||||
errs.Append(fmt.Errorf("error populating account emojis: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return errs.Combine()
|
||||
}
|
||||
|
||||
func (a *accountDB) PutAccount(ctx context.Context, account *gtsmodel.Account) db.Error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue