Comment out color privacy stuff for now (revisit later?)

This commit is contained in:
Ske 2020-06-17 21:51:40 +02:00
parent 721a4502bb
commit e92700f339
7 changed files with 23 additions and 20 deletions

View File

@ -45,7 +45,8 @@ namespace PluralKit.API
var o = new JObject(); var o = new JObject();
o.Add("id", member.Hid); o.Add("id", member.Hid);
o.Add("name", member.NamePrivacy.CanAccess(ctx) ? member.Name : member.DisplayName ?? member.Name); o.Add("name", member.NamePrivacy.CanAccess(ctx) ? member.Name : member.DisplayName ?? member.Name);
o.Add("color", member.ColorPrivacy.CanAccess(ctx) ? member.Color : null); // o.Add("color", member.ColorPrivacy.CanAccess(ctx) ? member.Color : null);
o.Add("color", member.Color);
o.Add("display_name", member.NamePrivacy.CanAccess(ctx) ? member.DisplayName : null); o.Add("display_name", member.NamePrivacy.CanAccess(ctx) ? member.DisplayName : null);
o.Add("birthday", member.BirthdayPrivacy.CanAccess(ctx) && member.Birthday.HasValue ? DateTimeFormats.DateExportFormat.Format(member.Birthday.Value) : null); o.Add("birthday", member.BirthdayPrivacy.CanAccess(ctx) && member.Birthday.HasValue ? DateTimeFormats.DateExportFormat.Format(member.Birthday.Value) : null);
o.Add("pronouns", member.PronounPrivacy.CanAccess(ctx) ? member.Pronouns : null); o.Add("pronouns", member.PronounPrivacy.CanAccess(ctx) ? member.Pronouns : null);
@ -66,7 +67,7 @@ namespace PluralKit.API
o.Add("description_privacy", ctx == LookupContext.ByOwner ? (member.DescriptionPrivacy == PrivacyLevel.Private ? "private" : "public") : null); o.Add("description_privacy", ctx == LookupContext.ByOwner ? (member.DescriptionPrivacy == PrivacyLevel.Private ? "private" : "public") : null);
o.Add("birthday_privacy", ctx == LookupContext.ByOwner ? (member.BirthdayPrivacy == PrivacyLevel.Private ? "private" : "public") : null); o.Add("birthday_privacy", ctx == LookupContext.ByOwner ? (member.BirthdayPrivacy == PrivacyLevel.Private ? "private" : "public") : null);
o.Add("pronoun_privacy", ctx == LookupContext.ByOwner ? (member.PronounPrivacy == PrivacyLevel.Private ? "private" : "public") : null); o.Add("pronoun_privacy", ctx == LookupContext.ByOwner ? (member.PronounPrivacy == PrivacyLevel.Private ? "private" : "public") : null);
o.Add("color_privacy", ctx == LookupContext.ByOwner ? (member.ColorPrivacy == PrivacyLevel.Private ? "private" : "public") : null); // o.Add("color_privacy", ctx == LookupContext.ByOwner ? (member.ColorPrivacy == PrivacyLevel.Private ? "private" : "public") : null);
o.Add("metadata_privacy", ctx == LookupContext.ByOwner ? (member.MetadataPrivacy == PrivacyLevel.Private ? "private" : "public") : null); o.Add("metadata_privacy", ctx == LookupContext.ByOwner ? (member.MetadataPrivacy == PrivacyLevel.Private ? "private" : "public") : null);
if(member.MetadataPrivacy.CanAccess(ctx)) if(member.MetadataPrivacy.CanAccess(ctx))
@ -124,7 +125,7 @@ namespace PluralKit.API
member.DescriptionPrivacy = plevel; member.DescriptionPrivacy = plevel;
member.BirthdayPrivacy = plevel; member.BirthdayPrivacy = plevel;
member.PronounPrivacy = plevel; member.PronounPrivacy = plevel;
member.ColorPrivacy = plevel; // member.ColorPrivacy = plevel;
member.MetadataPrivacy = plevel; member.MetadataPrivacy = plevel;
} }
else else
@ -134,7 +135,7 @@ namespace PluralKit.API
if (o.ContainsKey("description_privacy")) member.DescriptionPrivacy = o.Value<string>("description_privacy").ParsePrivacy("member"); if (o.ContainsKey("description_privacy")) member.DescriptionPrivacy = o.Value<string>("description_privacy").ParsePrivacy("member");
if (o.ContainsKey("birthday_privacy")) member.BirthdayPrivacy = o.Value<string>("birthday_privacy").ParsePrivacy("member"); if (o.ContainsKey("birthday_privacy")) member.BirthdayPrivacy = o.Value<string>("birthday_privacy").ParsePrivacy("member");
if (o.ContainsKey("pronoun_privacy")) member.PronounPrivacy = o.Value<string>("pronoun_privacy").ParsePrivacy("member"); if (o.ContainsKey("pronoun_privacy")) member.PronounPrivacy = o.Value<string>("pronoun_privacy").ParsePrivacy("member");
if (o.ContainsKey("color_privacy")) member.ColorPrivacy = o.Value<string>("color_privacy").ParsePrivacy("member"); // if (o.ContainsKey("color_privacy")) member.ColorPrivacy = o.Value<string>("color_privacy").ParsePrivacy("member");
if (o.ContainsKey("metadata_privacy")) member.MetadataPrivacy = o.Value<string>("metadata_privacy").ParsePrivacy("member"); if (o.ContainsKey("metadata_privacy")) member.MetadataPrivacy = o.Value<string>("metadata_privacy").ParsePrivacy("member");
} }
} }

