mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 21:16:49 +00:00
feat: pk;config
This commit is contained in:
parent
d195c80d92
commit
56d07e0f2d
41 changed files with 648 additions and 313 deletions
|
|
@ -34,4 +34,32 @@ public class SystemControllerV2: PKControllerBase
|
|||
var newSystem = await _repo.UpdateSystem(system.Id, patch);
|
||||
return Ok(newSystem.ToJson(LookupContext.ByOwner, APIVersion.V2));
|
||||
}
|
||||
|
||||
[HttpGet("{systemRef}/settings")]
|
||||
public async Task<IActionResult> GetSystemSettings(string systemRef)
|
||||
{
|
||||
var system = await ResolveSystem(systemRef);
|
||||
if (ContextFor(system) != LookupContext.ByOwner)
|
||||
throw Errors.GenericMissingPermissions;
|
||||
|
||||
var config = await _repo.GetSystemConfig(system.Id);
|
||||
return Ok(config.ToJson());
|
||||
}
|
||||
|
||||
[HttpPatch("{systemRef}/settings")]
|
||||
public async Task<IActionResult> DoSystemSettingsPatch(string systemRef, [FromBody] JObject data)
|
||||
{
|
||||
var system = await ResolveSystem(systemRef);
|
||||
if (ContextFor(system) != LookupContext.ByOwner)
|
||||
throw Errors.GenericMissingPermissions;
|
||||
|
||||
var patch = SystemConfigPatch.FromJson(data);
|
||||
|
||||
patch.AssertIsValid();
|
||||
if (patch.Errors.Count > 0)
|
||||
throw new ModelParseError(patch.Errors);
|
||||
|
||||
var newConfig = await _repo.UpdateSystemConfig(system.Id, patch);
|
||||
return Ok(newConfig.ToJson());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue