feat(api): add member.message_count, member.last_message_timestamp

This commit is contained in:
spiral 2022-12-15 00:50:24 +00:00
parent 513c3e1a72
commit de9cae0cbd
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E
2 changed files with 10 additions and 2 deletions

View File

@ -102,8 +102,11 @@ public static class PKMemberExt
public static Instant? CreatedFor(this PKMember member, LookupContext ctx) =>
member.MetadataPrivacy.Get(ctx, (Instant?)member.Created);
public static int MessageCountFor(this PKMember member, LookupContext ctx) =>
member.MetadataPrivacy.Get(ctx, member.MessageCount);
public static int? MessageCountFor(this PKMember member, LookupContext ctx) =>
member.MetadataPrivacy.Get<int?>(ctx, member.MessageCount, fallback: null);
public static Instant? LastMessageTimestampFor(this PKMember member, LookupContext ctx) =>
member.MetadataPrivacy.Get(ctx, member.LastMessageTimestamp);
public static JObject ToJson(this PKMember member, LookupContext ctx, bool needsLegacyProxyTags = false,
string systemStr = null)
@ -132,6 +135,9 @@ public static class PKMemberExt
o.Add("autoproxy_enabled", ctx == LookupContext.ByOwner ? member.AllowAutoproxy : null);
o.Add("message_count", member.MessageCountFor(ctx));
o.Add("last_message_timestamp", member.LastMessageTimestampFor(ctx)?.FormatExport());
var tagArray = new JArray();
foreach (var tag in member.ProxyTags)
tagArray.Add(new JObject { { "prefix", tag.Prefix }, { "suffix", tag.Suffix } });

View File

@ -52,6 +52,8 @@ Every PluralKit entity has two IDs: a short (5-character) ID and a longer UUID.
|proxy_tags|array of [ProxyTag objects](#proxytag-object)|
|keep_proxy|boolean||
|autoproxy_enabled|?boolean||
|message_count|?int||
|last_message_timestamp|?datetime||
|privacy|?member privacy object||
* Member privacy keys: `visibility`, `name_privacy`, `description_privacy`, `birthday_privacy`, `pronoun_privacy`, `avatar_privacy`, `metadata_privacy`