From 4d04f859e6578efd8bf37117ca27812d4aa4efd8 Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 23 Dec 2021 23:23:16 -0500 Subject: [PATCH] feat: revert system/group card member count privacy --- PluralKit.Bot/Services/EmbedService.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Services/EmbedService.cs b/PluralKit.Bot/Services/EmbedService.cs index f2127f38..ec36b560 100644 --- a/PluralKit.Bot/Services/EmbedService.cs +++ b/PluralKit.Bot/Services/EmbedService.cs @@ -45,7 +45,16 @@ public class EmbedService var accounts = await _repo.GetSystemAccounts(system.Id); var users = (await GetUsers(accounts)).Select(x => x.User?.NameAndMention() ?? $"(deleted account {x.Id})"); - var memberCount = await _repo.GetSystemMemberCount(system.Id, ctx == LookupContext.ByOwner ? null : PrivacyLevel.Public); + var countctx = LookupContext.ByNonOwner; + if (cctx.MatchFlag("a", "all")) + { + if (system.Id == cctx.System.Id) + countctx = LookupContext.ByOwner; + else + throw Errors.LookupNotAllowed; + } + + var memberCount = await _repo.GetSystemMemberCount(system.Id, countctx == LookupContext.ByOwner ? null : PrivacyLevel.Public); uint color; try @@ -224,7 +233,17 @@ public class EmbedService public async Task CreateGroupEmbed(Context ctx, PKSystem system, PKGroup target) { var pctx = ctx.LookupContextFor(system.Id); - var memberCount = await _repo.GetGroupMemberCount(target.Id, pctx == LookupContext.ByOwner ? null : PrivacyLevel.Public); + + var countctx = LookupContext.ByNonOwner; + if (ctx.MatchFlag("a", "all")) + { + if (system.Id == ctx.System.Id) + countctx = LookupContext.ByOwner; + else + throw Errors.LookupNotAllowed; + } + + var memberCount = await _repo.GetGroupMemberCount(target.Id, countctx == LookupContext.ByOwner ? null : PrivacyLevel.Public); var nameField = target.Name; if (system.Name != null)