Skip to content

Commit

Permalink
update default settings
Browse files Browse the repository at this point in the history
pankajsoni19 committed Jan 21, 2025
1 parent e57589d commit ced3bfa
Showing 6 changed files with 20 additions and 28 deletions.
1 change: 1 addition & 0 deletions cmd/notifications.go
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ func (app *App) sendNotification(toEmails []string, subject, tplName string, dat
m.Body = body
m.From = app.defaultMessenger.From()
m.Messenger = app.defaultMessenger.UUID()

if err := app.manager.PushMessage(m); err != nil {
app.log.Printf("error sending admin notification (%s): %v", subject, err)
return err
6 changes: 3 additions & 3 deletions cmd/tx.go
Original file line number Diff line number Diff line change
@@ -136,14 +136,14 @@ func handleSendTxMessage(c echo.Context) error {

// Prepare the final message.
msg := models.Message{}

msg.Subscriber = sub
msg.To = []string{sub.Email}
msg.Subject = m.Subject
msg.ContentType = m.ContentType

msg.Messenger = messenger.UUID()

msg.From = from
msg.Messenger = messenger.UUID()

msg.Body = m.Body
for _, a := range m.Attachments {
9 changes: 4 additions & 5 deletions internal/balancer/balancer.go
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ func NewBalance() *Balance {

func (b *Balance) addWFrom(from string, weight int) *Balance {
b.items = append(b.items, &item{
id: from,
id: from,
weight: weight,
})

@@ -103,9 +103,9 @@ func (b *Balance) Add(messenger *models.CampaignMessenger) *Balance {
}

item := &item{
id: messenger.UUID,
weight: messenger.Weight,
current: 0,
id: messenger.UUID,
weight: messenger.Weight,
current: 0,
balancer: addWeightedFrom(messenger),
}

@@ -172,4 +172,3 @@ func (b *Balance) get() *item {

return max
}

14 changes: 5 additions & 9 deletions internal/manager/manager.go
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ type CampaignMessage struct {
Campaign *models.Campaign
Subscriber models.Subscriber

from string
from string
to string
subject string
body []byte
@@ -141,11 +141,6 @@ type Config struct {
ScanCampaigns bool
}

type msgError struct {
st *pipe
err error
}

var pushTimeout = time.Second * 3

// New returns a new instance of Mailer.
@@ -245,16 +240,16 @@ func (m *Manager) PushCampaignMessage(msg CampaignMessage) error {

if msg.Campaign.TrafficType == models.CampaignTrafficTypeSplit {
wmf := balancer.GetMF()

msg.from = wmf.From
msg.messenger = wmf.UUID

m.campMsgQ <- msg
} else {
for _, wmf := range balancer.All() {
msg.from = wmf.From
msg.messenger = wmf.UUID

m.campMsgQ <- msg
}
}
@@ -552,6 +547,7 @@ func (m *Manager) worker() {

// Outgoing message.
out := models.Message{
From: msg.from,
To: []string{msg.to},
Subject: msg.subject,
ContentType: msg.Campaign.ContentType,
9 changes: 3 additions & 6 deletions internal/messenger/email/email.go
Original file line number Diff line number Diff line change
@@ -17,10 +17,9 @@ const (
hdrCc = "Cc"
)



// Server represents an SMTP server's credentials.
type Server struct {
From string `json:"from"`
UUID string `json:"uuid"`
Name string `json:"name"`
Username string `json:"username"`
@@ -30,7 +29,6 @@ type Server struct {
TLSSkipVerify bool `json:"tls_skip_verify"`
EmailHeaders map[string]string `json:"email_headers"`
Default bool `json:"default"`
From string `json:"from"`

// Rest of the options are embedded directly from the smtppool lib.
// The JSON tag is for config unmarshal to work.
@@ -41,7 +39,7 @@ type Server struct {

// Emailer is the SMTP e-mail messenger.
type Emailer struct {
server *Server
server *Server
}

// New returns an SMTP e-mail Messenger backend with the given SMTP servers.
@@ -81,7 +79,7 @@ func New(s Server) (*Emailer, error) {
s.pool = pool

e := &Emailer{
server: &s,
server: &s,
}

return e, nil
@@ -188,6 +186,5 @@ func (e *Emailer) Flush() error {
// Close closes the SMTP pools.
func (e *Emailer) Close() error {
e.server.pool.Close()

return nil
}
9 changes: 4 additions & 5 deletions internal/messenger/postback/postback.go
Original file line number Diff line number Diff line change
@@ -58,14 +58,14 @@ type Options struct {
MaxConns int `json:"max_conns"`
Retries int `json:"retries"`
Timeout time.Duration `json:"timeout"`
From string `json:"from"`
From string `json:"from"`
}

// Postback represents an HTTP Message server.
type Postback struct {
authStr string
o Options
c *http.Client
authStr string
o Options
c *http.Client
}

// New returns a new instance of the HTTP Postback messenger.
@@ -110,7 +110,6 @@ func (p *Postback) From() string {

// Push pushes a message to the server.
func (p *Postback) Push(m models.Message) error {

pb := postback{
FromEmail: m.From,
Subject: m.Subject,

0 comments on commit ced3bfa

Please sign in to comment.