From 4a36e5a3dcd94608dc71521a29e216c377fef47d Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Thu, 14 Jan 2021 11:21:08 -0500 Subject: [PATCH] Don't pass redis pool or FCM client to ApplyModifiers which shouldn't ever send messages --- core/models/events.go | 4 ++-- core/models/imports.go | 2 +- web/contact/contact.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/models/events.go b/core/models/events.go index 94d780620..c31baddbd 100644 --- a/core/models/events.go +++ b/core/models/events.go @@ -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()) @@ -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") } diff --git a/core/models/imports.go b/core/models/imports.go index 2d979e390..d8cb955cc 100644 --- a/core/models/imports.go +++ b/core/models/imports.go @@ -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") } diff --git a/web/contact/contact.go b/web/contact/contact.go index 80284c515..c604c9563 100644 --- a/web/contact/contact.go +++ b/web/contact/contact.go @@ -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") } @@ -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 }