The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://transifex.com/wekan/wekan only.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
wekan/server/notifications/notifications.js

38 lines
1.1 KiB

// a map of notification service, like email, web, IM, qq, etc.
// serviceName -> callback(user, title, description, params)
// expected arguments to callback:
// - user: Meteor user object
// - title: String, TAPi18n key
// - description, String, TAPi18n key
// - params: Object, values extracted from context, to used for above two TAPi18n keys
// see example call to Notifications.notify() in models/activities.js
const notifyServices = {};
Notifications = {
subscribe: (serviceName, callback) => {
notifyServices[serviceName] = callback;
},
unsubscribe: serviceName => {
if (typeof notifyServices[serviceName] === 'function')
delete notifyServices[serviceName];
},
getUsers: watchers => {
const users = [];
watchers.forEach(userId => {
const user = Users.findOne(userId);
if (user) users.push(user);
});
return users;
},
notify: (user, title, description, params) => {
for (const k in notifyServices) {
const notifyImpl = notifyServices[k];
if (notifyImpl && typeof notifyImpl === 'function')
notifyImpl(user, title, description, params);
}
},
};