feat: don't hide information from own system when directly requested
in lists, pk;m <ref> <prop>, etc
This commit is contained in:
@@ -133,6 +133,12 @@ public class Context
|
||||
await Reply($"{Emojis.Warn} This command is deprecated and will be removed soon. In the future, please use `pk;{commandDef.Key}`.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Same as LookupContextFor, but skips flags / config checks.
|
||||
/// </summary>
|
||||
public LookupContext DirectLookupContextFor(SystemId systemId)
|
||||
=> System?.Id == systemId ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
|
||||
public LookupContext LookupContextFor(SystemId systemId)
|
||||
{
|
||||
var hasPrivateOverride = this.MatchFlag("private", "priv");
|
||||
|
@@ -21,10 +21,10 @@ public static class ContextChecksExt
|
||||
throw new PKError("This command must be run in a DM.");
|
||||
}
|
||||
|
||||
public static Context CheckSystemPrivacy(this Context ctx, PKSystem target, PrivacyLevel level)
|
||||
public static Context CheckSystemPrivacy(this Context ctx, SystemId target, PrivacyLevel level)
|
||||
{
|
||||
if (level.CanAccess(ctx.LookupContextFor(target.Id))) return ctx;
|
||||
throw target.Id == ctx.System?.Id ? Errors.LookupHidden : Errors.LookupNotAllowed;
|
||||
if (level.CanAccess(ctx.DirectLookupContextFor(target))) return ctx;
|
||||
throw Errors.LookupNotAllowed;
|
||||
}
|
||||
|
||||
public static Context CheckOwnSystem(this Context ctx, PKSystem system)
|
||||
|
Reference in New Issue
Block a user