Skip to content

Commit

Permalink
Fix private lists being unsubscribed from public form and re-factor s…
Browse files Browse the repository at this point in the history
…ubscription status view in admin.
  • Loading branch information
knadh committed Aug 6, 2023
1 parent eafae46 commit 1164afa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
14 changes: 9 additions & 5 deletions cmd/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/assets/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -591,6 +591,7 @@ body.is-noscroll {
}
}


/* Page header */
.page-header {
.buttons {
Expand Down Expand Up @@ -675,6 +676,10 @@ section.lists {
thead th, tbody td {
padding: 10px;
}

td.status .tag {
width: 100%;
}
}

.bounces {
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/views/SubscriberForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,23 @@
</b-tag>{{ ' ' }}
</div>
</b-table-column>
<b-table-column v-slot="props" field="status" :label="$t('globals.fields.status')">
{{ props.row.optin === 'double' ? props.row.subscriptionStatus : '-' }}

<b-table-column v-slot="props" field="status" cell-class="status"
:label="$t('globals.fields.status')">
<b-tag :class="`status-${props.row.subscriptionStatus}`">
{{ $t(`subscribers.status.${props.row.subscriptionStatus}`) }}
</b-tag>
<template v-if="props.row.optin === 'double'
&& props.row.subscriptionMeta.optinIp">
<br /><span class="is-size-7">{{ props.row.subscriptionMeta.optinIp }}</span>
</template>
</b-table-column>

<b-table-column v-slot="props" field="createdAt"
:label="$t('globals.fields.createdAt')">
{{ $utils.niceDate(props.row.subscriptionCreatedAt, true) }}
</b-table-column>

<b-table-column v-slot="props" field="updatedAt"
:label="$t('globals.fields.updatedAt')">
{{ $utils.niceDate(props.row.subscriptionCreatedAt, true) }}
Expand Down

0 comments on commit 1164afa

Please sign in to comment.