Skip to content

Commit

Permalink
Fix preference management logic to avoid unnecessary DB calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Sep 25, 2023
1 parent 99c71a2 commit a61a9d8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions cmd/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit a61a9d8

Please sign in to comment.