feat(webhooks): init, add service/models, add JSON to patch objects
This commit is contained in:
7
PluralKit.Core/Database/Migrations/20.sql
Normal file
7
PluralKit.Core/Database/Migrations/20.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
-- schema version 20: insert date
|
||||
-- add outgoing webhook to systems
|
||||
|
||||
alter table systems add column webhook_url text;
|
||||
alter table systems add column webhook_token text;
|
||||
|
||||
update info set schema_version = 20;
|
@@ -8,6 +8,12 @@ namespace PluralKit.Core
|
||||
{
|
||||
public partial class ModelRepository
|
||||
{
|
||||
public Task<PKGroup?> GetGroup(GroupId id)
|
||||
{
|
||||
var query = new Query("groups").Where("id", id);
|
||||
return _db.QueryFirst<PKGroup?>(query);
|
||||
}
|
||||
|
||||
public Task<PKGroup?> GetGroupByName(SystemId system, string name)
|
||||
{
|
||||
var query = new Query("groups").Where("system", system).WhereRaw("lower(name) = lower(?)", name.ToLower());
|
||||
|
@@ -100,6 +100,9 @@ namespace PluralKit.Core
|
||||
return _db.QueryStream<PKSwitch>(query);
|
||||
}
|
||||
|
||||
public Task<PKSwitch?> GetSwitch(SwitchId id)
|
||||
=> _db.QueryFirst<PKSwitch?>(new Query("switches").Where("id", id));
|
||||
|
||||
public Task<PKSwitch> GetSwitchByUuid(Guid uuid)
|
||||
{
|
||||
var query = new Query("switches").Where("uuid", uuid);
|
||||
|
@@ -6,10 +6,12 @@ namespace PluralKit.Core
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDatabase _db;
|
||||
public ModelRepository(ILogger logger, IDatabase db)
|
||||
private readonly DispatchService _dispatch;
|
||||
public ModelRepository(ILogger logger, IDatabase db, DispatchService dispatch)
|
||||
{
|
||||
_logger = logger.ForContext<ModelRepository>();
|
||||
_db = db;
|
||||
_dispatch = dispatch;
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@ namespace PluralKit.Core
|
||||
internal class DatabaseMigrator
|
||||
{
|
||||
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
|
||||
private const int TargetSchemaVersion = 19;
|
||||
private const int TargetSchemaVersion = 20;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DatabaseMigrator(ILogger logger)
|
||||
|
Reference in New Issue
Block a user