feat: import/export system config
This commit is contained in:
@@ -4,13 +4,13 @@ namespace PluralKit.Core;
|
||||
|
||||
public partial class ModelRepository
|
||||
{
|
||||
public Task<SystemConfig> GetSystemConfig(SystemId system)
|
||||
=> _db.QueryFirst<SystemConfig>(new Query("config").Where("system", system));
|
||||
public Task<SystemConfig> GetSystemConfig(SystemId system, IPKConnection conn = null)
|
||||
=> _db.QueryFirst<SystemConfig>(conn, new Query("config").Where("system", system));
|
||||
|
||||
public async Task<SystemConfig> UpdateSystemConfig(SystemId system, SystemConfigPatch patch)
|
||||
public async Task<SystemConfig> UpdateSystemConfig(SystemId system, SystemConfigPatch patch, IPKConnection conn = null)
|
||||
{
|
||||
var query = patch.Apply(new Query("config").Where("system", system));
|
||||
var config = await _db.QueryFirst<SystemConfig>(query, "returning *");
|
||||
var config = await _db.QueryFirst<SystemConfig>(conn, query, "returning *");
|
||||
|
||||
_ = _dispatch.Dispatch(system, new UpdateDispatchData
|
||||
{
|
||||
|
@@ -80,7 +80,12 @@ public partial class ModelRepository
|
||||
var system = await _db.QueryFirst<PKSystem>(conn, query, "returning *");
|
||||
_logger.Information("Created {SystemId}", system.Id);
|
||||
|
||||
await _db.Execute(conn => conn.QueryAsync("insert into config (system) values (@system)", new { system = system.Id }));
|
||||
var (q, pms) = ("insert into config (system) values (@system)", new { system = system.Id });
|
||||
|
||||
if (conn == null)
|
||||
await _db.Execute(conn => conn.QueryAsync(q, pms));
|
||||
else
|
||||
await conn.QueryAsync(q, pms);
|
||||
|
||||
// no dispatch call here - system was just created, we don't have a webhook URL
|
||||
return system;
|
||||
|
Reference in New Issue
Block a user