diff --git a/src/user/digest.js b/src/user/digest.js index 62c8a11ae8..06ea1aa967 100644 --- a/src/user/digest.js +++ b/src/user/digest.js @@ -9,7 +9,8 @@ var async = require('async'), user = require('../user'), topics = require('../topics'), batch = require('../batch'), - emailer = require('../emailer'); + emailer = require('../emailer'), + utils = require('../../public/src/utils'); (function(Digest) { Digest.execute = function(interval) { @@ -31,6 +32,22 @@ var async = require('async'), return winston.error('[user/jobs] Could not send digests (' + interval + '): ' + err.message); } + // Fix relative paths in topic data + data.topics.topics = data.topics.topics.map(function(topicObj) { + if (topicObj.hasOwnProperty('teaser') && topicObj.teaser !== undefined) { + if (utils.isRelativeUrl(topicObj.teaser.user.picture)) { + topicObj.teaser.user.picture = nconf.get('url') + topicObj.teaser.user.picture; + } + } else { + if (utils.isRelativeUrl(topicObj.user.picture)) { + topicObj.user.picture = nconf.get('url') + topicObj.user.picture; + } + } + + return topicObj; + }); + return; + data.interval = interval; if (data.subscribers.length) {