From 1164afac5e9cc069add81a45390f84985712336f Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 6 Aug 2023 21:09:16 +0530 Subject: [PATCH] Fix private lists being unsubscribed from public form and re-factor subscription status view in admin. --- cmd/public.go | 14 +++++++++----- frontend/src/assets/style.scss | 9 +++++++-- frontend/src/views/SubscriberForm.vue | 10 ++++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/cmd/public.go b/cmd/public.go index 044e0aa..7816ca3 100644 --- a/cmd/public.go +++ b/cmd/public.go @@ -302,18 +302,22 @@ func handleSubscriptionPrefs(c echo.Context) error { // Get the subscriber's lists and whatever is not sent in the request (unchecked), // unsubscribe them. - subs, err := app.core.GetSubscriptions(0, subUUID, false) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, app.i18n.T("public.errorFetchingLists")) - } reqUUIDs := make(map[string]struct{}) for _, u := range req.ListUUIDs { reqUUIDs[u] = struct{}{} } + subs, err := app.core.GetSubscriptions(0, subUUID, false) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, app.i18n.T("public.errorFetchingLists")) + } + unsubUUIDs := make([]string, 0, len(req.ListUUIDs)) for _, s := range subs { - if _, ok := reqUUIDs[s.UUID]; ok { + if s.Type == models.ListTypePrivate { + continue + } + if _, ok := reqUUIDs[s.UUID]; !ok { unsubUUIDs = append(unsubUUIDs, s.UUID) } } diff --git a/frontend/src/assets/style.scss b/frontend/src/assets/style.scss index c2f5641..7f1e8cf 100644 --- a/frontend/src/assets/style.scss +++ b/frontend/src/assets/style.scss @@ -560,14 +560,14 @@ body.is-noscroll { border: 1px solid lighten($color, 42%); box-shadow: 1px 1px 0 lighten($color, 42%); } - &.finished, &.enabled { + &.finished, &.enabled, &.status-confirmed { $color: $green; color: $color; background: #f6ffed; border: 1px solid lighten($color, 45%); box-shadow: 1px 1px 0 lighten($color, 45%); } - &.blocklisted, &.cancelled { + &.blocklisted, &.cancelled, &.status-unsubscribed { $color: $red; color: $color; background: #fff1f0; @@ -591,6 +591,7 @@ body.is-noscroll { } } + /* Page header */ .page-header { .buttons { @@ -675,6 +676,10 @@ section.lists { thead th, tbody td { padding: 10px; } + + td.status .tag { + width: 100%; + } } .bounces { diff --git a/frontend/src/views/SubscriberForm.vue b/frontend/src/views/SubscriberForm.vue index 4f19cc2..025b25c 100644 --- a/frontend/src/views/SubscriberForm.vue +++ b/frontend/src/views/SubscriberForm.vue @@ -94,17 +94,23 @@ {{ ' ' }} - - {{ props.row.optin === 'double' ? props.row.subscriptionStatus : '-' }} + + + + {{ $t(`subscribers.status.${props.row.subscriptionStatus}`) }} + + {{ $utils.niceDate(props.row.subscriptionCreatedAt, true) }} + {{ $utils.niceDate(props.row.subscriptionCreatedAt, true) }}