Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 1c1fe26

Browse files
committed
Add Store Name to Email Notifications
1 parent 2b4c3a3 commit 1c1fe26

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

api/jsonapi.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,6 +4083,12 @@ func (i *jsonAPIHandler) POSTTestEmailNotifications(w http.ResponseWriter, r *ht
40834083
ErrorResponse(w, http.StatusBadRequest, err.Error())
40844084
return
40854085
}
4086+
profile, err := i.node.GetProfile()
4087+
if err != nil {
4088+
ErrorResponse(w, http.StatusBadRequest, err.Error())
4089+
return
4090+
}
4091+
settings.OpenBazaarName = profile.Name
40864092
notifier := smtpNotifier{&settings}
40874093
err = notifier.notify(repo.TestNotification{})
40884094
if err != nil {

api/notifier.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ func (m *notificationManager) getNotifiers() []notifier {
6868

6969
// SMTP notifier
7070
conf := settings.SMTPSettings
71+
72+
profile, err := m.node.GetProfile()
73+
if err != nil {
74+
return nil
75+
}
76+
conf.OpenBazaarName = profile.Name
77+
7178
if conf != nil && conf.Notifications {
7279
notifiers = append(notifiers, &smtpNotifier{settings: conf})
7380
}
@@ -85,15 +92,15 @@ func (notifier *smtpNotifier) notify(n repo.Notifier) error {
8592
"To: %s",
8693
"MIME-Version: 1.0",
8794
"Content-Type: text/html; charset=UTF-8",
88-
"Subject: [OpenBazaar] %s\r\n",
95+
"Subject: [OpenBazaar - %s] %s\r\n",
8996
"%s\r\n",
9097
}, "\r\n")
9198
head, body, ok := n.GetSMTPTitleAndBody()
9299
if !ok {
93100
return nil
94101
}
95102
conf := notifier.settings
96-
data := fmt.Sprintf(template, conf.SenderEmail, conf.RecipientEmail, head, body)
103+
data := fmt.Sprintf(template, conf.SenderEmail, conf.RecipientEmail, conf.OpenBazaarName, head, body)
97104
return sendEmail(notifier.settings, []byte(data))
98105
}
99106

repo/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type SMTPSettings struct {
4040
Password string `json:"password"`
4141
SenderEmail string `json:"senderEmail"`
4242
RecipientEmail string `json:"recipientEmail"`
43+
OpenBazaarName string `json:"openBazaarName"`
4344
}
4445

4546
type Follower struct {

0 commit comments

Comments
 (0)