Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix preconfirm option not working on bulk 'select all' subscriber list management. Closes #1646.

Kailash Nadhbce675870c66
diff --git a/cmd/subscribers.go b/cmd/subscribers.go
index 087f3b54..3cfd3851 100644
--- a/cmd/subscribers.go
+++ b/cmd/subscribers.go
@@ -458,7 +458,7 @@ func handleManageSubscriberListsByQuery(c echo.Context) error {
var err error
switch req.Action {
case "add":
- err = app.core.AddSubscriptionsByQuery(req.Query, req.ListIDs, req.TargetListIDs)
+ err = app.core.AddSubscriptionsByQuery(req.Query, req.ListIDs, req.TargetListIDs, req.Status)
case "remove":
err = app.core.DeleteSubscriptionsByQuery(req.Query, req.ListIDs, req.TargetListIDs)
case "unsubscribe":
diff --git a/i18n/it.json b/i18n/it.json
index 9ad0d30f..ff7f8445 100644
--- a/i18n/it.json
+++ b/i18n/it.json
@@ -577,4 +577,4 @@
"templates.subject": "Oggetto",
"users.login": "Accesso",
"users.logout": "Esci"
-}
\ No newline at end of file
+}
diff --git a/internal/core/subscriptions.go b/internal/core/subscriptions.go
index fa8f127d..c5a78a90 100644
--- a/internal/core/subscriptions.go
+++ b/internal/core/subscriptions.go
@@ -35,12 +35,12 @@ func (c *Core) AddSubscriptions(subIDs, listIDs []int, status string) error {
// AddSubscriptionsByQuery adds list subscriptions to subscribers by a given arbitrary query expression.
// sourceListIDs is the list of list IDs to filter the subscriber query with.
-func (c *Core) AddSubscriptionsByQuery(query string, sourceListIDs, targetListIDs []int) error {
+func (c *Core) AddSubscriptionsByQuery(query string, sourceListIDs, targetListIDs []int, status string) error {
if sourceListIDs == nil {
sourceListIDs = []int{}
}
- err := c.q.ExecSubQueryTpl(sanitizeSQLExp(query), c.q.AddSubscribersToListsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs))
+ err := c.q.ExecSubQueryTpl(sanitizeSQLExp(query), c.q.AddSubscribersToListsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs), status)
if err != nil {
c.log.Printf("error adding subscriptions by query: %v", err)
return echo.NewHTTPError(http.StatusInternalServerError,
diff --git a/queries.sql b/queries.sql
index cad62233..557227c6 100644
--- a/queries.sql
+++ b/queries.sql
@@ -386,8 +386,8 @@ UPDATE subscriber_lists SET status='unsubscribed', updated_at=NOW()
-- name: add-subscribers-to-lists-by-query
-- raw: true
WITH subs AS (%s)
-INSERT INTO subscriber_lists (subscriber_id, list_id)
- (SELECT a, b FROM UNNEST(ARRAY(SELECT id FROM subs)) a, UNNEST($3::INT[]) b)
+INSERT INTO subscriber_lists (subscriber_id, list_id, status)
+ (SELECT a, b, (CASE WHEN $4 != '' THEN $4::subscription_status ELSE 'unconfirmed' END) FROM UNNEST(ARRAY(SELECT id FROM subs)) a, UNNEST($3::INT[]) b)
ON CONFLICT (subscriber_id, list_id) DO NOTHING;
-- name: delete-subscriptions-by-query