diff --git a/service/package-lock.json b/service/package-lock.json index b3c0d432..29783c56 100644 --- a/service/package-lock.json +++ b/service/package-lock.json @@ -1,12 +1,12 @@ { "name": "alkemio-notifications", - "version": "0.6.6", + "version": "0.6.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "alkemio-notifications", - "version": "0.6.6", + "version": "0.6.7", "license": "EUPL-1.2", "dependencies": { "@alkemio/client-lib": "^0.17.3", @@ -22,6 +22,7 @@ "apollo-server-express": "^3.3.0", "cross-env": "^7.0.3", "dotenv": "^10.0.0", + "markdown-to-text": "^0.1.1", "module-alias": "^2.2.2", "nest-winston": "^1.5.0", "nodemon": "^2.0.12", @@ -2916,6 +2917,11 @@ "@types/node": "*" } }, + "node_modules/@types/chai": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==" + }, "node_modules/@types/connect": { "version": "3.4.35", "license": "MIT", @@ -3092,6 +3098,11 @@ "version": "1.3.2", "license": "MIT" }, + "node_modules/@types/mocha": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", + "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==" + }, "node_modules/@types/module-alias": { "version": "2.0.1", "dev": true, @@ -6826,9 +6837,10 @@ "license": "Apache-2.0" }, "node_modules/fast-glob": { - "version": "3.2.6", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, - "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -6837,7 +6849,7 @@ "micromatch": "^4.0.4" }, "engines": { - "node": ">=8" + "node": ">=8.6.0" } }, "node_modules/fast-json-stable-stringify": { @@ -10610,6 +10622,15 @@ "license": "MIT", "optional": true }, + "node_modules/markdown-to-text": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/markdown-to-text/-/markdown-to-text-0.1.1.tgz", + "integrity": "sha512-co/J5l8mJ2RK9wD/nQRGwO7JxoeyfvVNtOZll016EdAX2qYkwCWMdtYvJO42b41Ho7GFEJMuly9llf0Nj+ReQw==", + "dependencies": { + "@types/chai": "^4.2.14", + "@types/mocha": "^8.2.0" + } + }, "node_modules/measured-core": { "version": "1.51.1", "license": "MIT", @@ -16476,6 +16497,11 @@ "@types/node": "*" } }, + "@types/chai": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==" + }, "@types/connect": { "version": "3.4.35", "requires": { @@ -16630,6 +16656,11 @@ "@types/mime": { "version": "1.3.2" }, + "@types/mocha": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", + "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==" + }, "@types/module-alias": { "version": "2.0.1", "dev": true @@ -19183,7 +19214,9 @@ "dev": true }, "fast-glob": { - "version": "3.2.6", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -21773,6 +21806,15 @@ "version": "1.0.0", "optional": true }, + "markdown-to-text": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/markdown-to-text/-/markdown-to-text-0.1.1.tgz", + "integrity": "sha512-co/J5l8mJ2RK9wD/nQRGwO7JxoeyfvVNtOZll016EdAX2qYkwCWMdtYvJO42b41Ho7GFEJMuly9llf0Nj+ReQw==", + "requires": { + "@types/chai": "^4.2.14", + "@types/mocha": "^8.2.0" + } + }, "measured-core": { "version": "1.51.1", "optional": true, diff --git a/service/package.json b/service/package.json index 605137ec..779f0407 100644 --- a/service/package.json +++ b/service/package.json @@ -1,6 +1,6 @@ { "name": "alkemio-notifications", - "version": "0.6.6", + "version": "0.6.7", "description": "Alkemio notifications service", "author": "Alkemio Foundation", "private": false, @@ -48,6 +48,7 @@ "apollo-server-express": "^3.3.0", "cross-env": "^7.0.3", "dotenv": "^10.0.0", + "markdown-to-text": "^0.1.1", "module-alias": "^2.2.2", "nest-winston": "^1.5.0", "nodemon": "^2.0.12", diff --git a/service/src/services/domain/builders/communication-user-mention/communication.user.mention.notification.builder.ts b/service/src/services/domain/builders/communication-user-mention/communication.user.mention.notification.builder.ts index 5520fe58..fac1d262 100644 --- a/service/src/services/domain/builders/communication-user-mention/communication.user.mention.notification.builder.ts +++ b/service/src/services/domain/builders/communication-user-mention/communication.user.mention.notification.builder.ts @@ -10,6 +10,7 @@ import { NotificationTemplateType } from '@src/types/notification.template.type' import { CommunicationUserMentionEmailPayload } from '@common/email-template-payload'; import { ALKEMIO_URL_GENERATOR } from '@src/common/enums/providers'; import { UserPreferenceType } from '@alkemio/client-lib'; +import { convertMarkdownToText } from '@src/utils/markdown-to-text.util'; @Injectable() export class CommunicationUserMentionNotificationBuilder @@ -66,6 +67,8 @@ export class CommunicationUserMentionNotificationBuilder ); const alkemioURL = this.alkemioUrlGenerator.createPlatformURL(); + const htmlComment: string = convertMarkdownToText(eventPayload.comment); + return { emailFrom: 'info@alkem.io', commentSender: { @@ -77,7 +80,7 @@ export class CommunicationUserMentionNotificationBuilder email: recipient.email, notificationPreferences: notificationPreferenceURL, }, - comment: eventPayload.comment, + comment: htmlComment, platform: { url: alkemioURL, }, diff --git a/service/src/utils/markdown-to-text.util.ts b/service/src/utils/markdown-to-text.util.ts new file mode 100644 index 00000000..b8f4cf32 --- /dev/null +++ b/service/src/utils/markdown-to-text.util.ts @@ -0,0 +1,5 @@ +import removeMarkdown from 'markdown-to-text'; + +export function convertMarkdownToText(markdown: string): string { + return removeMarkdown(markdown); +}