2022-01-22 07:47:47 +00:00
|
|
|
using Dapper;
|
|
|
|
|
2021-09-30 01:51:38 +00:00
|
|
|
using SqlKata;
|
2020-11-20 23:34:08 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.Core;
|
|
|
|
|
|
|
|
public partial class ModelRepository
|
2020-11-20 23:34:08 +00:00
|
|
|
{
|
2022-01-22 07:47:47 +00:00
|
|
|
public async Task<ulong?> GetDmChannel(ulong id)
|
|
|
|
=> await _db.Execute(c => c.QueryFirstOrDefaultAsync<ulong?>("select dm_channel from accounts where uid = @id", new { id = id }));
|
|
|
|
|
2022-06-15 23:28:34 +00:00
|
|
|
public async Task<bool> GetAutoproxyEnabled(ulong id)
|
|
|
|
=> await _db.QueryFirst<bool>(new Query("accounts").Select("allow_autoproxy").Where("uid", id));
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public async Task UpdateAccount(ulong id, AccountPatch patch)
|
2020-11-20 23:34:08 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
_logger.Information("Updated account {accountId}: {@AccountPatch}", id, patch);
|
|
|
|
var query = patch.Apply(new Query("accounts").Where("uid", id));
|
|
|
|
_ = _dispatch.Dispatch(id, patch);
|
|
|
|
await _db.ExecuteQuery(query, "returning *");
|
2020-11-20 23:34:08 +00:00
|
|
|
}
|
|
|
|
}
|