WIP: 6367-blankNotification #1903

Draft
pablone wants to merge 11 commits from 6367-blankNotification into dev
5 changed files with 26 additions and 16 deletions
Showing only changes of commit 97b6cac486 - Show all commits

View File

@ -16,19 +16,18 @@ module.exports = Self => {
Self.send = async options => {
const models = Self.app.models;
const findStatus = 'pending';
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const notificationQueue = await models.NotificationQueue.find({
where: {status: findStatus},
where: {status: 'pending'},
include: [
{
relation: 'notification',
scope: {
include: {
include: [{
relation: 'subscription',
scope: {
include: {
@ -40,18 +39,21 @@ module.exports = Self => {
}
}
}
}
}
},
}, {
relation: 'notificationTemplate',
fields: ['id']
}]
}
}
]
}]
}, myOptions);
console.log('notificationQueue: ', notificationQueue);
const statusSent = 'sent';
for (const queue of notificationQueue) {
const queueName = queue.notification().name;
const queueName = queue.notification().notificationTemplate().code;
const queueParams = JSON.parse(queue.params);
for (const notificationUser of queue.notification().subscription()) {
@ -74,7 +76,6 @@ module.exports = Self => {
await queue.updateAttribute('status', statusSent);
} catch (error) {
console.log('error: ', error);
await queue.updateAttribute('status', 'error');
}
}

View File

@ -25,6 +25,11 @@
"type": "hasMany",
"model": "NotificationSubscription",
"foreignKey": "notificationFk"
},
"notificationTemplate": {
"type": "belongsTo",
"model": "NotificationTemplate",
"foreignKey": "templateFk"
}
}
}

View File

@ -18,6 +18,7 @@ class Email extends Component {
}
async getSubject() {
if (this.args.subject) return this.args.subject;
return (await this.getUserLocale())['subject'];
}
@ -77,7 +78,8 @@ class Email extends Component {
for (let attachment of options.attachments)
attachments.push(attachment);
}
console.log(typeof this.args);
console.log(this.args?.subject);
const localeSubject = await this.getSubject();
const mailOptions = {
to: this.args.recipient,

View File

@ -1,7 +1,8 @@
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>pinga</h1>
<h1 v-html="title" align="center"></h1>
<p v-html="text"></p>
</div>
</div>
</email-body>

View File

@ -1,10 +1,9 @@
const Component = require(`vn-print/core/component`);
const emailBody = new Component();
console.log('entra');
const emailBody = new Component('email-body');
module.exports = {
name: 'blank-notification',
components: {
'email-body': emailBody.build(),
'email-body': emailBody.build()
},
props: {
title: {
@ -12,8 +11,10 @@ module.exports = {
required: true
},
text: {
type: String,
required: true
type: String
},
subject: {
type: String
}
}
};