View File

@ -42,7 +42,7 @@ namespace PluralKit.Bot
public static Command MemberServerName = new Command("member servername", "member <member> servername [server name]", "Changes a member's display name in the current server"); public static Command MemberServerName = new Command("member servername", "member <member> servername [server name]", "Changes a member's display name in the current server");
public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying"); public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying");
public static Command MemberRandom = new Command("random", "random", "Looks up a random member from your system"); public static Command MemberRandom = new Command("random", "random", "Looks up a random member from your system");
public static Command MemberPrivacy = new Command("member privacy", "member <member> privacy <name|description|birthday|pronouns|color|metadata|visibility|all> <public|private>", "Changes a members's privacy settings"); public static Command MemberPrivacy = new Command("member privacy", "member <member> privacy <name|description|birthday|pronouns|metadata|visibility|all> <public|private>", "Changes a members's privacy settings");
public static Command Switch = new Command("switch", "switch <member> [member 2] [member 3...]", "Registers a switch"); public static Command Switch = new Command("switch", "switch <member> [member 2] [member 3...]", "Registers a switch");
public static Command SwitchOut = new Command("switch out", "switch out", "Registers a switch with no members"); public static Command SwitchOut = new Command("switch out", "switch out", "Registers a switch with no members");
public static Command SwitchMove = new Command("switch move", "switch move <date/time>", "Moves the latest switch in time"); public static Command SwitchMove = new Command("switch move", "switch move <date/time>", "Moves the latest switch in time");

View File

