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.