From cf4002bcc9fea2f986b3b364cf7f595e3de32520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 10 Feb 2021 17:41:39 -0500 Subject: [PATCH] perf: cache base_url --- src/user/digest.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/user/digest.js b/src/user/digest.js index 2a46d85b3f..93e3d3332a 100644 --- a/src/user/digest.js +++ b/src/user/digest.js @@ -14,6 +14,8 @@ const utils = require('../utils'); const Digest = module.exports; +const baseUrl = nconf.get('base_url'); + Digest.execute = async function (payload) { const digestsDisabled = meta.config.disableEmailSubscriptions === 1; if (digestsDisabled) { @@ -118,10 +120,10 @@ Digest.send = async function (data) { unreadNotifs.forEach((n) => { if (n.image && !n.image.startsWith('http')) { - n.image = nconf.get('base_url') + n.image; + n.image = baseUrl + n.image; } if (n.path) { - n.notification_url = n.path.startsWith('http') ? n.path : nconf.get('base_url') + n.path; + n.notification_url = n.path.startsWith('http') ? n.path : baseUrl + n.path; } }); @@ -211,7 +213,7 @@ async function getTermTopics(term, uid) { const user = topicObj.hasOwnProperty('teaser') && topicObj.teaser && topicObj.teaser.user ? topicObj.teaser.user : topicObj.user; if (user && user.picture && utils.isRelativeUrl(user.picture)) { - user.picture = nconf.get('base_url') + user.picture; + user.picture = baseUrl + user.picture; } } });