diff options
| author | 2022-09-02 10:56:33 +0100 | |
|---|---|---|
| committer | 2022-09-02 11:56:33 +0200 | |
| commit | 614ab12733b991dbea9d1f7fa311a98072558727 (patch) | |
| tree | 41780382cb71413566c8c87ce1ce0184c504253b /internal/processing | |
| parent | [feature] Emojify spoiler and content in web templates (#785) (diff) | |
| download | gotosocial-614ab12733b991dbea9d1f7fa311a98072558727.tar.xz | |
[performance] use GetAccountByUsernameDomain() for local account lookups to rely on cache (#793)
Signed-off-by: kim <grufwub@gmail.com>
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/processing')
| -rw-r--r-- | internal/processing/account/get.go | 2 | ||||
| -rw-r--r-- | internal/processing/federation/getfollowers.go | 2 | ||||
| -rw-r--r-- | internal/processing/federation/getfollowing.go | 2 | ||||
| -rw-r--r-- | internal/processing/federation/getoutbox.go | 2 | ||||
| -rw-r--r-- | internal/processing/federation/getstatus.go | 2 | ||||
| -rw-r--r-- | internal/processing/federation/getstatusreplies.go | 2 | ||||
| -rw-r--r-- | internal/processing/federation/getuser.go | 2 | ||||
| -rw-r--r-- | internal/processing/federation/getwebfinger.go | 2 | ||||
| -rw-r--r-- | internal/processing/instance.go | 2 | ||||
| -rw-r--r-- | internal/processing/search.go | 2 | ||||
| -rw-r--r-- | internal/processing/util.go | 2 | 
11 files changed, 11 insertions, 11 deletions
| diff --git a/internal/processing/account/get.go b/internal/processing/account/get.go index d6f1aa71f..c558b52ed 100644 --- a/internal/processing/account/get.go +++ b/internal/processing/account/get.go @@ -44,7 +44,7 @@ func (p *processor) Get(ctx context.Context, requestingAccount *gtsmodel.Account  }  func (p *processor) GetLocalByUsername(ctx context.Context, requestingAccount *gtsmodel.Account, username string) (*apimodel.Account, gtserror.WithCode) { -	targetAccount, err := p.db.GetLocalAccountByUsername(ctx, username) +	targetAccount, err := p.db.GetAccountByUsernameDomain(ctx, username, "")  	if err != nil {  		if err == db.ErrNoEntries {  			return nil, gtserror.NewErrorNotFound(errors.New("account not found")) diff --git a/internal/processing/federation/getfollowers.go b/internal/processing/federation/getfollowers.go index 30ec1c58f..89c229706 100644 --- a/internal/processing/federation/getfollowers.go +++ b/internal/processing/federation/getfollowers.go @@ -30,7 +30,7 @@ import (  func (p *processor) GetFollowers(ctx context.Context, requestedUsername string, requestURL *url.URL) (interface{}, gtserror.WithCode) {  	// get the account the request is referring to -	requestedAccount, err := p.db.GetLocalAccountByUsername(ctx, requestedUsername) +	requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")  	if err != nil {  		return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))  	} diff --git a/internal/processing/federation/getfollowing.go b/internal/processing/federation/getfollowing.go index 13291939a..91f097817 100644 --- a/internal/processing/federation/getfollowing.go +++ b/internal/processing/federation/getfollowing.go @@ -30,7 +30,7 @@ import (  func (p *processor) GetFollowing(ctx context.Context, requestedUsername string, requestURL *url.URL) (interface{}, gtserror.WithCode) {  	// get the account the request is referring to -	requestedAccount, err := p.db.GetLocalAccountByUsername(ctx, requestedUsername) +	requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")  	if err != nil {  		return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))  	} diff --git a/internal/processing/federation/getoutbox.go b/internal/processing/federation/getoutbox.go index b2e618b98..1a9afc14f 100644 --- a/internal/processing/federation/getoutbox.go +++ b/internal/processing/federation/getoutbox.go @@ -31,7 +31,7 @@ import (  func (p *processor) GetOutbox(ctx context.Context, requestedUsername string, page bool, maxID string, minID string, requestURL *url.URL) (interface{}, gtserror.WithCode) {  	// get the account the request is referring to -	requestedAccount, err := p.db.GetLocalAccountByUsername(ctx, requestedUsername) +	requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")  	if err != nil {  		return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))  	} diff --git a/internal/processing/federation/getstatus.go b/internal/processing/federation/getstatus.go index f61c87d1d..eff8881d8 100644 --- a/internal/processing/federation/getstatus.go +++ b/internal/processing/federation/getstatus.go @@ -30,7 +30,7 @@ import (  func (p *processor) GetStatus(ctx context.Context, requestedUsername string, requestedStatusID string, requestURL *url.URL) (interface{}, gtserror.WithCode) {  	// get the account the request is referring to -	requestedAccount, err := p.db.GetLocalAccountByUsername(ctx, requestedUsername) +	requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")  	if err != nil {  		return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))  	} diff --git a/internal/processing/federation/getstatusreplies.go b/internal/processing/federation/getstatusreplies.go index fad986ea5..067fcb36b 100644 --- a/internal/processing/federation/getstatusreplies.go +++ b/internal/processing/federation/getstatusreplies.go @@ -32,7 +32,7 @@ import (  func (p *processor) GetStatusReplies(ctx context.Context, requestedUsername string, requestedStatusID string, page bool, onlyOtherAccounts bool, minID string, requestURL *url.URL) (interface{}, gtserror.WithCode) {  	// get the account the request is referring to -	requestedAccount, err := p.db.GetLocalAccountByUsername(ctx, requestedUsername) +	requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")  	if err != nil {  		return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))  	} diff --git a/internal/processing/federation/getuser.go b/internal/processing/federation/getuser.go index 372a3a57b..c1ad9853b 100644 --- a/internal/processing/federation/getuser.go +++ b/internal/processing/federation/getuser.go @@ -32,7 +32,7 @@ import (  func (p *processor) GetUser(ctx context.Context, requestedUsername string, requestURL *url.URL) (interface{}, gtserror.WithCode) {  	// get the account the request is referring to -	requestedAccount, err := p.db.GetLocalAccountByUsername(ctx, requestedUsername) +	requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")  	if err != nil {  		return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))  	} diff --git a/internal/processing/federation/getwebfinger.go b/internal/processing/federation/getwebfinger.go index 7158680d7..a1e1cb983 100644 --- a/internal/processing/federation/getwebfinger.go +++ b/internal/processing/federation/getwebfinger.go @@ -37,7 +37,7 @@ const (  func (p *processor) GetWebfingerAccount(ctx context.Context, requestedUsername string) (*apimodel.WellKnownResponse, gtserror.WithCode) {  	// get the account the request is referring to -	requestedAccount, err := p.db.GetLocalAccountByUsername(ctx, requestedUsername) +	requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")  	if err != nil {  		return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))  	} diff --git a/internal/processing/instance.go b/internal/processing/instance.go index 0a13917ea..b7418659a 100644 --- a/internal/processing/instance.go +++ b/internal/processing/instance.go @@ -137,7 +137,7 @@ func (p *processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSe  	// validate & update site contact account if it's set on the form  	if form.ContactUsername != nil {  		// make sure the account with the given username exists in the db -		contactAccount, err := p.db.GetLocalAccountByUsername(ctx, *form.ContactUsername) +		contactAccount, err := p.db.GetAccountByUsernameDomain(ctx, *form.ContactUsername, "")  		if err != nil {  			return nil, gtserror.NewErrorBadRequest(err, fmt.Sprintf("account with username %s not retrievable", *form.ContactUsername))  		} diff --git a/internal/processing/search.go b/internal/processing/search.go index 2e5ec2025..3d7f3e56e 100644 --- a/internal/processing/search.go +++ b/internal/processing/search.go @@ -193,7 +193,7 @@ func (p *processor) searchAccountByURI(ctx context.Context, authed *oauth.Auth,  func (p *processor) searchAccountByMention(ctx context.Context, authed *oauth.Auth, username string, domain string, resolve bool) (*gtsmodel.Account, error) {  	// if it's a local account we can skip a whole bunch of stuff  	if domain == config.GetHost() || domain == config.GetAccountDomain() || domain == "" { -		maybeAcct, err := p.db.GetLocalAccountByUsername(ctx, username) +		maybeAcct, err := p.db.GetAccountByUsernameDomain(ctx, username, "")  		if err == nil || err == db.ErrNoEntries {  			return maybeAcct, nil  		} diff --git a/internal/processing/util.go b/internal/processing/util.go index 76d1187f9..e360428cc 100644 --- a/internal/processing/util.go +++ b/internal/processing/util.go @@ -46,7 +46,7 @@ func GetParseMentionFunc(dbConn db.DB, federator federation.Federator) gtsmodel.  		var mentionedAccount *gtsmodel.Account  		if domain == "" || domain == config.GetHost() || domain == config.GetAccountDomain() { -			localAccount, err := dbConn.GetLocalAccountByUsername(ctx, username) +			localAccount, err := dbConn.GetAccountByUsernameDomain(ctx, username, "")  			if err != nil {  				return nil, err  			} | 
