mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-05 13:27:54 +00:00
feat: premium ID changes
Some checks failed
Build and push Docker image / .net docker build (push) Has been cancelled
.net checks / run .net tests (push) Has been cancelled
.net checks / dotnet-format (push) Has been cancelled
Build and push Rust service Docker images / rust docker build (push) Has been cancelled
rust checks / cargo fmt (push) Has been cancelled
Some checks failed
Build and push Docker image / .net docker build (push) Has been cancelled
.net checks / run .net tests (push) Has been cancelled
.net checks / dotnet-format (push) Has been cancelled
Build and push Rust service Docker images / rust docker build (push) Has been cancelled
rust checks / cargo fmt (push) Has been cancelled
This commit is contained in:
parent
41f8beb2aa
commit
24b6b0d455
16 changed files with 306 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using SqlKata;
|
||||
using Npgsql;
|
||||
|
||||
namespace PluralKit.Core;
|
||||
|
||||
|
|
@ -20,4 +21,27 @@ public partial class ModelRepository
|
|||
|
||||
return config;
|
||||
}
|
||||
|
||||
public async Task<bool> TryUpdateSystemConfigForIdChange(SystemId system, IPKConnection conn = null)
|
||||
{
|
||||
var query = new Query("system_config")
|
||||
.AsUpdate(new
|
||||
{
|
||||
premium_id_changes_remaining = new UnsafeLiteral("premium_id_changes_remaining - 1")
|
||||
})
|
||||
.Where("system", system);
|
||||
|
||||
try
|
||||
{
|
||||
await _db.ExecuteQuery(conn, query);
|
||||
}
|
||||
catch (PostgresException pe)
|
||||
{
|
||||
if (!pe.Message.Contains("violates check constraint"))
|
||||
throw;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue