feat: don't try to match other systems' members in switch / group add commands

This commit is contained in:
spiral
2021-09-13 03:14:59 -04:00
parent dec228d5bd
commit a2bf70b395
4 changed files with 22 additions and 17 deletions

View File

@@ -17,8 +17,11 @@ namespace PluralKit.Core
public Task<PKGroup?> GetGroupByDisplayName(IPKConnection conn, SystemId system, string display_name) =>
conn.QueryFirstOrDefaultAsync<PKGroup?>("select * from groups where system = @System and lower(display_name) = lower(@Name)", new { System = system, Name = display_name });
public Task<PKGroup?> GetGroupByHid(IPKConnection conn, string hid) =>
conn.QueryFirstOrDefaultAsync<PKGroup?>("select * from groups where hid = @hid", new { hid = hid.ToLowerInvariant() });
public Task<PKGroup?> GetGroupByHid(IPKConnection conn, string hid, SystemId? system = null)
=> conn.QueryFirstOrDefaultAsync<PKGroup?>(
"select * from groups where hid = @hid" + (system != null ? " and system = @System" : ""),
new { hid = hid.ToLowerInvariant(), System = system }
);
public Task<int> GetGroupMemberCount(IPKConnection conn, GroupId id, PrivacyLevel? privacyFilter = null)
{

View File

@@ -1,4 +1,5 @@
#nullable enable
using System;
using System.Data;
using System.Threading.Tasks;
@@ -11,8 +12,11 @@ namespace PluralKit.Core
public Task<PKMember?> GetMember(IPKConnection conn, MemberId id) =>
conn.QueryFirstOrDefaultAsync<PKMember?>("select * from members where id = @id", new { id });
public Task<PKMember?> GetMemberByHid(IPKConnection conn, string hid) =>
conn.QuerySingleOrDefaultAsync<PKMember?>("select * from members where hid = @Hid", new { Hid = hid.ToLower() });
public Task<PKMember?> GetMemberByHid(IPKConnection conn, string hid, SystemId? system = null)
=> conn.QuerySingleOrDefaultAsync<PKMember?>(
"select * from members where hid = @Hid" + (system != null ? " and system = @System" : ""),
new { Hid = hid.ToLower(), System = system }
);
public Task<PKMember?> GetMemberByName(IPKConnection conn, SystemId system, string name) =>
conn.QueryFirstOrDefaultAsync<PKMember?>("select * from members where lower(name) = lower(@Name) and system = @SystemID", new { Name = name, SystemID = system });