mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
One delivery model (models/lib/notificationDelivery.js) for every channel - e-mail, the notification tray and outgoing webhooks - set in the Notifications popup at Admin Panel, board and Member Settings scope, and in each one-way webhook's form: - Content. Webhooks: the text on or off, and which property groups are sent (standard, ids, names, links, actor, people, details), with checklist, list, swimlane and board names, before/after values, the card description and links added as opt-in groups. E-mail and tray: the classic sentence or a clear layout - the board as a link first, the actor and card in bold - and which parts are shown. - Grouping: one message per event, per card, per board, or all together. - Scheduling: immediately, every 5 minutes to 24 hours, or once a day, with optional quiet hours, in the time zone of whoever set it. The most specific explicit setting wins: member, then board, then Admin Panel for e-mail and tray; the webhook, then its board, then Admin Panel for webhooks. A member can only leave their own name out of outgoing webhooks. The built-in defaults keep today's behaviour. Grouped and scheduled webhooks and e-mail go through durable queues that survive restarts; queued webhooks use the SSRF guard and log a blocked address in Admin Panel - Problems. Values of admin-only custom fields now reach only board admins in e-mail and tray, and never a webhook. The new strings are in English in every locale, pending Transifex. Thanks to HaKePlan, Meeques and xet7 ! Fixes #3695, Fixes #5171.
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
import { formatDateForDisplay } from '/client/lib/dateDisplay';
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
import Users from '/models/users';
|
|
import { trayClearItemHtml } from '/client/lib/notificationTray';
|
|
|
|
Template.notification.events({
|
|
async 'click .read-status .materialCheckBox'() {
|
|
const update = {};
|
|
const newReadValue = this.read ? null : new Date();
|
|
update[`profile.notifications.${this.index}.read`] = newReadValue;
|
|
|
|
await Users.updateAsync(Meteor.userId(), { $set: update }).catch((error) => {
|
|
if (error) {
|
|
console.error('Error updating notification:', error);
|
|
}
|
|
});
|
|
},
|
|
'click .remove a'() {
|
|
ReactiveCache.getCurrentUser().removeNotification(this.activityData._id);
|
|
},
|
|
});
|
|
|
|
Template.notification.helpers({
|
|
mode: 'board',
|
|
clearItem() {
|
|
return trayClearItemHtml(this.activityData);
|
|
},
|
|
isOfActivityType(activityId, type) {
|
|
const activity = ReactiveCache.getActivity(activityId);
|
|
return activity && activity.activityType === type;
|
|
},
|
|
activityType(activityId) {
|
|
const activity = ReactiveCache.getActivity(activityId);
|
|
return activity ? activity.activityType : '';
|
|
},
|
|
activityUser(activityId) {
|
|
const activity = ReactiveCache.getActivity(activityId);
|
|
return activity && activity.userId;
|
|
},
|
|
activityDate() {
|
|
const activity = this.activityData;
|
|
if (!activity || !activity.createdAt) return '';
|
|
|
|
const user = ReactiveCache.getCurrentUser();
|
|
if (!user) return '';
|
|
|
|
const dateObj = new Date(activity.createdAt);
|
|
if (Number.isNaN(dateObj.getTime())) return '';
|
|
|
|
const datePart = formatDateForDisplay(dateObj, false);
|
|
const timePart = dateObj.toLocaleTimeString([], {
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
});
|
|
return `${datePart} ${timePart}`.trim();
|
|
},
|
|
});
|