From 5980c77e7696552c6599a2888d04d5afbafbbfd3 Mon Sep 17 00:00:00 2001 From: cryptoethic Date: Thu, 4 Jun 2020 02:04:31 +0200 Subject: [PATCH 1/2] fix: parse post content before sending notification --- library.js | 8 +++++++- package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library.js b/library.js index 04563d3..dac6aea 100644 --- a/library.js +++ b/library.js @@ -9,6 +9,7 @@ var nconf = module.parent.require('nconf'); var db = require.main.require('./src/database'); var Topics = require.main.require('./src/topics'); var User = require.main.require('./src/user'); +var Posts = require.main.require('./src/posts'); var Groups = require.main.require('./src/groups'); var Notifications = require.main.require('./src/notifications'); var Privileges = require.main.require('./src/privileges'); @@ -186,7 +187,12 @@ function sendNotificationToUids(postData, uids, nidType, notificationText) { var notification; async.waterfall([ function (next) { - createNotification(postData, nidType, notificationText, next); + Posts.parsePost(postData) + .then((parsedPost => next(null, parsedPost))) + .catch(next); + }, + function (postObject, next) { + createNotification(postObject, nidType, notificationText, next); }, function (_notification, next) { notification = _notification; diff --git a/package.json b/package.json index 8a78b61..b1bbee9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodebb-plugin-mentions", - "version": "2.7.4", + "version": "2.7.5", "description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username", "main": "library.js", "scripts": { From 3b3d0a88356eec8906cb1858be771636c1baa26a Mon Sep 17 00:00:00 2001 From: cryptoethic Date: Thu, 4 Jun 2020 02:15:06 +0200 Subject: [PATCH 2/2] fix: replace relative paths to absolute for imgs and urls --- library.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library.js b/library.js index dac6aea..6d57d5d 100644 --- a/library.js +++ b/library.js @@ -192,6 +192,8 @@ function sendNotificationToUids(postData, uids, nidType, notificationText) { .catch(next); }, function (postObject, next) { + postObject.content = Posts.relativeToAbsolute(postObject.content, Posts.urlRegex); + postObject.content = Posts.relativeToAbsolute(postObject.content, Posts.imgRegex); createNotification(postObject, nidType, notificationText, next); }, function (_notification, next) {