mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-17 03:00:13 +00:00
fix: name privacy respected when searching
This commit is contained in:
parent
86883db9f8
commit
8955d7c779
2 changed files with 11 additions and 2 deletions
|
|
@ -60,7 +60,8 @@ public static class DatabaseViewsExt
|
|||
static string Filter(string column) =>
|
||||
$"(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)
|
||||
{
|
||||
// We need to account for the possibility of description privacy when searching
|
||||
|
|
|
|||
|
|
@ -30,7 +30,15 @@ select members.*,
|
|||
-- Privacy '1' = public; just return description as normal
|
||||
when members.description_privacy = 1 then members.description
|
||||
-- Any other privacy (rn just '2'), return null description (missing case = null in SQL)
|
||||
end as public_description
|
||||
end as public_description,
|
||||
|
||||
-- Extract member name as seen by "the public"
|
||||
case
|
||||
-- Privacy '1' = public; just return name as normal
|
||||
when members.name_privacy = 1 then members.name
|
||||
-- Any other privacy (rn just '2'), return display name
|
||||
else members.display_name
|
||||
end as public_name
|
||||
from members;
|
||||
|
||||
create view group_list as
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue