mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-16 14:33:00 -06:00
[feature] Email notifications for new / closed moderation reports (#1628)
* start fiddling about with email sending to allow multiple recipients * do some fiddling * notifs working * notify on closed report * finishing up * envparsing * use strings.ContainsAny
This commit is contained in:
parent
9c55c07be9
commit
7db81cde44
35 changed files with 773 additions and 420 deletions
|
|
@ -156,3 +156,34 @@ func (i *instanceDB) GetInstanceAccounts(ctx context.Context, domain string, max
|
|||
|
||||
return accounts, nil
|
||||
}
|
||||
|
||||
func (i *instanceDB) GetInstanceModeratorAddresses(ctx context.Context) ([]string, db.Error) {
|
||||
addresses := []string{}
|
||||
|
||||
// Select email addresses of approved, confirmed,
|
||||
// and enabled moderators or admins.
|
||||
|
||||
q := i.conn.
|
||||
NewSelect().
|
||||
TableExpr("? AS ?", bun.Ident("users"), bun.Ident("user")).
|
||||
Column("user.email").
|
||||
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)
|
||||
}).
|
||||
OrderExpr("? ASC", bun.Ident("user.email"))
|
||||
|
||||
if err := q.Scan(ctx, &addresses); err != nil {
|
||||
return nil, i.conn.ProcessError(err)
|
||||
}
|
||||
|
||||
if len(addresses) == 0 {
|
||||
return nil, db.ErrNoEntries
|
||||
}
|
||||
|
||||
return addresses, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue