diff options
author | 2024-04-11 11:45:53 +0200 | |
---|---|---|
committer | 2024-04-11 11:45:53 +0200 | |
commit | 9fb8a78f91adffd5f4d28df1270e407c25a7a16e (patch) | |
tree | d68200744e28d07e75a52bb0c9f6593c86a38a91 /internal/db/bundb/instance.go | |
parent | [performance] massively improved ActivityPub delivery worker efficiency (#2812) (diff) | |
download | gotosocial-9fb8a78f91adffd5f4d28df1270e407c25a7a16e.tar.xz |
[feature] New user sign-up via web page (#2796)
* [feature] User sign-up form and admin notifs
* add chosen + filtered languages to migration
* remove stray comment
* chosen languages schmosen schmanguages
* proper error on local account missing
Diffstat (limited to 'internal/db/bundb/instance.go')
-rw-r--r-- | internal/db/bundb/instance.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/db/bundb/instance.go b/internal/db/bundb/instance.go index 5f96f9a26..73bbcea8b 100644 --- a/internal/db/bundb/instance.go +++ b/internal/db/bundb/instance.go @@ -380,3 +380,33 @@ func (i *instanceDB) GetInstanceModeratorAddresses(ctx context.Context) ([]strin return addresses, nil } + +func (i *instanceDB) GetInstanceModerators(ctx context.Context) ([]*gtsmodel.Account, error) { + accountIDs := []string{} + + // Select account IDs of approved, confirmed, + // and enabled moderators or admins. + + q := i.db. + NewSelect(). + TableExpr("? AS ?", bun.Ident("users"), bun.Ident("user")). + Column("user.account_id"). + Where("? = ?", bun.Ident("user.approved"), true). + Where("? IS NOT NULL", bun.Ident("user.confirmed_at")). + Where("? = ?", bun.Ident("user.disabled"), false). + WhereGroup(" AND ", func(q *bun.SelectQuery) *bun.SelectQuery { + return q. + Where("? = ?", bun.Ident("user.moderator"), true). + WhereOr("? = ?", bun.Ident("user.admin"), true) + }) + + if err := q.Scan(ctx, &accountIDs); err != nil { + return nil, err + } + + if len(accountIDs) == 0 { + return nil, db.ErrNoEntries + } + + return i.state.DB.GetAccountsByIDs(ctx, accountIDs) +} |