feat: add a wait before a notice can be accepted

This commit is contained in:
2026-11-13 22:46:07 +01:00
parent 28b6244a17
commit 93036bae89
12 changed files with 131 additions and 7 deletions
@@ -12,7 +12,7 @@ namespace Jellyfin.Plugin.Herald.Storage;
/// </summary>
public class SqliteNoticeStore : INoticeStore
{
private const string NoticeColumns = "id, title, body, require_accept, enabled, target_all, target_users, revision, created_at, updated_at";
private const string NoticeColumns = "id, title, body, require_accept, enabled, target_all, target_users, revision, created_at, updated_at, accept_delay";
private const string AckColumns = "notice_id, revision, user_id, action, timestamp";
private readonly HeraldDatabase _database;
@@ -66,12 +66,13 @@ public class SqliteNoticeStore : INoticeStore
connection,
transaction,
"""
INSERT INTO notices (id, title, body, require_accept, enabled, target_all, target_users, revision, created_at, updated_at)
VALUES ($id, $title, $body, $requireAccept, $enabled, $targetAll, $targetUsers, $revision, $createdAt, $updatedAt)
INSERT INTO notices (id, title, body, require_accept, enabled, target_all, target_users, revision, created_at, updated_at, accept_delay)
VALUES ($id, $title, $body, $requireAccept, $enabled, $targetAll, $targetUsers, $revision, $createdAt, $updatedAt, $acceptDelay)
ON CONFLICT (id) DO UPDATE SET
title = excluded.title,
body = excluded.body,
require_accept = excluded.require_accept,
accept_delay = excluded.accept_delay,
enabled = excluded.enabled,
target_all = excluded.target_all,
target_users = excluded.target_users,
@@ -88,6 +89,7 @@ public class SqliteNoticeStore : INoticeStore
command.Parameters.AddWithValue("$revision", notice.Revision);
command.Parameters.AddWithValue("$createdAt", Db.Time(notice.CreatedAt));
command.Parameters.AddWithValue("$updatedAt", Db.Time(notice.UpdatedAt));
command.Parameters.AddWithValue("$acceptDelay", notice.AcceptDelaySeconds);
return command.ExecuteNonQuery();
});
}
@@ -184,6 +186,7 @@ public class SqliteNoticeStore : INoticeStore
Title = reader.GetString(1),
Body = reader.GetString(2),
RequireAccept = reader.GetBoolean(3),
AcceptDelaySeconds = reader.GetInt32(10),
Enabled = reader.GetBoolean(4),
Target = new NoticeTarget
{