feat(bot): add observable notification management

This commit is contained in:
2026-03-24 03:58:00 +04:00
parent 7e9ae75a41
commit 83ffd7df72
18 changed files with 1267 additions and 58 deletions

View File

@@ -181,6 +181,38 @@ export function createDbAdHocNotificationRepository(databaseUrl: string): {
return rows[0] ? mapNotification(rows[0]) : null
},
async updateNotification(input) {
const updates: Record<string, unknown> = {
updatedAt: instantToDate(input.updatedAt)
}
if (input.scheduledFor) {
updates.scheduledFor = instantToDate(input.scheduledFor)
}
if (input.timePrecision) {
updates.timePrecision = input.timePrecision
}
if (input.deliveryMode) {
updates.deliveryMode = input.deliveryMode
}
if (input.dmRecipientMemberIds) {
updates.dmRecipientMemberIds = input.dmRecipientMemberIds
}
const rows = await db
.update(schema.adHocNotifications)
.set(updates)
.where(
and(
eq(schema.adHocNotifications.id, input.notificationId),
eq(schema.adHocNotifications.status, 'scheduled')
)
)
.returning(notificationSelect())
return rows[0] ? mapNotification(rows[0]) : null
},
async listDueNotifications(asOf) {
const rows = await db
.select(notificationSelect())