mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-17 03:00:13 +00:00
fix: description privacy respected while searching
This commit is contained in:
parent
debfc46776
commit
86883db9f8
6 changed files with 13 additions and 8 deletions
|
|
@ -54,7 +54,7 @@ public class GroupMember
|
||||||
public async Task ListMemberGroups(Context ctx, PKMember target)
|
public async Task ListMemberGroups(Context ctx, PKMember target)
|
||||||
{
|
{
|
||||||
var targetSystem = await ctx.Repository.GetSystem(target.System);
|
var targetSystem = await ctx.Repository.GetSystem(target.System);
|
||||||
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(target.System));
|
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(target.System), ctx.LookupContextFor(target.System));
|
||||||
opts.MemberFilter = target.Id;
|
opts.MemberFilter = target.Id;
|
||||||
|
|
||||||
var title = new StringBuilder($"Groups containing {target.Name} (`{target.DisplayHid(ctx.Config)}`) in ");
|
var title = new StringBuilder($"Groups containing {target.Name} (`{target.DisplayHid(ctx.Config)}`) in ");
|
||||||
|
|
@ -129,7 +129,7 @@ public class GroupMember
|
||||||
var targetSystem = await GetGroupSystem(ctx, target);
|
var targetSystem = await GetGroupSystem(ctx, target);
|
||||||
ctx.CheckSystemPrivacy(targetSystem.Id, target.ListPrivacy);
|
ctx.CheckSystemPrivacy(targetSystem.Id, target.ListPrivacy);
|
||||||
|
|
||||||
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(target.System));
|
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(target.System), ctx.LookupContextFor(target.System));
|
||||||
opts.GroupFilter = target.Id;
|
opts.GroupFilter = target.Id;
|
||||||
|
|
||||||
var title = new StringBuilder($"Members of {target.DisplayName ?? target.Name} (`{target.DisplayHid(ctx.Config)}`) in ");
|
var title = new StringBuilder($"Members of {target.DisplayName ?? target.Name} (`{target.DisplayHid(ctx.Config)}`) in ");
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,7 @@ public class Groups
|
||||||
// - ParseListOptions checks list access privacy and sets the privacy filter (which members show up in list)
|
// - ParseListOptions checks list access privacy and sets the privacy filter (which members show up in list)
|
||||||
// - RenderGroupList checks the indivual privacy for each member (NameFor, etc)
|
// - RenderGroupList checks the indivual privacy for each member (NameFor, etc)
|
||||||
// the own system is always allowed to look up their list
|
// the own system is always allowed to look up their list
|
||||||
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(system.Id));
|
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(system.Id), ctx.LookupContextFor(system.Id));
|
||||||
await ctx.RenderGroupList(
|
await ctx.RenderGroupList(
|
||||||
ctx.LookupContextFor(system.Id),
|
ctx.LookupContextFor(system.Id),
|
||||||
system.Id,
|
system.Id,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace PluralKit.Bot;
|
||||||
|
|
||||||
public static class ContextListExt
|
public static class ContextListExt
|
||||||
{
|
{
|
||||||
public static ListOptions ParseListOptions(this Context ctx, LookupContext lookupCtx)
|
public static ListOptions ParseListOptions(this Context ctx, LookupContext directLookupCtx, LookupContext lookupContext)
|
||||||
{
|
{
|
||||||
var p = new ListOptions();
|
var p = new ListOptions();
|
||||||
|
|
||||||
|
|
@ -55,10 +55,13 @@ public static class ContextListExt
|
||||||
if (ctx.MatchFlag("private-only", "po")) p.PrivacyFilter = PrivacyLevel.Private;
|
if (ctx.MatchFlag("private-only", "po")) p.PrivacyFilter = PrivacyLevel.Private;
|
||||||
|
|
||||||
// PERM CHECK: If we're trying to access non-public members of another system, error
|
// PERM CHECK: If we're trying to access non-public members of another system, error
|
||||||
if (p.PrivacyFilter != PrivacyLevel.Public && lookupCtx != LookupContext.ByOwner)
|
if (p.PrivacyFilter != PrivacyLevel.Public && directLookupCtx != LookupContext.ByOwner)
|
||||||
// TODO: should this just return null instead of throwing or something? >.>
|
// TODO: should this just return null instead of throwing or something? >.>
|
||||||
throw Errors.NotOwnInfo;
|
throw Errors.NotOwnInfo;
|
||||||
|
|
||||||
|
//this is for searching
|
||||||
|
p.Context = lookupContext;
|
||||||
|
|
||||||
// Additional fields to include in the search results
|
// Additional fields to include in the search results
|
||||||
if (ctx.MatchFlag("with-last-switch", "with-last-fronted", "with-last-front", "wls", "wlf"))
|
if (ctx.MatchFlag("with-last-switch", "with-last-fronted", "with-last-front", "wls", "wlf"))
|
||||||
p.IncludeLastSwitch = true;
|
p.IncludeLastSwitch = true;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public class ListOptions
|
||||||
public bool Reverse { get; set; }
|
public bool Reverse { get; set; }
|
||||||
|
|
||||||
public PrivacyLevel? PrivacyFilter { get; set; } = PrivacyLevel.Public;
|
public PrivacyLevel? PrivacyFilter { get; set; } = PrivacyLevel.Public;
|
||||||
|
public LookupContext Context { get; set; } = LookupContext.ByNonOwner;
|
||||||
public GroupId? GroupFilter { get; set; }
|
public GroupId? GroupFilter { get; set; }
|
||||||
public MemberId? MemberFilter { get; set; }
|
public MemberId? MemberFilter { get; set; }
|
||||||
public string? Search { get; set; }
|
public string? Search { get; set; }
|
||||||
|
|
@ -99,7 +100,8 @@ public class ListOptions
|
||||||
GroupFilter = GroupFilter,
|
GroupFilter = GroupFilter,
|
||||||
MemberFilter = MemberFilter,
|
MemberFilter = MemberFilter,
|
||||||
Search = Search,
|
Search = Search,
|
||||||
SearchDescription = SearchDescription
|
SearchDescription = SearchDescription,
|
||||||
|
Context = Context
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public class Random
|
||||||
{
|
{
|
||||||
ctx.CheckSystemPrivacy(group.System, group.ListPrivacy);
|
ctx.CheckSystemPrivacy(group.System, group.ListPrivacy);
|
||||||
|
|
||||||
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(group.System));
|
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(group.System), ctx.LookupContextFor(group.System));
|
||||||
opts.GroupFilter = group.Id;
|
opts.GroupFilter = group.Id;
|
||||||
|
|
||||||
var members = await ctx.Database.Execute(conn => conn.QueryMemberList(group.System, opts.ToQueryOptions()));
|
var members = await ctx.Database.Execute(conn => conn.QueryMemberList(group.System, opts.ToQueryOptions()));
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public class SystemList
|
||||||
// - ParseListOptions checks list access privacy and sets the privacy filter (which members show up in list)
|
// - ParseListOptions checks list access privacy and sets the privacy filter (which members show up in list)
|
||||||
// - RenderMemberList checks the indivual privacy for each member (NameFor, etc)
|
// - RenderMemberList checks the indivual privacy for each member (NameFor, etc)
|
||||||
// the own system is always allowed to look up their list
|
// the own system is always allowed to look up their list
|
||||||
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(target.Id));
|
var opts = ctx.ParseListOptions(ctx.DirectLookupContextFor(target.Id), ctx.LookupContextFor(target.Id));
|
||||||
await ctx.RenderMemberList(
|
await ctx.RenderMemberList(
|
||||||
ctx.LookupContextFor(target.Id),
|
ctx.LookupContextFor(target.Id),
|
||||||
target.Id,
|
target.Id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue