mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-17 03:00:13 +00:00
fix: respect group name/desc privacy in list searching
This commit is contained in:
parent
8955d7c779
commit
0aec492352
2 changed files with 18 additions and 2 deletions
|
|
@ -24,7 +24,8 @@ public static class DatabaseViewsExt
|
||||||
static string Filter(string column) =>
|
static string Filter(string column) =>
|
||||||
$"(position(lower(@filter) in lower(coalesce({column}, ''))) > 0)";
|
$"(position(lower(@filter) in lower(coalesce({column}, ''))) > 0)";
|
||||||
|
|
||||||
query.Append($" and ({Filter("name")} or {Filter("display_name")}");
|
var nameColumn = opts.Context == LookupContext.ByOwner ? "name" : "public_name";
|
||||||
|
query.Append($" and ({Filter(nameColumn)} or {Filter("display_name")}");
|
||||||
if (opts.SearchDescription)
|
if (opts.SearchDescription)
|
||||||
{
|
{
|
||||||
// We need to account for the possibility of description privacy when searching
|
// We need to account for the possibility of description privacy when searching
|
||||||
|
|
|
||||||
|
|
@ -56,5 +56,20 @@ select groups.*,
|
||||||
inner join members on group_members.member_id = members.id
|
inner join members on group_members.member_id = members.id
|
||||||
where
|
where
|
||||||
group_members.group_id = groups.id
|
group_members.group_id = groups.id
|
||||||
) as total_member_count
|
) as total_member_count,
|
||||||
|
|
||||||
|
-- Extract group description as seen by "the public"
|
||||||
|
case
|
||||||
|
-- Privacy '1' = public; just return description as normal
|
||||||
|
when groups.description_privacy = 1 then groups.description
|
||||||
|
-- Any other privacy (rn just '2'), return null description (missing case = null in SQL)
|
||||||
|
end as public_description,
|
||||||
|
|
||||||
|
-- Extract member name as seen by "the public"
|
||||||
|
case
|
||||||
|
-- Privacy '1' = public; just return name as normal
|
||||||
|
when groups.name_privacy = 1 then groups.name
|
||||||
|
-- Any other privacy (rn just '2'), return display name
|
||||||
|
else groups.display_name
|
||||||
|
end as public_name
|
||||||
from groups;
|
from groups;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue