Files
wekan/server/methods/boardDueReminders.js
T
Lauri Ojansivu 58d166029c Set due-date reminder days and webhook delivery per board.
Board Settings -> Notifications now has due-date reminders: a board's own
offsets override NOTIFY_DUE_DAYS_BEFORE_AND_AFTER (an empty list turns
them off, an empty field restores the server default), and a switch sends
the board's reminders to all of its enabled outgoing webhooks, whatever
activities those subscribe to. The reminder scan now runs when either the
environment variable or a board sets offsets, and writes a reminder only
for the offsets that board uses. A validated method limited to board
admins stores the setting.

The new strings are English, pending Transifex. add-pending-keys.mjs now
writes symlinked locales once and checks every file before writing any.

Thanks to xet7 !

Fixes #5323,
2026-09-29 13:44:54 +03:00

32 lines
1.5 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { check, Match } from 'meteor/check';
import Boards from '/models/boards';
import { allowIsBoardAdminOrSiteAdmin } from '/server/lib/utils';
import { normalizeBoardDueDays } from '/models/lib/dueNotificationConfig';
// #5323: Board Settings -> Notifications -> due-date reminders. `days` is the
// board's own offset list (null clears it and falls back to the server default
// NOTIFY_DUE_DAYS_BEFORE_AND_AFTER; [] turns reminders off for this board);
// `webhook` sends the reminders to this board's outgoing webhooks too.
Meteor.methods({
async setBoardDueReminders(boardId, days, webhook) {
check(boardId, String);
check(days, Match.OneOf(null, [Match.Integer]));
check(webhook, Boolean);
if (!this.userId) throw new Meteor.Error('not-authorized');
const board = await Boards.findOneAsync(boardId);
if (!board || !(await allowIsBoardAdminOrSiteAdmin(this.userId, board))) {
throw new Meteor.Error('not-authorized');
}
const normalized = days === null ? null : normalizeBoardDueDays(days);
if (days !== null && !normalized) {
throw new Meteor.Error('invalid-due-reminder-days', 'Use up to ten whole days from -14 to 14.');
}
const modifier = normalized
? { $set: { dueReminderDays: normalized, dueReminderWebhook: webhook } }
: { $set: { dueReminderWebhook: webhook }, $unset: { dueReminderDays: '' } };
await Boards.updateAsync(boardId, modifier);
return { days: normalized, webhook };
},
});