diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index b2748477d..58a26dd28 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -49,7 +49,6 @@ module.exports = Self => { }, myOptions); const statusSent = 'sent'; - const statusError = 'error'; for (const queue of notificationQueue) { const queueName = queue.notification().name; @@ -58,7 +57,7 @@ module.exports = Self => { for (const notificationUser of queue.notification().subscription()) { try { const sendParams = { - recipient: notificationUser.user().emailUser().email, + recipient: 'pablone.verdnatura@gmail.com', lang: notificationUser.user().lang }; @@ -75,7 +74,8 @@ module.exports = Self => { await queue.updateAttribute('status', statusSent); } catch (error) { - await queue.updateAttribute('status', statusError); + console.log('error: ', error); + await queue.updateAttribute('status', 'error'); } } } diff --git a/back/model-config.json b/back/model-config.json index ebc0e321b..5144b1724 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -103,6 +103,9 @@ "NotificationSubscription": { "dataSource": "vn" }, + "NotificationTemplate": { + "dataSource": "vn" + }, "Province": { "dataSource": "vn" }, diff --git a/back/models/notificationTemplate.json b/back/models/notificationTemplate.json new file mode 100644 index 000000000..b43bb49e0 --- /dev/null +++ b/back/models/notificationTemplate.json @@ -0,0 +1,24 @@ +{ + "name": "NotificationTemplate", + "base": "VnModel", + "options": { + "mysql": { + "table": "util.notificationTemplate" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "code": { + "type": "string", + "required": true + }, + "description": { + "type": "string", + "required": true + } + } +} \ No newline at end of file diff --git a/db/changes/240201/00-NotificationTemplate.sql b/db/changes/240201/00-NotificationTemplate.sql new file mode 100644 index 000000000..f6b978a5c --- /dev/null +++ b/db/changes/240201/00-NotificationTemplate.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS `util`.`notificationTemplate` ( + `id` int unsigned auto_increment NULL, + `code` varchar(100) NOT NULL, + description varchar(100) NOT NULL, + CONSTRAINT `notificationTemplate_PK` PRIMARY KEY (`id`), + CONSTRAINT `notificationTemplate_UN` UNIQUE KEY (`code`) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE `util`.`notification` ADD templateFk int unsigned NULL; +ALTER TABLE `util`.`notification` ADD CONSTRAINT notification_notificationTemplate_FK + FOREIGN KEY (templateFk) REFERENCES util.notificationTemplate(id); + diff --git a/print/core/component.js b/print/core/component.js index 06ef3033a..9f6cddfec 100644 --- a/print/core/component.js +++ b/print/core/component.js @@ -95,6 +95,8 @@ class Component { build() { const fullPath = path.resolve(__dirname, this.path); + console.log('this.path: ', this.path); + console.log('fullPath: ', fullPath); if (!fs.existsSync(fullPath)) throw new Error(`Template "${this.name}" not found`); diff --git a/print/templates/email/blank-notification/assets/css/import.js b/print/templates/email/blank-notification/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/blank-notification/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/blank-notification/blank-notification.html b/print/templates/email/blank-notification/blank-notification.html new file mode 100644 index 000000000..266db117d --- /dev/null +++ b/print/templates/email/blank-notification/blank-notification.html @@ -0,0 +1,7 @@ + +
+
+

pinga

+
+
+
\ No newline at end of file diff --git a/print/templates/email/blank-notification/blank-notification.js b/print/templates/email/blank-notification/blank-notification.js new file mode 100755 index 000000000..051fb5a6f --- /dev/null +++ b/print/templates/email/blank-notification/blank-notification.js @@ -0,0 +1,19 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component(); +console.log('entra'); +module.exports = { + name: 'blank-notification', + components: { + 'email-body': emailBody.build(), + }, + props: { + title: { + type: String, + required: true + }, + text: { + type: String, + required: true + } + } +};