Skip to content

Commit 894d284

Browse files
committed
Fix GET subscribers not filtering by list permissions. Closes #2129.
1 parent 8b213f0 commit 894d284

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

cmd/subscribers.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,18 @@ func filterListQeryByPerm(qp url.Values, user models.User, app *App) ([]int, err
706706
}
707707

708708
listIDs = user.FilterListsByPerm(ids, true, true)
709-
} else {
710-
// There are no incoming params. If the user doesn't have permission to get all subscribers,
711-
// filter by the lists they have access to.
709+
}
710+
711+
// There are no incoming params. If the user doesn't have permission to get all subscribers,
712+
// filter by the lists they have access to.
713+
if len(listIDs) == 0 {
712714
if _, ok := user.PermissionsMap[models.PermSubscribersGetAll]; !ok {
713-
listIDs = user.GetListIDs
715+
if len(user.GetListIDs) > 0 {
716+
listIDs = user.GetListIDs
717+
} else {
718+
// User doesn't have access to any lists.
719+
listIDs = []int{-1}
720+
}
714721
}
715722
}
716723

internal/core/subscribers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (c *Core) QuerySubscribers(query string, listIDs []int, subStatus string, o
120120
}
121121

122122
// Run the query again and fetch the actual data. stmt is the raw SQL query.
123-
var out models.Subscribers
123+
out := models.Subscribers{}
124124
stmt := fmt.Sprintf(c.q.QuerySubscribersCount, cond)
125125
stmt = strings.ReplaceAll(c.q.QuerySubscribers, "%query%", cond)
126126
stmt = strings.ReplaceAll(stmt, "%order%", orderBy+" "+order)

0 commit comments

Comments
 (0)