mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-11 00:07:55 +00:00
fix(bot): respect member/group name/desc privacy in search
This commit is contained in:
parent
42235cef9c
commit
5f644ab17a
8 changed files with 42 additions and 12 deletions
|
|
@ -11,7 +11,7 @@ namespace PluralKit.Bot;
|
|||
|
||||
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();
|
||||
|
||||
|
|
@ -55,10 +55,13 @@ public static class ContextListExt
|
|||
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
|
||||
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? >.>
|
||||
throw Errors.NotOwnInfo;
|
||||
|
||||
//this is for searching
|
||||
p.Context = lookupContext;
|
||||
|
||||
// Additional fields to include in the search results
|
||||
if (ctx.MatchFlag("with-last-switch", "with-last-fronted", "with-last-front", "wls", "wlf"))
|
||||
p.IncludeLastSwitch = true;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class ListOptions
|
|||
public bool Reverse { get; set; }
|
||||
|
||||
public PrivacyLevel? PrivacyFilter { get; set; } = PrivacyLevel.Public;
|
||||
public LookupContext Context { get; set; } = LookupContext.ByNonOwner;
|
||||
public GroupId? GroupFilter { get; set; }
|
||||
public MemberId? MemberFilter { get; set; }
|
||||
public string? Search { get; set; }
|
||||
|
|
@ -99,7 +100,8 @@ public class ListOptions
|
|||
GroupFilter = GroupFilter,
|
||||
MemberFilter = MemberFilter,
|
||||
Search = Search,
|
||||
SearchDescription = SearchDescription
|
||||
SearchDescription = SearchDescription,
|
||||
Context = Context
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue