Skip to content

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

Fix preference management logic to avoid unnecessary DB calls.

Kailash Nadha61a9d8c04b6
diff --git a/cmd/public.go b/cmd/public.go
index ff8e6dc5..019786ad 100644
--- a/cmd/public.go
+++ b/cmd/public.go
@@ -200,16 +200,6 @@ func handleSubscriptionPage(c echo.Context) error {
out.AllowWipe = app.constants.Privacy.AllowWipe
out.AllowPreferences = app.constants.Privacy.AllowPreferences
- if app.constants.Privacy.AllowPreferences {
- out.ShowManage = showManage
- }
-
- // Get the subscriber's lists.
- subs, err := app.core.GetSubscriptions(0, subUUID, false)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, app.i18n.T("public.errorFetchingLists"))
- }
-
s, err := app.core.GetSubscriber(0, subUUID, "")
if err != nil {
return c.Render(http.StatusInternalServerError, tplMessage,
@@ -222,8 +212,17 @@ func handleSubscriptionPage(c echo.Context) error {
makeMsgTpl(app.i18n.T("public.noSubTitle"), "", app.i18n.Ts("public.blocklisted")))
}
- // Filter out unrelated private lists.
- if showManage {
+ // Only show preference management if it's enabled in settings.
+ if app.constants.Privacy.AllowPreferences {
+ out.ShowManage = showManage
+ }
+ if out.ShowManage {
+ // Get the subscriber's lists.
+ subs, err := app.core.GetSubscriptions(0, subUUID, false)
+ if err != nil {
+ return echo.NewHTTPError(http.StatusBadRequest, app.i18n.T("public.errorFetchingLists"))
+ }
+
out.Subscriptions = make([]models.Subscription, 0, len(subs))
for _, s := range subs {
if s.Type == models.ListTypePrivate {