feat: rework group list into member list
This commit is contained in:
@@ -43,9 +43,11 @@ public class PKGroup
|
||||
public string? BannerImage { get; private set; }
|
||||
public string? Color { get; private set; }
|
||||
|
||||
public PrivacyLevel NamePrivacy { get; private set; }
|
||||
public PrivacyLevel DescriptionPrivacy { get; private set; }
|
||||
public PrivacyLevel IconPrivacy { get; private set; }
|
||||
public PrivacyLevel ListPrivacy { get; private set; }
|
||||
public PrivacyLevel MetadataPrivacy { get; private set; }
|
||||
public PrivacyLevel Visibility { get; private set; }
|
||||
|
||||
public Instant Created { get; private set; }
|
||||
@@ -53,12 +55,18 @@ public class PKGroup
|
||||
|
||||
public static class PKGroupExt
|
||||
{
|
||||
public static string? NameFor(this PKGroup group, LookupContext ctx) =>
|
||||
group.NamePrivacy.Get(ctx, group.Name, group.DisplayName ?? group.Name);
|
||||
|
||||
public static string? DescriptionFor(this PKGroup group, LookupContext ctx) =>
|
||||
group.DescriptionPrivacy.Get(ctx, group.Description);
|
||||
|
||||
public static string? IconFor(this PKGroup group, LookupContext ctx) =>
|
||||
group.IconPrivacy.Get(ctx, group.Icon?.TryGetCleanCdnUrl());
|
||||
|
||||
public static Instant? CreatedFor(this PKGroup group, LookupContext ctx) =>
|
||||
group.MetadataPrivacy.Get(ctx, (Instant?)group.Created);
|
||||
|
||||
public static JObject ToJson(this PKGroup group, LookupContext ctx, string? systemStr = null,
|
||||
bool needsMembersArray = false)
|
||||
{
|
||||
@@ -66,18 +74,18 @@ public static class PKGroupExt
|
||||
|
||||
o.Add("id", group.Hid);
|
||||
o.Add("uuid", group.Uuid.ToString());
|
||||
o.Add("name", group.Name);
|
||||
o.Add("name", group.NameFor(ctx));
|
||||
|
||||
if (systemStr != null)
|
||||
o.Add("system", systemStr);
|
||||
|
||||
o.Add("display_name", group.DisplayName);
|
||||
o.Add("display_name", group.NamePrivacy.CanAccess(ctx) ? group.DisplayName : null);
|
||||
o.Add("description", group.DescriptionPrivacy.Get(ctx, group.Description));
|
||||
o.Add("icon", group.IconFor(ctx));
|
||||
o.Add("banner", group.DescriptionPrivacy.Get(ctx, group.BannerImage));
|
||||
o.Add("color", group.Color);
|
||||
|
||||
o.Add("created", group.Created.FormatExport());
|
||||
o.Add("created", group.CreatedFor(ctx)?.FormatExport());
|
||||
|
||||
if (needsMembersArray)
|
||||
o.Add("members", new JArray());
|
||||
@@ -86,9 +94,11 @@ public static class PKGroupExt
|
||||
{
|
||||
var p = new JObject();
|
||||
|
||||
p.Add("name_privacy", group.NamePrivacy.ToJsonString());
|
||||
p.Add("description_privacy", group.DescriptionPrivacy.ToJsonString());
|
||||
p.Add("icon_privacy", group.IconPrivacy.ToJsonString());
|
||||
p.Add("list_privacy", group.ListPrivacy.ToJsonString());
|
||||
p.Add("metadata_privacy", group.MetadataPrivacy.ToJsonString());
|
||||
p.Add("visibility", group.Visibility.ToJsonString());
|
||||
|
||||
o.Add("privacy", p);
|
||||
|
||||
Reference in New Issue
Block a user