Add per-email sender name for compliance page emails
When an email has a sender name set (the organization name), the mailer composes the From header as "OrgName via Probo" instead of the default global sender name. This gives compliance page recipients clearer context about which organization is contacting them. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -31,6 +31,7 @@ type (
|
||||
ID gid.GID `db:"id"`
|
||||
RecipientEmail string `db:"recipient_email"`
|
||||
RecipientName string `db:"recipient_name"`
|
||||
SenderName *string `db:"sender_name"`
|
||||
ReplyTo *mail.Addr `db:"reply_to"`
|
||||
UnsubscribeURL *string `db:"unsubscribe_url"`
|
||||
MailingListUpdateID *gid.GID `db:"mailing_list_update_id"`
|
||||
@@ -51,6 +52,7 @@ type (
|
||||
Emails []*Email
|
||||
|
||||
EmailOptions struct {
|
||||
SenderName *string
|
||||
ReplyTo *mail.Addr
|
||||
UnsubscribeURL *string
|
||||
MailingListUpdateID *gid.GID
|
||||
@@ -91,6 +93,7 @@ func NewEmail(
|
||||
}
|
||||
|
||||
if opts != nil {
|
||||
e.SenderName = opts.SenderName
|
||||
e.ReplyTo = opts.ReplyTo
|
||||
e.UnsubscribeURL = opts.UnsubscribeURL
|
||||
e.MailingListUpdateID = opts.MailingListUpdateID
|
||||
@@ -108,7 +111,9 @@ INSERT INTO emails (
|
||||
id,
|
||||
recipient_email,
|
||||
recipient_name,
|
||||
reply_to, unsubscribe_url,
|
||||
sender_name,
|
||||
reply_to,
|
||||
unsubscribe_url,
|
||||
mailing_list_update_id,
|
||||
subject,
|
||||
text_body,
|
||||
@@ -123,6 +128,7 @@ VALUES (
|
||||
@id,
|
||||
@recipient_email,
|
||||
@recipient_name,
|
||||
@sender_name,
|
||||
@reply_to,
|
||||
@unsubscribe_url,
|
||||
@mailing_list_update_id,
|
||||
@@ -141,6 +147,7 @@ VALUES (
|
||||
"id": e.ID,
|
||||
"recipient_email": e.RecipientEmail,
|
||||
"recipient_name": e.RecipientName,
|
||||
"sender_name": e.SenderName,
|
||||
"reply_to": e.ReplyTo,
|
||||
"unsubscribe_url": e.UnsubscribeURL,
|
||||
"mailing_list_update_id": e.MailingListUpdateID,
|
||||
@@ -172,6 +179,7 @@ func (emails Emails) BulkInsert(
|
||||
e.ID,
|
||||
e.RecipientEmail,
|
||||
e.RecipientName,
|
||||
e.SenderName,
|
||||
e.ReplyTo,
|
||||
e.UnsubscribeURL,
|
||||
e.MailingListUpdateID,
|
||||
@@ -186,7 +194,7 @@ func (emails Emails) BulkInsert(
|
||||
_, err := conn.CopyFrom(
|
||||
ctx,
|
||||
pgx.Identifier{"emails"},
|
||||
[]string{"id", "recipient_email", "recipient_name", "reply_to", "unsubscribe_url", "mailing_list_update_id", "subject", "text_body", "html_body", "created_at", "updated_at"},
|
||||
[]string{"id", "recipient_email", "recipient_name", "sender_name", "reply_to", "unsubscribe_url", "mailing_list_update_id", "subject", "text_body", "html_body", "created_at", "updated_at"},
|
||||
pgx.CopyFromRows(rows),
|
||||
)
|
||||
return err
|
||||
@@ -198,7 +206,7 @@ func (e *Email) LoadNextPendingForUpdateSkipLocked(
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id, recipient_email, recipient_name, reply_to, unsubscribe_url, mailing_list_update_id, subject, text_body, html_body,
|
||||
id, recipient_email, recipient_name, sender_name, reply_to, unsubscribe_url, mailing_list_update_id, subject, text_body, html_body,
|
||||
status, processing_started_at, attempt_count, max_attempts,
|
||||
last_attempted_at, last_error, created_at, updated_at, sent_at
|
||||
FROM emails
|
||||
|
||||
1
pkg/coredata/migrations/20260322T120000Z.sql
Normal file
1
pkg/coredata/migrations/20260322T120000Z.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE emails ADD COLUMN sender_name text;
|
||||
Reference in New Issue
Block a user