From 959541f8eeab12a512dbbe9d8ed2cc56b7f2fda2 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 8 May 2022 14:45:45 +0530 Subject: [PATCH] Rename unsub query to match the `core` method name. --- internal/core/subscribers.go | 2 +- models/queries.go | 2 +- queries.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/core/subscribers.go b/internal/core/subscribers.go index dcb4b23..5c1a867 100644 --- a/internal/core/subscribers.go +++ b/internal/core/subscribers.go @@ -399,7 +399,7 @@ func (c *Core) DeleteSubscribersByQuery(query string, listIDs []int) error { // UnsubscribeByCampaign unsubscibers a given subscriber from lists in a given campaign. func (c *Core) UnsubscribeByCampaign(subUUID, campUUID string, blocklist bool) error { - if _, err := c.q.Unsubscribe.Exec(campUUID, subUUID, blocklist); err != nil { + if _, err := c.q.UnsubscribeByCampaign.Exec(campUUID, subUUID, blocklist); err != nil { c.log.Printf("error unsubscribing: %v", err) return echo.NewHTTPError(http.StatusInternalServerError, c.i18n.Ts("globals.messages.errorUpdating", "name", "{globals.terms.subscribers}", "error", pqErrMsg(err))) diff --git a/models/queries.go b/models/queries.go index ee4bef8..501d980 100644 --- a/models/queries.go +++ b/models/queries.go @@ -28,7 +28,7 @@ type Queries struct { ConfirmSubscriptionOptin *sqlx.Stmt `query:"confirm-subscription-optin"` UnsubscribeSubscribersFromLists *sqlx.Stmt `query:"unsubscribe-subscribers-from-lists"` DeleteSubscribers *sqlx.Stmt `query:"delete-subscribers"` - Unsubscribe *sqlx.Stmt `query:"unsubscribe"` + UnsubscribeByCampaign *sqlx.Stmt `query:"unsubscribe-by-campaign"` ExportSubscriberData *sqlx.Stmt `query:"export-subscriber-data"` // Non-prepared arbitrary subscriber queries. diff --git a/queries.sql b/queries.sql index 3646a7b..c79a244 100644 --- a/queries.sql +++ b/queries.sql @@ -174,7 +174,7 @@ UPDATE subscriber_lists SET status='confirmed', updated_at=NOW() UPDATE subscriber_lists SET status='unsubscribed', updated_at=NOW() WHERE (subscriber_id, list_id) = ANY(SELECT a, b FROM UNNEST($1::INT[]) a, UNNEST($2::INT[]) b); --- name: unsubscribe +-- name: unsubscribe-by-campaign -- Unsubscribes a subscriber given a campaign UUID (from all the lists in the campaign) and the subscriber UUID. -- If $3 is TRUE, then all subscriptions of the subscriber is blocklisted -- and all existing subscriptions, irrespective of lists, unsubscribed.