summaryrefslogtreecommitdiff
path: root/internal/authentication/types.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2022-07-18 10:56:09 +1000
committerGitHub <noreply@github.com>2022-07-18 10:56:09 +1000
commitdf016be29ea155c030d419937bf4bf8757ae3bf0 (patch)
tree1e086c07392b209094033c9146a234b3de25b336 /internal/authentication/types.go
parent38e3f741b72957997d1691b53507f1c353cc6886 (diff)
fix(notification): incorrect date header format (#3684)
* fix(notification): incorrect date header format The date header in the email envelopes was incorrectly formatted missing a space between the `Date:` header and the value of this header. This also refactors the notification templates system allowing people to manually override the envelope itself. * test: fix tests and linting issues * fix: misc issues * refactor: misc refactoring * docs: add example for envelope with message id * refactor: organize smtp notifier * refactor: move subject interpolation * refactor: include additional placeholders * docs: fix missing link * docs: gravity * fix: rcpt to command * refactor: remove mid * refactor: apply suggestions Co-authored-by: Amir Zarrinkafsh <nightah@me.com> * refactor: include pid Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
Diffstat (limited to 'internal/authentication/types.go')
-rw-r--r--internal/authentication/types.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/authentication/types.go b/internal/authentication/types.go
index ee4e47ba1..5299185fc 100644
--- a/internal/authentication/types.go
+++ b/internal/authentication/types.go
@@ -2,6 +2,7 @@ package authentication
import (
"crypto/tls"
+ "net/mail"
"github.com/go-ldap/ldap/v3"
"golang.org/x/text/encoding/unicode"
@@ -36,6 +37,24 @@ type UserDetails struct {
Groups []string
}
+// Addresses returns the Emails []string as []mail.Address formatted with DisplayName as the Name attribute.
+func (d UserDetails) Addresses() (addresses []mail.Address) {
+ if len(d.Emails) == 0 {
+ return nil
+ }
+
+ addresses = make([]mail.Address, len(d.Emails))
+
+ for i, email := range d.Emails {
+ addresses[i] = mail.Address{
+ Name: d.DisplayName,
+ Address: email,
+ }
+ }
+
+ return addresses
+}
+
type ldapUserProfile struct {
DN string
Emails []string