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

23 lines
778 B
C#
Raw Normal View History

2021-11-30 02:35:21 +00:00
using SqlKata;
namespace PluralKit.Core;
public partial class ModelRepository
{
2021-11-30 22:04:42 +00:00
public Task<SystemConfig> GetSystemConfig(SystemId system, IPKConnection conn = null)
=> _db.QueryFirst<SystemConfig>(conn, new Query("system_config").Where("system", system));
2021-11-30 02:35:21 +00:00
2021-11-30 22:04:42 +00:00
public async Task<SystemConfig> UpdateSystemConfig(SystemId system, SystemConfigPatch patch, IPKConnection conn = null)
2021-11-30 02:35:21 +00:00
{
var query = patch.Apply(new Query("system_config").Where("system", system));
2021-11-30 22:04:42 +00:00
var config = await _db.QueryFirst<SystemConfig>(conn, query, "returning *");
2021-11-30 02:35:21 +00:00
_ = _dispatch.Dispatch(system, new UpdateDispatchData
{
Event = DispatchEvent.UPDATE_SETTINGS,
EventData = patch.ToJson()
});
return config;
}
}