From 2cd5047b141b9213d814890c05c41613931ec92f Mon Sep 17 00:00:00 2001 From: spiral Date: Tue, 9 Mar 2021 15:19:26 +0000 Subject: [PATCH] fix importing pronouns and message count --- PluralKit.Core/Services/DataFileService.cs | 1 + PluralKit.Core/Utils/BulkImporter.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PluralKit.Core/Services/DataFileService.cs b/PluralKit.Core/Services/DataFileService.cs index c694a156..05dd3b37 100644 --- a/PluralKit.Core/Services/DataFileService.cs +++ b/PluralKit.Core/Services/DataFileService.cs @@ -85,6 +85,7 @@ namespace PluralKit.Core Pronouns = fileMember.Pronouns, AvatarUrl = fileMember.AvatarUrl, KeepProxy = fileMember.KeepProxy, + MessageCount = fileMember.MessageCount, }; if (fileMember.Prefix != null || fileMember.Suffix != null) diff --git a/PluralKit.Core/Utils/BulkImporter.cs b/PluralKit.Core/Utils/BulkImporter.cs index bf7d764a..1d409457 100644 --- a/PluralKit.Core/Utils/BulkImporter.cs +++ b/PluralKit.Core/Utils/BulkImporter.cs @@ -80,12 +80,17 @@ namespace PluralKit.Core if (patch.Name.IsPresent) qb.Variable("name", "@Name"); if (patch.DisplayName.IsPresent) qb.Variable("display_name", "@DisplayName"); if (patch.Description.IsPresent) qb.Variable("description", "@Description"); + if (patch.Pronouns.IsPresent) qb.Variable("pronouns", "@Pronouns"); if (patch.Color.IsPresent) qb.Variable("color", "@Color"); if (patch.AvatarUrl.IsPresent) qb.Variable("avatar_url", "@AvatarUrl"); if (patch.ProxyTags.IsPresent) qb.Variable("proxy_tags", "@ProxyTags"); if (patch.Birthday.IsPresent) qb.Variable("birthday", "@Birthday"); if (patch.KeepProxy.IsPresent) qb.Variable("keep_proxy", "@KeepProxy"); + // don't overwrite message count on existing members + if (existingMember == null) + if (patch.MessageCount.IsPresent) qb.Variable("message_count", "@MessageCount"); + var newMember = await _conn.QueryFirstAsync(qb.Build("returning *"), new { @@ -94,11 +99,13 @@ namespace PluralKit.Core Name = patch.Name.Value, DisplayName = patch.DisplayName.Value, Description = patch.Description.Value, + Pronouns = patch.Pronouns.Value, Color = patch.Color.Value, AvatarUrl = patch.AvatarUrl.Value, KeepProxy = patch.KeepProxy.Value, ProxyTags = patch.ProxyTags.Value, - Birthday = patch.Birthday.Value + Birthday = patch.Birthday.Value, + MessageCount = patch.MessageCount.Value, }); // Log this member ID by the given identifier