mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-02-14 20:17:23 +01:00
don't repeat regex parsing
This commit is contained in:
parent
d2c512575c
commit
2edc5c702a
1 changed files with 6 additions and 10 deletions
|
@ -160,16 +160,12 @@ func (p *processor) searchAccountByURI(ctx context.Context, authed *oauth.Auth,
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *processor) searchAccountByMention(ctx context.Context, authed *oauth.Auth, mention string, resolve bool) (*gtsmodel.Account, error) {
|
func (p *processor) searchAccountByMention(ctx context.Context, authed *oauth.Auth, username string, domain string, resolve bool) (*gtsmodel.Account, error) {
|
||||||
// query is for a remote account
|
maybeAcct := >smodel.Account{}
|
||||||
username, host, err := util.ExtractNamestringParts(mention)
|
var err error
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("searchAccountByMention: error extracting mention parts: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it's a local account we can skip a whole bunch of stuff
|
// if it's a local account we can skip a whole bunch of stuff
|
||||||
maybeAcct := >smodel.Account{}
|
if domain == config.GetHost() {
|
||||||
if host == config.GetHost() {
|
|
||||||
maybeAcct, err = p.db.GetLocalAccountByUsername(ctx, username)
|
maybeAcct, err = p.db.GetLocalAccountByUsername(ctx, username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("searchAccountByMention: error getting local account by username: %s", err)
|
return nil, fmt.Errorf("searchAccountByMention: error getting local account by username: %s", err)
|
||||||
|
@ -180,7 +176,7 @@ func (p *processor) searchAccountByMention(ctx context.Context, authed *oauth.Au
|
||||||
// it's not a local account so first we'll check if it's in the database already...
|
// it's not a local account so first we'll check if it's in the database already...
|
||||||
where := []db.Where{
|
where := []db.Where{
|
||||||
{Key: "username", Value: username, CaseInsensitive: true},
|
{Key: "username", Value: username, CaseInsensitive: true},
|
||||||
{Key: "domain", Value: host, CaseInsensitive: true},
|
{Key: "domain", Value: domain, CaseInsensitive: true},
|
||||||
}
|
}
|
||||||
err = p.db.GetWhere(ctx, where, maybeAcct)
|
err = p.db.GetWhere(ctx, where, maybeAcct)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -198,7 +194,7 @@ func (p *processor) searchAccountByMention(ctx context.Context, authed *oauth.Au
|
||||||
maybeAcct, err = p.federator.GetRemoteAccount(ctx, dereferencing.GetRemoteAccountParams{
|
maybeAcct, err = p.federator.GetRemoteAccount(ctx, dereferencing.GetRemoteAccountParams{
|
||||||
RequestingUsername: authed.Account.Username,
|
RequestingUsername: authed.Account.Username,
|
||||||
RemoteAccountUsername: username,
|
RemoteAccountUsername: username,
|
||||||
RemoteAccountHost: host,
|
RemoteAccountHost: domain,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("searchAccountByMention: error getting remote account: %s", err)
|
return nil, fmt.Errorf("searchAccountByMention: error getting remote account: %s", err)
|
||||||
|
|
Loading…
Reference in a new issue