accounts: fix bool queries on (some) string fields

wasn't implemented for things like email on the server side.
also changed text mail variant's footers to all use {{ .footer }} like I
should have before.
This commit is contained in:
Harvey Tindall
2025-09-01 20:43:34 +01:00
parent 0fe574fbd9
commit 6ebc7d18bf
12 changed files with 71 additions and 21 deletions

View File

@@ -5,4 +5,4 @@
{{ .confirmationURL }}
{{ .message }}
{{ .footer }}

View File

@@ -6,4 +6,4 @@
{{ .timeString }}: {{ .time }}
{{ .notificationNotice }}
{{ .footer }}

View File

@@ -4,4 +4,4 @@
{{ .reasonString }}: {{ .reason }}
{{ .message }}
{{ .footer }}

View File

@@ -2,4 +2,4 @@
{{ .expiredAt }}
{{ .notificationNotice }}
{{ .footer }}

View File

@@ -8,4 +8,4 @@
{{ .reasonString }}: {{ .reason }}
{{ .message }}
{{ .footer }}

View File

@@ -2,4 +2,4 @@
{{ .yourAccountIsDueToExpire }}
{{ .message }}
{{ .footer }}

View File

@@ -5,4 +5,4 @@
{{ .inviteURL }}
{{ .message }}
{{ .footer }}

View File

@@ -10,4 +10,4 @@
{{ .pinString }}: {{ .pin }}
{{ .message }}
{{ .footer }}

View File

@@ -1,3 +1,3 @@
{{ .plaintext }}
{{ .message }}
{{ .footer }}

View File

@@ -2,4 +2,4 @@
{{ .contactTheAdmin }}
{{ .message }}
{{ .footer }}

View File

@@ -8,4 +8,4 @@
{{ .yourAccountWillExpire }}
{{ .message }}
{{ .footer }}

View File

@@ -345,8 +345,18 @@ func (q QueryDTO) AsFilter() Filter {
return cmp.Compare(strings.ToLower(a.Name), strings.ToLower(q.Value.(string))) == int(operator)
}
case "email":
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Email), strings.ToLower(q.Value.(string))) == int(operator)
switch q.Class {
case BoolQuery:
return func(a *respUser) bool {
if q.Value.(bool) {
return a.Email != ""
}
return a.Email == ""
}
case StringQuery:
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Email), strings.ToLower(q.Value.(string))) == int(operator)
}
}
case "notify_email":
return func(a *respUser) bool {
@@ -391,16 +401,36 @@ func (q QueryDTO) AsFilter() Filter {
return cmp.Compare(bool2int(a.Disabled), bool2int(q.Value.(bool))) == int(operator)
}
case "telegram":
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Telegram), strings.ToLower(q.Value.(string))) == int(operator)
switch q.Class {
case BoolQuery:
return func(a *respUser) bool {
if q.Value.(bool) {
return a.Telegram != ""
}
return a.Telegram == ""
}
case StringQuery:
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Telegram), strings.ToLower(q.Value.(string))) == int(operator)
}
}
case "notify_telegram":
return func(a *respUser) bool {
return cmp.Compare(bool2int(a.NotifyThroughTelegram), bool2int(q.Value.(bool))) == int(operator)
}
case "discord":
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Discord), strings.ToLower(q.Value.(string))) == int(operator)
switch q.Class {
case BoolQuery:
return func(a *respUser) bool {
if q.Value.(bool) {
return a.Discord != ""
}
return a.Discord == ""
}
case StringQuery:
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Discord), strings.ToLower(q.Value.(string))) == int(operator)
}
}
case "discord_id":
return func(a *respUser) bool {
@@ -411,16 +441,36 @@ func (q QueryDTO) AsFilter() Filter {
return cmp.Compare(bool2int(a.NotifyThroughDiscord), bool2int(q.Value.(bool))) == int(operator)
}
case "matrix":
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Matrix), strings.ToLower(q.Value.(string))) == int(operator)
switch q.Class {
case BoolQuery:
return func(a *respUser) bool {
if q.Value.(bool) {
return a.Matrix != ""
}
return a.Matrix == ""
}
case StringQuery:
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Matrix), strings.ToLower(q.Value.(string))) == int(operator)
}
}
case "notify_matrix":
return func(a *respUser) bool {
return cmp.Compare(bool2int(a.NotifyThroughMatrix), bool2int(q.Value.(bool))) == int(operator)
}
case "label":
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Label), strings.ToLower(q.Value.(string))) == int(operator)
switch q.Class {
case BoolQuery:
return func(a *respUser) bool {
if q.Value.(bool) {
return a.Label != ""
}
return a.Label == ""
}
case StringQuery:
return func(a *respUser) bool {
return cmp.Compare(strings.ToLower(a.Label), strings.ToLower(q.Value.(string))) == int(operator)
}
}
case "accounts_admin":
return func(a *respUser) bool {