run dotnet format
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
@@ -9,7 +9,7 @@ namespace PluralKit.Core
|
||||
List,
|
||||
Visibility
|
||||
}
|
||||
|
||||
|
||||
public static class GroupPrivacyUtils
|
||||
{
|
||||
public static GroupPatch WithPrivacy(this GroupPatch group, GroupPrivacySubject subject, PrivacyLevel level)
|
||||
@@ -23,14 +23,14 @@ namespace PluralKit.Core
|
||||
GroupPrivacySubject.Visibility => group.Visibility = level,
|
||||
_ => throw new ArgumentOutOfRangeException($"Unknown privacy subject {subject}")
|
||||
};
|
||||
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
public static GroupPatch WithAllPrivacy(this GroupPatch member, PrivacyLevel level)
|
||||
{
|
||||
foreach (var subject in Enum.GetValues(typeof(GroupPrivacySubject)))
|
||||
member.WithPrivacy((GroupPrivacySubject) subject, level);
|
||||
member.WithPrivacy((GroupPrivacySubject)subject, level);
|
||||
return member;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace PluralKit.Core
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
public enum LookupContext
|
||||
{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
@@ -29,14 +29,14 @@ namespace PluralKit.Core
|
||||
MemberPrivacySubject.Visibility => member.Visibility = level,
|
||||
_ => throw new ArgumentOutOfRangeException($"Unknown privacy subject {subject}")
|
||||
};
|
||||
|
||||
|
||||
return member;
|
||||
}
|
||||
|
||||
public static MemberPatch WithAllPrivacy(this MemberPatch member, PrivacyLevel level)
|
||||
{
|
||||
foreach (var subject in Enum.GetValues(typeof(MemberPrivacySubject)))
|
||||
member.WithPrivacy((MemberPrivacySubject) subject, level);
|
||||
member.WithPrivacy((MemberPrivacySubject)subject, level);
|
||||
return member;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace PluralKit.Core
|
||||
Public = 1,
|
||||
Private = 2
|
||||
}
|
||||
|
||||
|
||||
public static class PrivacyLevelExt
|
||||
{
|
||||
public static bool CanAccess(this PrivacyLevel level, LookupContext ctx) =>
|
||||
level == PrivacyLevel.Public || ctx == LookupContext.ByOwner;
|
||||
|
||||
public static string LevelName(this PrivacyLevel level) =>
|
||||
public static string LevelName(this PrivacyLevel level) =>
|
||||
level == PrivacyLevel.Public ? "public" : "private";
|
||||
|
||||
public static T Get<T>(this PrivacyLevel level, LookupContext ctx, T input, T fallback = default) =>
|
||||
level.CanAccess(ctx) ? input : fallback;
|
||||
|
||||
|
||||
public static string Explanation(this PrivacyLevel level) =>
|
||||
level switch
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace PluralKit.Core
|
||||
output = input;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static string ToJsonString(this PrivacyLevel level) => level.LevelName();
|
||||
|
||||
public static PrivacyLevel ParsePrivacy(this JObject o, string propertyName)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
@@ -25,17 +25,17 @@ namespace PluralKit.Core
|
||||
SystemPrivacySubject.GroupList => system.GroupListPrivacy = level,
|
||||
_ => throw new ArgumentOutOfRangeException($"Unknown privacy subject {subject}")
|
||||
};
|
||||
|
||||
|
||||
return system;
|
||||
}
|
||||
|
||||
public static SystemPatch WithAllPrivacy(this SystemPatch system, PrivacyLevel level)
|
||||
{
|
||||
foreach (var subject in Enum.GetValues(typeof(SystemPrivacySubject)))
|
||||
WithPrivacy(system, (SystemPrivacySubject) subject, level);
|
||||
WithPrivacy(system, (SystemPrivacySubject)subject, level);
|
||||
return system;
|
||||
}
|
||||
|
||||
|
||||
public static bool TryParseSystemPrivacy(string input, out SystemPrivacySubject subject)
|
||||
{
|
||||
switch (input.ToLowerInvariant())
|
||||
@@ -45,7 +45,7 @@ namespace PluralKit.Core
|
||||
case "text":
|
||||
case "info":
|
||||
subject = SystemPrivacySubject.Description;
|
||||
break;
|
||||
break;
|
||||
case "members":
|
||||
case "memberlist":
|
||||
case "list":
|
||||
@@ -72,6 +72,6 @@ namespace PluralKit.Core
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user