Add member proxy display names

This commit is contained in:
Ske
2019-08-09 10:12:38 +02:00
parent fabf772085
commit 200ba6d84c
7 changed files with 67 additions and 21 deletions

View File

@@ -7,6 +7,7 @@ namespace PluralKit
{
public class PKSystem
{
// Additions here should be mirrored in SystemStore::Save
[Key] [JsonIgnore] public int Id { get; set; }
[JsonProperty("id")] public string Hid { get; set; }
[JsonProperty("name")] public string Name { get; set; }
@@ -24,12 +25,14 @@ namespace PluralKit
public class PKMember
{
// Additions here should be mirrored in MemberStore::Save
[JsonIgnore] public int Id { get; set; }
[JsonProperty("id")] public string Hid { get; set; }
[JsonIgnore] public int System { get; set; }
[JsonProperty("color")] public string Color { get; set; }
[JsonProperty("avatar_url")] public string AvatarUrl { get; set; }
[JsonProperty("name")] public string Name { get; set; }
[JsonProperty("display_name")] public string DisplayName { get; set; }
[JsonProperty("birthday")] public LocalDate? Birthday { get; set; }
[JsonProperty("pronouns")] public string Pronouns { get; set; }
[JsonProperty("description")] public string Description { get; set; }
@@ -52,6 +55,12 @@ namespace PluralKit
[JsonIgnore] public bool HasProxyTags => Prefix != null || Suffix != null;
[JsonIgnore] public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}";
public string ProxyName(string systemTag)
{
if (systemTag == null) return DisplayName ?? Name;
return $"{DisplayName ?? Name} {systemTag}";
}
}
public class PKSwitch

View File

@@ -150,7 +150,7 @@ namespace PluralKit {
public async Task Save(PKMember member) {
using (var conn = await _conn.Obtain())
await conn.ExecuteAsync("update members set name = @Name, description = @Description, color = @Color, avatar_url = @AvatarUrl, birthday = @Birthday, pronouns = @Pronouns, prefix = @Prefix, suffix = @Suffix where id = @Id", member);
await conn.ExecuteAsync("update members set name = @Name, display_name = @DisplayName, description = @Description, color = @Color, avatar_url = @AvatarUrl, birthday = @Birthday, pronouns = @Pronouns, prefix = @Prefix, suffix = @Suffix where id = @Id", member);
_logger.Information("Updated member {@Member}", member);
}

View File

@@ -242,7 +242,7 @@ namespace PluralKit
public static readonly string Warn = "\u26A0";
public static readonly string Success = "\u2705";
public static readonly string Error = "\u274C";
public static readonly string Note = "\u2757";
public static readonly string Note = "\U0001f4dd";
public static readonly string ThumbsUp = "\U0001f44d";
public static readonly string RedQuestion = "\u2753";
}

View File

@@ -13,18 +13,19 @@ create table if not exists systems
create table if not exists members
(
id serial primary key,
hid char(5) unique not null,
system serial not null references systems (id) on delete cascade,
color char(6),
avatar_url text,
name text not null,
birthday date,
pronouns text,
description text,
prefix text,
suffix text,
created timestamp not null default (current_timestamp at time zone 'utc')
id serial primary key,
hid char(5) unique not null,
system serial not null references systems (id) on delete cascade,
color char(6),
avatar_url text,
name text not null,
display_name text,
birthday date,
pronouns text,
description text,
prefix text,
suffix text,
created timestamp not null default (current_timestamp at time zone 'utc')
);
create table if not exists accounts