app2-api/helpers/notification.helpers.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-11-11 16:43:08 +00:00
const moment = require('moment');
const { tinytom } = require('./message.helper');
const messages = require('./messages.json');
const createNotification = (data) => {
return {
date: data.date,
title: data.title,
2019-11-11 17:20:59 +00:00
body: data.body,
2019-11-11 16:43:08 +00:00
ttl: data.ttl,
priority: data.priority ? data.priority : 'high',
recipients: data.recipients,
data: data.data,
userId: data.userId,
_displayInForeground: true,
sound: 'default',
2019-11-11 18:10:34 +00:00
android: {
channelId: 'lqdvi-messages'
}
2019-11-11 16:43:08 +00:00
}
}
createNotificationValidatedInscription = (inscription) => {
let jsonMessage = messages.push.confirmInvitation;
const jsonNotification = tinytom(jsonMessage, {
congress: inscription.event.name,
ticketId: inscription.id,
});
return {
...jsonNotification,
date: moment(),
priority: "high",
_displayInForeground: true,
sound: 'default',
recipients: {
"userIds": [
inscription.user.id,
]
},
}
}
module.exports = {
createNotificationValidatedInscription,
createNotification,
//createMessageNotification
}