@ -153,8 +153,8 @@ namespace PluralKit.Bot
} }
else if (!ctx.HasNext()) else if (!ctx.HasNext())
{ {
if (!target.ColorPrivacy.CanAccess(ctx.LookupContextFor(target.System))) // if (!target.ColorPrivacy.CanAccess(ctx.LookupContextFor(target.System)))
throw Errors.LookupNotAllowed; // throw Errors.LookupNotAllowed;
if (target.Color == null) if (target.Color == null)
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
@ -381,10 +381,10 @@ namespace PluralKit.Bot
.AddField("Description", PrivacyLevelString(target.DescriptionPrivacy)) .AddField("Description", PrivacyLevelString(target.DescriptionPrivacy))
.AddField("Birthday", PrivacyLevelString(target.BirthdayPrivacy)) .AddField("Birthday", PrivacyLevelString(target.BirthdayPrivacy))
.AddField("Pronouns", PrivacyLevelString(target.PronounPrivacy)) .AddField("Pronouns", PrivacyLevelString(target.PronounPrivacy))
.AddField("Color", PrivacyLevelString(target.ColorPrivacy)) // .AddField("Color", PrivacyLevelString(target.ColorPrivacy))
.AddField("Meta (message count, last front, last message)", PrivacyLevelString(target.MetadataPrivacy)) .AddField("Meta (message count, last front, last message)", PrivacyLevelString(target.MetadataPrivacy))
.AddField("Visibility", PrivacyLevelString(target.MemberVisibility)) .AddField("Visibility", PrivacyLevelString(target.MemberVisibility))
.WithDescription("To edit privacy settings, use the command:\n`pk;member <member> privacy <subject> <level>`\n\n- `subject` is one of `name`, `description`, `birthday`, `pronouns`, `color`, `created`, `messages`, `visibility`, or `all`\n- `level` is either `public` or `private`."); .WithDescription("To edit privacy settings, use the command:\n`pk;member <member> privacy <subject> <level>`\n\n- `subject` is one of `name`, `description`, `birthday`, `pronouns`, `created`, `messages`, `visibility`, or `all`\n- `level` is either `public` or `private`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
return; return;
} }
@ -413,7 +413,7 @@ namespace PluralKit.Bot
} }
string levelStr, levelExplanation, subjectStr; string levelStr, levelExplanation, subjectStr;
var subjectList = "`name`, `description`, `birthday`, `pronouns`, `color`, `metadata`, `visibility`, or `all`"; var subjectList = "`name`, `description`, `birthday`, `pronouns`, `metadata`, `visibility`, or `all`";
if(ctx.Match("name")) if(ctx.Match("name"))
{ {
subjectStr = "name"; subjectStr = "name";
@ -434,11 +434,11 @@ namespace PluralKit.Bot
subjectStr = "pronouns"; subjectStr = "pronouns";
target.PronounPrivacy = PopPrivacyLevel("pronouns", out levelStr, out levelExplanation); target.PronounPrivacy = PopPrivacyLevel("pronouns", out levelStr, out levelExplanation);
} }
else if(ctx.Match("color","colour")) /*else if(ctx.Match("color","colour"))
{ {
subjectStr = "color"; subjectStr = "color";
target.ColorPrivacy = PopPrivacyLevel("color", out levelStr, out levelExplanation); target.ColorPrivacy = PopPrivacyLevel("color", out levelStr, out levelExplanation);
} }*/
else if(ctx.Match("meta","metadata")) else if(ctx.Match("meta","metadata"))
{ {
subjectStr = "metadata (date created, message count, last fronted, and last message)"; subjectStr = "metadata (date created, message count, last fronted, and last message)";
@ -474,7 +474,7 @@ namespace PluralKit.Bot
target.DescriptionPrivacy = level; target.DescriptionPrivacy = level;
target.BirthdayPrivacy = level; target.BirthdayPrivacy = level;
target.PronounPrivacy = level; target.PronounPrivacy = level;
target.ColorPrivacy = level; // target.ColorPrivacy = level;
target.MetadataPrivacy = level; target.MetadataPrivacy = level;
} }
else else

View File

