PluralKit/PluralKit.Core/Models/ModelExtensions.cs

37 lines
1.6 KiB
C#
Raw Normal View History

using NodaTime;
namespace PluralKit.Core
{
public static class ModelExtensions
{
public static string DescriptionFor(this PKSystem system, LookupContext ctx) =>
system.DescriptionPrivacy.Get(ctx, system.Description);
public static string NameFor(this PKMember member, LookupContext ctx) =>
member.NamePrivacy.Get(ctx, member.Name, member.DisplayName ?? member.Name);
2020-06-20 14:00:50 +00:00
public static string AvatarFor(this PKMember member, LookupContext ctx) =>
member.AvatarPrivacy.Get(ctx, member.AvatarUrl);
public static string DescriptionFor(this PKMember member, LookupContext ctx) =>
member.DescriptionPrivacy.Get(ctx, member.Description);
public static LocalDate? BirthdayFor(this PKMember member, LookupContext ctx) =>
member.BirthdayPrivacy.Get(ctx, member.Birthday);
public static string PronounsFor(this PKMember member, LookupContext ctx) =>
member.PronounPrivacy.Get(ctx, member.Pronouns);
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);
2020-07-18 11:53:02 +00:00
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);
}
}