diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/db/bundb/account.go | 8 | ||||
| -rw-r--r-- | internal/db/bundb/instance.go | 19 | ||||
| -rw-r--r-- | internal/db/bundb/relationship.go | 2 | 
3 files changed, 13 insertions, 16 deletions
diff --git a/internal/db/bundb/account.go b/internal/db/bundb/account.go index c96d0df9e..aef1f3281 100644 --- a/internal/db/bundb/account.go +++ b/internal/db/bundb/account.go @@ -217,10 +217,6 @@ func (a *accountDB) GetAccountStatuses(ctx context.Context, accountID string, li  		q = q.Limit(limit)  	} -	if excludeReplies { -		q = q.WhereGroup(" AND ", whereEmptyOrNull("in_reply_to_id")) -	} -  	if pinnedOnly {  		q = q.Where("pinned = ?", true)  	} @@ -237,6 +233,10 @@ func (a *accountDB) GetAccountStatuses(ctx context.Context, accountID string, li  		})  	} +	if excludeReplies { +		q = q.WhereGroup(" AND ", whereEmptyOrNull("in_reply_to_id")) +	} +  	if err := q.Scan(ctx); err != nil {  		return nil, err  	} diff --git a/internal/db/bundb/instance.go b/internal/db/bundb/instance.go index 141b255cf..ea7ae194b 100644 --- a/internal/db/bundb/instance.go +++ b/internal/db/bundb/instance.go @@ -37,20 +37,17 @@ type instanceDB struct {  func (i *instanceDB) CountInstanceUsers(ctx context.Context, domain string) (int, db.Error) {  	q := i.conn.  		NewSelect(). -		Model(&[]*gtsmodel.Account{}) - -	if domain == i.config.Host { -		// if the domain is *this* domain, just count where the domain field is null -		q = q.WhereGroup(" AND ", whereEmptyOrNull("domain")) -	} else { -		q = q.Where("domain = ?", domain) -	} - -	// don't count the instance account or suspended users -	q = q. +		Model(&[]*gtsmodel.Account{}).  		Where("username != ?", domain).  		Where("? IS NULL", bun.Ident("suspended_at")) +		if domain == i.config.Host { +			// if the domain is *this* domain, just count where the domain field is null +			q = q.WhereGroup(" AND ", whereEmptyOrNull("domain")) +		} else { +			q = q.Where("domain = ?", domain) +		} +  	count, err := q.Count(ctx)  	return count, processErrorResponse(err) diff --git a/internal/db/bundb/relationship.go b/internal/db/bundb/relationship.go index ed144669e..95426f122 100644 --- a/internal/db/bundb/relationship.go +++ b/internal/db/bundb/relationship.go @@ -237,7 +237,7 @@ func (r *relationshipDB) AcceptFollowRequest(ctx context.Context, originAccountI  	if _, err := r.conn.  		NewInsert().  		Model(follow). -		On("CONFLICT CONSTRAINT follows_account_id_target_account_id_key DO UPDATE set uri = ?", follow.URI). +		On("CONFLICT ON CONSTRAINT follows_account_id_target_account_id_key DO UPDATE set uri = ?", follow.URI).  		Exec(ctx); err != nil {  		return nil, processErrorResponse(err)  	}  | 
