Skip to content

Commit

Permalink
Don't pass redis pool or FCM client to ApplyModifiers which shouldn't…
Browse files Browse the repository at this point in the history
… ever send messages
  • Loading branch information
rowanseymour committed Jan 14, 2021
1 parent b7a2edb commit 4a36e5a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/models/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func HandleAndCommitEvents(ctx context.Context, db QueryerWithTx, rp *redis.Pool
}

// ApplyModifiers modifies contacts by applying modifiers and handling the resultant events
func ApplyModifiers(ctx context.Context, db QueryerWithTx, rp *redis.Pool, fc *fcm.Client, oa *OrgAssets, modifiersByContact map[*flows.Contact][]flows.Modifier) (map[*flows.Contact][]flows.Event, error) {
func ApplyModifiers(ctx context.Context, db QueryerWithTx, oa *OrgAssets, modifiersByContact map[*flows.Contact][]flows.Modifier) (map[*flows.Contact][]flows.Event, error) {
// create an environment instance with location support
env := flows.NewEnvironment(oa.Env(), oa.SessionAssets().Locations())

Expand All @@ -253,7 +253,7 @@ func ApplyModifiers(ctx context.Context, db QueryerWithTx, rp *redis.Pool, fc *f
eventsByContact[contact] = events
}

err := HandleAndCommitEvents(ctx, db, rp, fc, oa, eventsByContact)
err := HandleAndCommitEvents(ctx, db, nil, nil, oa, eventsByContact)
if err != nil {
return nil, errors.Wrap(err, "error commiting events")
}
Expand Down
2 changes: 1 addition & 1 deletion core/models/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (b *ContactImportBatch) tryImport(ctx context.Context, db *sqlx.DB, orgID O
}

// and apply in bulk
_, err = ApplyModifiers(ctx, db, nil, nil, oa, modifiersByContact)
_, err = ApplyModifiers(ctx, db, oa, modifiersByContact)
if err != nil {
return errors.Wrap(err, "error applying modifiers")
}
Expand Down
4 changes: 2 additions & 2 deletions web/contact/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func handleCreate(ctx context.Context, s *web.Server, r *http.Request) (interfac
}

modifiersByContact := map[*flows.Contact][]flows.Modifier{contact: c.Mods}
_, err = models.ApplyModifiers(ctx, s.DB, s.RP, s.FCMClient, oa, modifiersByContact)
_, err = models.ApplyModifiers(ctx, s.DB, oa, modifiersByContact)
if err != nil {
return nil, http.StatusInternalServerError, errors.Wrap(err, "error modifying new contact")
}
Expand Down Expand Up @@ -153,7 +153,7 @@ func handleModify(ctx context.Context, s *web.Server, r *http.Request) (interfac
modifiersByContact[flowContact] = mods
}

eventsByContact, err := models.ApplyModifiers(ctx, s.DB, s.RP, s.FCMClient, oa, modifiersByContact)
eventsByContact, err := models.ApplyModifiers(ctx, s.DB, oa, modifiersByContact)
if err != nil {
return nil, http.StatusBadRequest, err
}
Expand Down

0 comments on commit 4a36e5a

Please sign in to comment.