app2-api/helpers/notification.helpers.js

41 lines
916 B
JavaScript
Raw Normal View History

2022-02-18 19:32:30 +00:00
const moment = require("moment");
const { tinytom } = require("./message.helper");
const messages = require("./messages.json");
2019-11-11 16:43:08 +00:00
const createNotification = (data) => {
2022-02-18 19:32:30 +00:00
return {
date: data.date,
title: data.title,
body: data.body,
ttl: data.ttl,
priority: data.priority ? data.priority : "high",
recipients: data.recipients,
data: data.data,
userId: data.userId,
};
};
2019-11-11 16:43:08 +00:00
2022-02-18 19:32:30 +00:00
const createNotificationValidatedInscription = (inscription) => {
let jsonMessage = messages.push.confirmInvitation;
2019-11-11 16:43:08 +00:00
2022-02-18 19:32:30 +00:00
const jsonNotification = tinytom(jsonMessage, {
congress: inscription.event.name,
ticketId: inscription.id,
});
2019-11-11 16:43:08 +00:00
2022-02-18 19:32:30 +00:00
return {
...jsonNotification,
date: moment(),
priority: "high",
recipients: {
userIds: [inscription.user.id],
},
};
};
2019-11-11 16:43:08 +00:00
module.exports = {
2022-02-18 19:32:30 +00:00
createNotificationValidatedInscription,
createNotification,
//createMessageNotification
};