Cleanup unnecessary pointers
This commit is contained in:
parent
ac2145de89
commit
5f6a4af6b4
|
@ -180,7 +180,7 @@ func handlePreviewCampaign(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the message body.
|
// Render the message body.
|
||||||
m := app.manager.NewMessage(camp, &sub)
|
m := app.manager.NewMessage(camp, sub)
|
||||||
if err := m.Render(); err != nil {
|
if err := m.Render(); err != nil {
|
||||||
app.log.Printf("error rendering message: %v", err)
|
app.log.Printf("error rendering message: %v", err)
|
||||||
return echo.NewHTTPError(http.StatusBadRequest,
|
return echo.NewHTTPError(http.StatusBadRequest,
|
||||||
|
@ -538,7 +538,7 @@ func handleTestCampaign(c echo.Context) error {
|
||||||
// Send the test messages.
|
// Send the test messages.
|
||||||
for _, s := range subs {
|
for _, s := range subs {
|
||||||
sub := s
|
sub := s
|
||||||
if err := sendTestMessage(&sub, &camp, app); err != nil {
|
if err := sendTestMessage(sub, &camp, app); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest,
|
return echo.NewHTTPError(http.StatusBadRequest,
|
||||||
fmt.Sprintf("Error sending test: %v", err))
|
fmt.Sprintf("Error sending test: %v", err))
|
||||||
}
|
}
|
||||||
|
@ -548,7 +548,7 @@ func handleTestCampaign(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendTestMessage takes a campaign and a subsriber and sends out a sample campaign message.
|
// sendTestMessage takes a campaign and a subsriber and sends out a sample campaign message.
|
||||||
func sendTestMessage(sub *models.Subscriber, camp *models.Campaign, app *App) error {
|
func sendTestMessage(sub models.Subscriber, camp *models.Campaign, app *App) error {
|
||||||
if err := camp.CompileTemplate(app.manager.TemplateFuncs(camp)); err != nil {
|
if err := camp.CompileTemplate(app.manager.TemplateFuncs(camp)); err != nil {
|
||||||
app.log.Printf("error compiling template: %v", err)
|
app.log.Printf("error compiling template: %v", err)
|
||||||
return fmt.Errorf("Error compiling template: %v", err)
|
return fmt.Errorf("Error compiling template: %v", err)
|
||||||
|
|
|
@ -27,7 +27,7 @@ const (
|
||||||
// that provides subscriber and campaign records.
|
// that provides subscriber and campaign records.
|
||||||
type DataSource interface {
|
type DataSource interface {
|
||||||
NextCampaigns(excludeIDs []int64) ([]*models.Campaign, error)
|
NextCampaigns(excludeIDs []int64) ([]*models.Campaign, error)
|
||||||
NextSubscribers(campID, limit int) ([]*models.Subscriber, error)
|
NextSubscribers(campID, limit int) ([]models.Subscriber, error)
|
||||||
GetCampaign(campID int) (*models.Campaign, error)
|
GetCampaign(campID int) (*models.Campaign, error)
|
||||||
UpdateCampaignStatus(campID int, status string) error
|
UpdateCampaignStatus(campID int, status string) error
|
||||||
CreateLink(url string) (string, error)
|
CreateLink(url string) (string, error)
|
||||||
|
@ -52,7 +52,7 @@ type Manager struct {
|
||||||
linksMutex sync.RWMutex
|
linksMutex sync.RWMutex
|
||||||
|
|
||||||
subFetchQueue chan *models.Campaign
|
subFetchQueue chan *models.Campaign
|
||||||
msgQueue chan *Message
|
msgQueue chan Message
|
||||||
msgErrorQueue chan msgError
|
msgErrorQueue chan msgError
|
||||||
msgErrorCounts map[int]int
|
msgErrorCounts map[int]int
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ type Manager struct {
|
||||||
// Message represents an active subscriber that's being processed.
|
// Message represents an active subscriber that's being processed.
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Campaign *models.Campaign
|
Campaign *models.Campaign
|
||||||
Subscriber *models.Subscriber
|
Subscriber models.Subscriber
|
||||||
Body []byte
|
Body []byte
|
||||||
|
|
||||||
from string
|
from string
|
||||||
|
@ -96,7 +96,7 @@ func New(cfg Config, src DataSource, notifCB models.AdminNotifCallback, l *log.L
|
||||||
camps: make(map[int]*models.Campaign),
|
camps: make(map[int]*models.Campaign),
|
||||||
links: make(map[string]string),
|
links: make(map[string]string),
|
||||||
subFetchQueue: make(chan *models.Campaign, cfg.Concurrency),
|
subFetchQueue: make(chan *models.Campaign, cfg.Concurrency),
|
||||||
msgQueue: make(chan *Message, cfg.Concurrency),
|
msgQueue: make(chan Message, cfg.Concurrency),
|
||||||
msgErrorQueue: make(chan msgError, cfg.MaxSendErrors),
|
msgErrorQueue: make(chan msgError, cfg.MaxSendErrors),
|
||||||
msgErrorCounts: make(map[int]int),
|
msgErrorCounts: make(map[int]int),
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ func New(cfg Config, src DataSource, notifCB models.AdminNotifCallback, l *log.L
|
||||||
|
|
||||||
// NewMessage creates and returns a Message that is made available
|
// NewMessage creates and returns a Message that is made available
|
||||||
// to message templates while they're compiled.
|
// to message templates while they're compiled.
|
||||||
func (m *Manager) NewMessage(c *models.Campaign, s *models.Subscriber) *Message {
|
func (m *Manager) NewMessage(c *models.Campaign, s models.Subscriber) Message {
|
||||||
return &Message{
|
return Message{
|
||||||
Campaign: c,
|
Campaign: c,
|
||||||
Subscriber: s,
|
Subscriber: s,
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ func (r *runnerDB) NextCampaigns(excludeIDs []int64) ([]*models.Campaign, error)
|
||||||
// Since batches are processed sequentially, the retrieval is ordered by ID,
|
// Since batches are processed sequentially, the retrieval is ordered by ID,
|
||||||
// and every batch takes the last ID of the last batch and fetches the next
|
// and every batch takes the last ID of the last batch and fetches the next
|
||||||
// batch above that.
|
// batch above that.
|
||||||
func (r *runnerDB) NextSubscribers(campID, limit int) ([]*models.Subscriber, error) {
|
func (r *runnerDB) NextSubscribers(campID, limit int) ([]models.Subscriber, error) {
|
||||||
var out []*models.Subscriber
|
var out []models.Subscriber
|
||||||
err := r.queries.NextCampaignSubscribers.Select(&out, campID, limit)
|
err := r.queries.NextCampaignSubscribers.Select(&out, campID, limit)
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ func handlePreviewTemplate(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the message body.
|
// Render the message body.
|
||||||
m := app.manager.NewMessage(&camp, &dummySubscriber)
|
m := app.manager.NewMessage(&camp, dummySubscriber)
|
||||||
if err := m.Render(); err != nil {
|
if err := m.Render(); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest,
|
return echo.NewHTTPError(http.StatusBadRequest,
|
||||||
fmt.Sprintf("Error rendering message: %v", err))
|
fmt.Sprintf("Error rendering message: %v", err))
|
||||||
|
|
Loading…
Reference in New Issue