feat(bot): allow separate member avatars for proxied messages (#523)

This allows for using one avatar for the member card, and a different
avatar for proxied messages - so that users can set the main avatar to
a "full" version of their avatar, and the "proxy" avatar to a cropped
version.
This commit is contained in:
the iris system
2023-03-02 06:11:35 +13:00
committed by GitHub
parent 7fffb7f65a
commit ccb89f50e9
12 changed files with 138 additions and 49 deletions

View File

@@ -39,6 +39,7 @@ public class PKMember
public Guid Uuid { get; private set; }
public SystemId System { get; private set; }
public string Color { get; private set; }
public string WebhookAvatarUrl { get; private set; }
public string AvatarUrl { get; private set; }
public string BannerImage { get; private set; }
public string Name { get; private set; }
@@ -90,6 +91,9 @@ public static class PKMemberExt
public static string AvatarFor(this PKMember member, LookupContext ctx) =>
member.AvatarPrivacy.Get(ctx, member.AvatarUrl.TryGetCleanCdnUrl());
public static string WebhookAvatarFor(this PKMember member, LookupContext ctx) =>
member.AvatarPrivacy.Get(ctx, (member.WebhookAvatarUrl ?? member.AvatarUrl).TryGetCleanCdnUrl());
public static string DescriptionFor(this PKMember member, LookupContext ctx) =>
member.DescriptionPrivacy.Get(ctx, member.Description);
@@ -128,6 +132,7 @@ public static class PKMemberExt
o.Add("birthday", member.BirthdayFor(ctx)?.FormatExport());
o.Add("pronouns", member.PronounsFor(ctx));
o.Add("avatar_url", member.AvatarFor(ctx).TryGetCleanCdnUrl());
o.Add("webhook_avatar_url", member.WebhookAvatarFor(ctx).TryGetCleanCdnUrl());
o.Add("banner", member.DescriptionPrivacy.Get(ctx, member.BannerImage).TryGetCleanCdnUrl());
o.Add("description", member.DescriptionFor(ctx));
o.Add("created", member.CreatedFor(ctx)?.FormatExport());