feat: proxy tag privacy (#571)

Merges PluralKit/PluralKit#571
This commit is contained in:
rladenson 2023-08-10 17:54:53 +12:00 committed by Iris System
parent 084df88624
commit 68cd21fb2f
8 changed files with 46 additions and 9 deletions

View file

@ -146,7 +146,7 @@ public static class ContextListExt
ret += $"({m.DisplayName})";
else if (opts.IncludeBirthday && m.BirthdayFor(lookupCtx) is { } birthday)
ret += $"(birthday: {m.BirthdayString})";
else if (m.HasProxyTags)
else if (m.HasProxyTags && m.ProxyPrivacy.CanAccess(lookupCtx))
{
var proxyTagsString = m.ProxyTagsString();
if (proxyTagsString.Length > 100) // arbitrary threshold for now, tweak?
@ -173,7 +173,7 @@ public static class ContextListExt
if (m.BirthdayFor(lookupCtx) != null)
profile.Append($"\n**Birthdate**: {m.BirthdayString}");
if (m.ProxyTags.Count > 0)
if (m.ProxyTags.Count > 0 && m.ProxyPrivacy.CanAccess(lookupCtx))
profile.Append($"\n**Proxy tags**: {m.ProxyTagsString()}");
if ((opts.IncludeMessageCount || opts.SortProperty == SortProperty.MessageCount) &&

View file

@ -574,11 +574,12 @@ public class MemberEdit
.Field(new Embed.Field("Avatar", target.AvatarPrivacy.Explanation()))
.Field(new Embed.Field("Birthday", target.BirthdayPrivacy.Explanation()))
.Field(new Embed.Field("Pronouns", target.PronounPrivacy.Explanation()))
.Field(new Embed.Field("Proxy Tags", target.ProxyPrivacy.Explanation()))
.Field(new Embed.Field("Meta (creation date, message count, last front, last message)",
target.MetadataPrivacy.Explanation()))
.Field(new Embed.Field("Visibility", target.MemberVisibility.Explanation()))
.Description(
"To edit privacy settings, use the command:\n`pk;member <member> privacy <subject> <level>`\n\n- `subject` is one of `name`, `description`, `avatar`, `birthday`, `pronouns`, `metadata`, `visibility`, or `all`\n- `level` is either `public` or `private`.")
"To edit privacy settings, use the command:\n`pk;member <member> privacy <subject> <level>`\n\n- `subject` is one of `name`, `description`, `avatar`, `birthday`, `pronouns`, `proxies`, `metadata`, `visibility`, or `all`\n- `level` is either `public` or `private`.")
.Build());
return;
}
@ -611,6 +612,7 @@ public class MemberEdit
MemberPrivacySubject.Avatar => "avatar privacy",
MemberPrivacySubject.Pronouns => "pronoun privacy",
MemberPrivacySubject.Birthday => "birthday privacy",
MemberPrivacySubject.Proxy => "proxy tag privacy",
MemberPrivacySubject.Metadata => "metadata privacy",
MemberPrivacySubject.Visibility => "visibility",
_ => throw new ArgumentOutOfRangeException($"Unknown privacy subject {subject}")
@ -628,6 +630,8 @@ public class MemberEdit
"This member's birthday is now hidden from other systems.",
(MemberPrivacySubject.Pronouns, PrivacyLevel.Private) =>
"This member's pronouns are now hidden from other systems.",
(MemberPrivacySubject.Proxy, PrivacyLevel.Private) =>
"This member's proxy tags are now hidden from other systems.",
(MemberPrivacySubject.Metadata, PrivacyLevel.Private) =>
"This member's metadata (eg. created timestamp, message count, etc) is now hidden from other systems.",
(MemberPrivacySubject.Visibility, PrivacyLevel.Private) =>
@ -642,7 +646,9 @@ public class MemberEdit
(MemberPrivacySubject.Birthday, PrivacyLevel.Public) =>
"This member's birthday is no longer hidden from other systems.",
(MemberPrivacySubject.Pronouns, PrivacyLevel.Public) =>
"This member's pronouns are no longer hidden other systems.",
"This member's pronouns are no longer hidden from other systems.",
(MemberPrivacySubject.Proxy, PrivacyLevel.Public) =>
"This member's proxy tags are no longer hidden from other systems.",
(MemberPrivacySubject.Metadata, PrivacyLevel.Public) =>
"This member's metadata (eg. created timestamp, message count, etc) is no longer hidden from other systems.",
(MemberPrivacySubject.Visibility, PrivacyLevel.Public) =>

View file

@ -242,7 +242,7 @@ public class EmbedService
eb.Field(new Embed.Field("Pronouns", pronouns.Truncate(1024), true));
if (member.MessageCountFor(ctx) is { } count && count > 0)
eb.Field(new Embed.Field("Message Count", member.MessageCount.ToString(), true));
if (member.HasProxyTags)
if (member.HasProxyTags && member.ProxyPrivacy.CanAccess(ctx))
eb.Field(new Embed.Field("Proxy Tags", member.ProxyTagsString("\n").Truncate(1024), true));
// --- For when this gets added to the member object itself or however they get added
// if (member.LastMessage != null && member.MetadataPrivacy.CanAccess(ctx)) eb.AddField("Last message:" FormatTimestamp(DiscordUtils.SnowflakeToInstant(m.LastMessage.Value)));