PluralKit/PluralKit.Core/Database/Repository/ModelRepository.Account.cs

22 lines
754 B
C#
Raw Normal View History

using Dapper;
using SqlKata;
2020-11-20 23:34:08 +00:00
namespace PluralKit.Core;
public partial class ModelRepository
2020-11-20 23:34:08 +00:00
{
public async Task<ulong?> GetDmChannel(ulong id)
=> await _db.QueryFirst<ulong?>(new Query("accounts").Select("dm_channel").Where("uid", id));
public async Task<bool> GetAutoproxyEnabled(ulong id)
=> await _db.QueryFirst<bool>(new Query("accounts").Select("allow_autoproxy").Where("uid", id));
public async Task UpdateAccount(ulong id, AccountPatch patch)
2020-11-20 23:34:08 +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
}
}