feat: add a wait before a notice can be accepted
This commit is contained in:
@@ -50,6 +50,11 @@ public class HeraldDatabase
|
||||
PRIMARY KEY (user_id, date)
|
||||
);
|
||||
CREATE INDEX ix_watch_daily_date ON watch_daily (date);
|
||||
""",
|
||||
|
||||
// 3: wait before a notice can be accepted
|
||||
"""
|
||||
ALTER TABLE notices ADD COLUMN accept_delay INTEGER NOT NULL DEFAULT 0;
|
||||
"""
|
||||
];
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user