diff --git a/PluralKit.Core/Services/IDataStore.cs b/PluralKit.Core/Services/IDataStore.cs index 522db4b5..9d16eb4c 100644 --- a/PluralKit.Core/Services/IDataStore.cs +++ b/PluralKit.Core/Services/IDataStore.cs @@ -149,6 +149,12 @@ namespace PluralKit.Core { /// /// The with the given name, or null if no member was found. Task GetMemberByName(PKSystem system, string name); + + /// + /// Gets a member by its display name within one system. + /// + /// The with the given name, or null if no member was found. + Task GetMemberByDisplayName(PKSystem system, string name); /// /// Gets all members inside a given system. diff --git a/PluralKit.Core/Services/PostgresDataStore.cs b/PluralKit.Core/Services/PostgresDataStore.cs index fd4bc579..4d1e2165 100644 --- a/PluralKit.Core/Services/PostgresDataStore.cs +++ b/PluralKit.Core/Services/PostgresDataStore.cs @@ -141,6 +141,12 @@ namespace PluralKit.Core { return await conn.QueryFirstOrDefaultAsync("select * from members where lower(name) = lower(@Name) and system = @SystemID", new { Name = name, SystemID = system.Id }); } + public async Task GetMemberByDisplayName(PKSystem system, string name) { + // QueryFirst, since members can (in rare cases) share display names + using (var conn = await _conn.Obtain()) + return await conn.QueryFirstOrDefaultAsync("select * from members where lower(display_name) = lower(@Name) and system = @SystemID", new { Name = name, SystemID = system.Id }); + } + public IAsyncEnumerable GetSystemMembers(PKSystem system, bool orderByName) { var sql = "select * from members where system = @SystemID";