From 05c724de30ef345c34f8d6ecbdd9278ac7fc57ec Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 27 Jan 2017 11:26:05 -0500 Subject: [PATCH] added new hook for messaging teaser retrieval, and casting input as String before execuring stripTags templates helper --- public/src/modules/helpers.js | 4 ++-- src/messaging.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js index a913da80b7..3035d29fc4 100644 --- a/public/src/modules/helpers.js +++ b/public/src/modules/helpers.js @@ -69,10 +69,10 @@ helpers.stripTags = function (str) { if (typeof S !== 'undefined') { - return S(str).stripTags().s; + return S(String(str)).stripTags().s; } else { var S = require('string'); - return S(str).stripTags().s; + return S(String(str)).stripTags().s; } }; diff --git a/src/messaging.js b/src/messaging.js index 5bb668ae6e..a37503e3e3 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -210,7 +210,9 @@ Messaging.getTeaser = function (uid, roomId, callback) { }, function (user, next) { teaser.user = user; - next(null, teaser); + plugins.fireHook('filter:messaging.getTeaser', { teaser: teaser }, function (err, data) { + next(err, data.teaser); + }); } ], callback); };