@ -110,7 +110,8 @@ namespace PluralKit.Bot {
var eb = new DiscordEmbedBuilder() var eb = new DiscordEmbedBuilder()
// TODO: add URL of website when that's up // TODO: add URL of website when that's up
.WithAuthor(name, iconUrl: DiscordUtils.WorkaroundForUrlBug(avatar)) .WithAuthor(name, iconUrl: DiscordUtils.WorkaroundForUrlBug(avatar))
.WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : DiscordUtils.Gray) // .WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : DiscordUtils.Gray)
.WithColor(color)
.WithFooter($"System ID: {system.Hid} | Member ID: {member.Hid} {(member.MetadataPrivacy.CanAccess(ctx) ? $"| Created on {DateTimeFormats.ZonedDateTimeFormat.Format(member.Created.InZone(system.Zone))}":"")}"); .WithFooter($"System ID: {system.Hid} | Member ID: {member.Hid} {(member.MetadataPrivacy.CanAccess(ctx) ? $"| Created on {DateTimeFormats.ZonedDateTimeFormat.Format(member.Created.InZone(system.Zone))}":"")}");
var description = ""; var description = "";
@ -133,7 +134,8 @@ namespace PluralKit.Bot {
// --- For when this gets added to the member object itself or however they get added // --- 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))); // if (member.LastMessage != null && member.MetadataPrivacy.CanAccess(ctx)) eb.AddField("Last message:" FormatTimestamp(DiscordUtils.SnowflakeToInstant(m.LastMessage.Value)));
// if (member.LastSwitchTime != null && m.MetadataPrivacy.CanAccess(ctx)) eb.AddField("Last switched in:", FormatTimestamp(member.LastSwitchTime.Value)); // if (member.LastSwitchTime != null && m.MetadataPrivacy.CanAccess(ctx)) eb.AddField("Last switched in:", FormatTimestamp(member.LastSwitchTime.Value));
if (!member.Color.EmptyOrNull() && member.ColorPrivacy.CanAccess(ctx)) eb.AddField("Color", $"#{member.Color}", true); // if (!member.Color.EmptyOrNull() && member.ColorPrivacy.CanAccess(ctx)) eb.AddField("Color", $"#{member.Color}", true);
if (!member.Color.EmptyOrNull()) eb.AddField("Color", $"#{member.Color}", true);
if (!member.Description.EmptyOrNull() && member.DescriptionPrivacy.CanAccess(ctx)) eb.AddField("Description", member.Description.NormalizeLineEndSpacing(), false); if (!member.Description.EmptyOrNull() && member.DescriptionPrivacy.CanAccess(ctx)) eb.AddField("Description", member.Description.NormalizeLineEndSpacing(), false);

View File

@ -5,7 +5,7 @@ alter table members add column name_privacy integer check (name_privacy in (1, 2
alter table members add column birthday_privacy integer check (birthday_privacy in (1, 2)) not null default 1; alter table members add column birthday_privacy integer check (birthday_privacy in (1, 2)) not null default 1;
alter table members add column pronoun_privacy integer check (pronoun_privacy in (1, 2)) not null default 1; alter table members add column pronoun_privacy integer check (pronoun_privacy in (1, 2)) not null default 1;
alter table members add column metadata_privacy integer check (metadata_privacy in (1, 2)) not null default 1; alter table members add column metadata_privacy integer check (metadata_privacy in (1, 2)) not null default 1;
alter table members add column color_privacy integer check (color_privacy in (1, 2)) not null default 1; -- alter table members add column color_privacy integer check (color_privacy in (1, 2)) not null default 1;
-- Transfer existing settings -- -- Transfer existing settings --
update members set description_privacy = member_privacy; update members set description_privacy = member_privacy;
@ -13,7 +13,7 @@ update members set name_privacy = member_privacy;
update members set birthday_privacy = member_privacy; update members set birthday_privacy = member_privacy;
update members set pronoun_privacy = member_privacy; update members set pronoun_privacy = member_privacy;
update members set metadata_privacy = member_privacy; update members set metadata_privacy = member_privacy;
update members set color_privacy = member_privacy; -- update members set color_privacy = member_privacy;
-- Rename member_privacy to member_visibility -- -- Rename member_privacy to member_visibility --
alter table members rename column member_privacy to member_visibility; alter table members rename column member_privacy to member_visibility;

View File

@ -29,7 +29,7 @@ namespace PluralKit.Core {
public PrivacyLevel BirthdayPrivacy { get; set; } public PrivacyLevel BirthdayPrivacy { get; set; }
public PrivacyLevel PronounPrivacy { get; set; } public PrivacyLevel PronounPrivacy { get; set; }
public PrivacyLevel MetadataPrivacy { get; set; } public PrivacyLevel MetadataPrivacy { get; set; }
public PrivacyLevel ColorPrivacy { get; set; } // public PrivacyLevel ColorPrivacy { get; set; }
/// Returns a formatted string representing the member's birthday, taking into account that a year of "0001" or "0004" is hidden /// Returns a formatted string representing the member's birthday, taking into account that a year of "0001" or "0004" is hidden
/// Before Feb 10 2020, the sentinel year was 0001, now it is 0004. /// Before Feb 10 2020, the sentinel year was 0001, now it is 0004.

View File

@ -150,7 +150,7 @@ namespace PluralKit.Core {
public async Task SaveMember(PKMember member) { public async Task SaveMember(PKMember member) {
using (var conn = await _conn.Obtain()) using (var conn = await _conn.Obtain())
await conn.ExecuteAsync("update members set name = @Name, display_name = @DisplayName, description = @Description, color = @Color, avatar_url = @AvatarUrl, birthday = @Birthday, pronouns = @Pronouns, proxy_tags = @ProxyTags, keep_proxy = @KeepProxy, member_visibility = @MemberVisibility, description_privacy = @DescriptionPrivacy, name_privacy = @NamePrivacy, birthday_privacy = @BirthdayPrivacy, pronoun_privacy = @PronounPrivacy, metadata_privacy = @MetadataPrivacy, color_privacy = @ColorPrivacy where id = @Id", member); await conn.ExecuteAsync("update members set name = @Name, display_name = @DisplayName, description = @Description, color = @Color, avatar_url = @AvatarUrl, birthday = @Birthday, pronouns = @Pronouns, proxy_tags = @ProxyTags, keep_proxy = @KeepProxy, member_visibility = @MemberVisibility, description_privacy = @DescriptionPrivacy, name_privacy = @NamePrivacy, birthday_privacy = @BirthdayPrivacy, pronoun_privacy = @PronounPrivacy, metadata_privacy = @MetadataPrivacy where id = @Id", member);
_logger.Information("Updated member {@Member}", member); _logger.Information("Updated member {@Member}", member);
} }