mirror of
https://github.com/plankanban/planka.git
synced 2025-12-17 17:23:25 +03:00
ref: Remove board types, refactoring
This commit is contained in:
@@ -1,26 +1,42 @@
|
||||
const valuesValidator = (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isPlainObject(value.user) && !_.isString(value.userId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isPlainObject(value.action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
userOrId: {
|
||||
type: 'ref',
|
||||
custom: (value) => _.isObjectLike(value) || _.isString(value),
|
||||
required: true,
|
||||
},
|
||||
action: {
|
||||
values: {
|
||||
type: 'ref',
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { userId = inputs.userOrId } = inputs.userOrId;
|
||||
const { values } = inputs;
|
||||
|
||||
if (values.user) {
|
||||
values.userId = values.user.id;
|
||||
}
|
||||
|
||||
const notification = await Notification.create({
|
||||
userId,
|
||||
actionId: inputs.action.id,
|
||||
cardId: inputs.action.cardId,
|
||||
...values,
|
||||
actionId: values.action.id,
|
||||
cardId: values.action.cardId,
|
||||
}).fetch();
|
||||
|
||||
sails.sockets.broadcast(`user:${userId}`, 'notificationCreate', {
|
||||
sails.sockets.broadcast(`user:${notification.userId}`, 'notificationCreate', {
|
||||
item: notification,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user