mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
feat: config setting to default show/hide private info
This commit is contained in:
parent
455830a2b5
commit
32bea51e18
14 changed files with 71 additions and 17 deletions
|
|
@ -141,7 +141,7 @@ public class Context
|
|||
if (hasPrivateOverride && hasPublicOverride)
|
||||
throw new PKError("Cannot match both public and private flags at the same time.");
|
||||
|
||||
if (System.Id != systemId)
|
||||
if (System?.Id != systemId)
|
||||
{
|
||||
if (hasPrivateOverride)
|
||||
throw Errors.NotOwnInfo;
|
||||
|
|
@ -153,8 +153,9 @@ public class Context
|
|||
if (hasPublicOverride)
|
||||
return LookupContext.ByNonOwner;
|
||||
|
||||
// todo: add config defaults
|
||||
return LookupContext.ByOwner;
|
||||
return Config.ShowPrivateInfo
|
||||
? LookupContext.ByOwner
|
||||
: LookupContext.ByNonOwner;
|
||||
}
|
||||
|
||||
public IComponentContext Services => _provider;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public static class ContextChecksExt
|
|||
public static Context CheckSystemPrivacy(this Context ctx, PKSystem target, PrivacyLevel level)
|
||||
{
|
||||
if (level.CanAccess(ctx.LookupContextFor(target.Id))) return ctx;
|
||||
throw new PKError("You do not have permission to access this information.");
|
||||
throw target.Id == ctx.System?.Id ? Errors.LookupHidden : Errors.LookupNotAllowed;
|
||||
}
|
||||
|
||||
public static Context CheckOwnSystem(this Context ctx, PKSystem system)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue