Cleanup unnecessary pointers

This commit is contained in:
Kailash Nadh 2020-03-08 11:07:24 +05:30
parent ac2145de89
commit 5f6a4af6b4
4 changed files with 12 additions and 12 deletions

View File

@ -180,7 +180,7 @@ func handlePreviewCampaign(c echo.Context) error {
}
// Render the message body.
m := app.manager.NewMessage(camp, &sub)
m := app.manager.NewMessage(camp, sub)
if err := m.Render(); err != nil {
app.log.Printf("error rendering message: %v", err)
return echo.NewHTTPError(http.StatusBadRequest,
@ -538,7 +538,7 @@ func handleTestCampaign(c echo.Context) error {
// Send the test messages.
for _, s := range subs {
sub := s
if err := sendTestMessage(&sub, &camp, app); err != nil {
if err := sendTestMessage(sub, &camp, app); err != nil {
return echo.NewHTTPError(http.StatusBadRequest,
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.
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 {
app.log.Printf("error compiling template: %v", err)
return fmt.Errorf("Error compiling template: %v", err)

View File

@ -27,7 +27,7 @@ const (
// that provides subscriber and campaign records.
type DataSource interface {
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)
UpdateCampaignStatus(campID int, status string) error
CreateLink(url string) (string, error)
@ -52,7 +52,7 @@ type Manager struct {
linksMutex sync.RWMutex
subFetchQueue chan *models.Campaign
msgQueue chan *Message
msgQueue chan Message
msgErrorQueue chan msgError
msgErrorCounts map[int]int
}
@ -60,7 +60,7 @@ type Manager struct {
// Message represents an active subscriber that's being processed.
type Message struct {
Campaign *models.Campaign
Subscriber *models.Subscriber
Subscriber models.Subscriber
Body []byte
from string
@ -96,7 +96,7 @@ func New(cfg Config, src DataSource, notifCB models.AdminNotifCallback, l *log.L
camps: make(map[int]*models.Campaign),
links: make(map[string]string),
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),
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
// to message templates while they're compiled.
func (m *Manager) NewMessage(c *models.Campaign, s *models.Subscriber) *Message {
return &Message{
func (m *Manager) NewMessage(c *models.Campaign, s models.Subscriber) Message {
return Message{
Campaign: c,
Subscriber: s,

View File

@ -29,8 +29,8 @@ func (r *runnerDB) NextCampaigns(excludeIDs []int64) ([]*models.Campaign, error)
// 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
// batch above that.
func (r *runnerDB) NextSubscribers(campID, limit int) ([]*models.Subscriber, error) {
var out []*models.Subscriber
func (r *runnerDB) NextSubscribers(campID, limit int) ([]models.Subscriber, error) {
var out []models.Subscriber
err := r.queries.NextCampaignSubscribers.Select(&out, campID, limit)
return out, err
}

View File

@ -114,7 +114,7 @@ func handlePreviewTemplate(c echo.Context) error {
}
// Render the message body.
m := app.manager.NewMessage(&camp, &dummySubscriber)
m := app.manager.NewMessage(&camp, dummySubscriber)
if err := m.Render(); err != nil {
return echo.NewHTTPError(http.StatusBadRequest,
fmt.Sprintf("Error rendering message: %v", err))