.
This commit is contained in:
parent
37419b8a2a
commit
ed86025b5f
@ -25,7 +25,7 @@
|
||||
"push": {
|
||||
"confirmInvitation": {
|
||||
"title": "{{ congress }}",
|
||||
"message": "Tu inscripción al congreso de {{ congress }} está confirmada.",
|
||||
"body": "Tu inscripción al congreso de {{ congress }} está confirmada.",
|
||||
"data": {
|
||||
"type": "message",
|
||||
"title": "{{ congress }}",
|
||||
|
||||
@ -7,7 +7,7 @@ const createNotification = (data) => {
|
||||
return {
|
||||
date: data.date,
|
||||
title: data.title,
|
||||
body: data.message,
|
||||
body: data.body,
|
||||
ttl: data.ttl,
|
||||
priority: data.priority ? data.priority : 'high',
|
||||
recipients: data.recipients,
|
||||
|
||||
@ -4,9 +4,6 @@ const { Expo } = require('expo-server-sdk');
|
||||
const expo = new Expo();
|
||||
|
||||
const createPushMessage = (data) => {
|
||||
console.log('---------------------------------');
|
||||
console.log(data);
|
||||
console.log('---------------------------------');
|
||||
return {
|
||||
title: data.title,
|
||||
body: data.body,
|
||||
|
||||
@ -10,7 +10,7 @@ const messages = require('../../helpers/messages.json');
|
||||
const eventService = require('./event.service');
|
||||
const eventReservationService = require('./events_reservations.service');
|
||||
const eventInscriptionService = require('./events_inscriptions.service');
|
||||
const notificationController = require('../notification/notification.controller');
|
||||
const notificationService = require('../notification/notification.service');
|
||||
|
||||
const { extractParamsFromRequest, handleErrorResponse, handleResultResponse } = require('../../helpers/controller.helper');
|
||||
|
||||
@ -286,11 +286,12 @@ console.log('>>>>>>>>>>>>>>><NewConfirmedEvent: ', NewConfirmedEvent);
|
||||
|
||||
try {
|
||||
let notification = notificationHelper.createNotificationValidatedInscription(inscription);
|
||||
notificationController.sendNotification(notification);
|
||||
console.log(notification);
|
||||
let result = notificationService.sendNotification(notification, [inscription.user.id]);
|
||||
|
||||
console.log(result);
|
||||
} catch (error) {
|
||||
console.log('No se ha podido mandar email con entrada');
|
||||
console.log('No se ha podido mandar push');
|
||||
};
|
||||
};
|
||||
|
||||
@ -300,6 +301,7 @@ console.log('>>>>>>>>>>>>>>><NewConfirmedEvent: ', NewConfirmedEvent);
|
||||
return handleResultResponse("No se pudo validar inscripción", null, params, res, httpStatus.NOT_FOUND);
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return handleResultResponse("Error al validar inscripción", null, params, res, httpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ const userDeviceService = require('./user_device.service');
|
||||
const eventInscriptionService = require('../events/events_inscriptions.service');
|
||||
const { usersIdsComposer } = require('../../helpers/composes.helper');
|
||||
const pushHelper = require('../../helpers/push.helper');
|
||||
const notificationHelper = require('../../helpers/notification.helpers');
|
||||
const notificationHelper = require('../../helpers/notification.helpers')
|
||||
|
||||
const { extractParamsFromRequest, handleErrorResponse, handleResultResponse } = require('../../helpers/controller.helper');
|
||||
|
||||
@ -63,8 +63,8 @@ const extraControllers = {
|
||||
return handleErrorResponse(controllerOptions.MODULE_NAME, 'sendNotification', new Error('Missing message title'), res)
|
||||
}
|
||||
|
||||
if (!body.message) {
|
||||
return handleErrorResponse(controllerOptions.MODULE_NAME, 'sendNotification', new Error('Missing message content'), res)
|
||||
if (!body.body) {
|
||||
return handleErrorResponse(controllerOptions.MODULE_NAME, 'sendNotification', new Error('Missing body content'), res)
|
||||
}
|
||||
|
||||
// Evento?
|
||||
@ -83,8 +83,6 @@ const extraControllers = {
|
||||
...body,
|
||||
userId: context.user.id
|
||||
});
|
||||
console.log('--------------------');
|
||||
console.log(notification);
|
||||
|
||||
let getUserIds = async () => {
|
||||
if (userIds) {
|
||||
|
||||
@ -12,7 +12,7 @@ const extraMethods = {
|
||||
return {
|
||||
date: data.date,
|
||||
title: data.title,
|
||||
body: data.message,
|
||||
body: data.body,
|
||||
ttl: data.ttl,
|
||||
priority: data.priority,
|
||||
recipients: data.recipients,
|
||||
@ -22,9 +22,6 @@ const extraMethods = {
|
||||
},
|
||||
|
||||
saveNotification: ({ date, title, body, ttl, priority, recipients, data, userId }) => {
|
||||
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<valores de la notificacion');
|
||||
console.log(date, title, body, ttl, priority, recipients, data, userId);
|
||||
|
||||
return models.Notification.create({
|
||||
date: moment(date),
|
||||
title: title,
|
||||
@ -58,7 +55,6 @@ const extraMethods = {
|
||||
return new Promise(function (resolve) {
|
||||
let _userDevices = [];
|
||||
userDevices.forEach(async function (userDevice) {
|
||||
console.log(userDevice);
|
||||
if (!userDeviceService.isValidPushToken(userDevice.token)) {
|
||||
await disableUserDevicePromise(userDevice.token);
|
||||
} else {
|
||||
@ -106,13 +102,11 @@ const extraMethods = {
|
||||
.then(function (notificationRecord) {
|
||||
notification = notificationRecord.toJSON();
|
||||
userIds.forEach(function (userId) {
|
||||
console.log(userId);
|
||||
getUserDevicesList.push(getUserDevicesPromise(userId));
|
||||
});
|
||||
|
||||
return Promise.all(getUserDevicesList)
|
||||
}).then(function (userDeviceList) {
|
||||
console.log(userDeviceList);
|
||||
let result = [];
|
||||
userDeviceList.forEach(function (elements) {
|
||||
elements.forEach(function (item) {
|
||||
|
||||
@ -14,7 +14,7 @@ const deviceTokenInputType = Joi.object().keys({
|
||||
const pushSendEvent = Joi.object().keys({
|
||||
date: Joi.date().optional(),
|
||||
title: Joi.string().required(),
|
||||
message: Joi.string().required(),
|
||||
body: Joi.string().required(),
|
||||
recipients: Joi.object().keys({
|
||||
userIds: Joi.array().optional(),
|
||||
eventId: Joi.string().optional(),
|
||||
|
||||
@ -7,7 +7,6 @@ const extraMethods = {
|
||||
saveNotificationDetails: async function (messages, tickets) {
|
||||
return new Promise(function (resolve) {
|
||||
messages.forEach(async function (message, index) {
|
||||
console.log(message);
|
||||
let notification = models.NotificationDetail.build({
|
||||
...message,
|
||||
token: message.to,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user