From 70eb31898372e29ae48c2d14bb88459fa2ab2685 Mon Sep 17 00:00:00 2001 From: Maksym Mykhailenko Date: Mon, 13 Apr 2020 19:26:05 +0300 Subject: [PATCH 1/2] fix: resize email user photo size to 80 --- config/default.js | 3 +++ config/development.js | 3 +++ config/production.js | 3 +++ connect/constants.js | 3 +++ connect/notificationServices/email.js | 4 +++- 5 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 config/development.js create mode 100644 config/production.js diff --git a/config/default.js b/config/default.js index 9563efe..9d426a7 100644 --- a/config/default.js +++ b/config/default.js @@ -34,6 +34,9 @@ module.exports = { API_CONTEXT_PATH: process.env.API_CONTEXT_PATH || '/v5/notifications', TC_API_BASE_URL: process.env.TC_API_BASE_URL || '', + // CloudFront CDN URL. It's used to host and resize images like user avatars. + TC_CDN_URL: process.env.TC_CDN_URL || '', + // Configuration for generating machine to machine auth0 token. // The token will be used for calling another internal API. AUTH0_URL: process.env.AUTH0_URL, diff --git a/config/development.js b/config/development.js new file mode 100644 index 0000000..f4ad9c8 --- /dev/null +++ b/config/development.js @@ -0,0 +1,3 @@ +module.exports = { + TC_CDN_URL: 'https://d1aahxkjiobka8.cloudfront.net', +}; diff --git a/config/production.js b/config/production.js new file mode 100644 index 0000000..7ee53e0 --- /dev/null +++ b/config/production.js @@ -0,0 +1,3 @@ +module.exports = { + TC_CDN_URL: 'https://d2nl5eqipnb33q.cloudfront.net' +}; diff --git a/connect/constants.js b/connect/constants.js index 3768ac5..4022ef1 100644 --- a/connect/constants.js +++ b/connect/constants.js @@ -1,4 +1,7 @@ module.exports = { + // size for user photos in emails + EMAIL_USER_PHOTO_SIZE: 80, + // periods of time in cron format (node-cron) SCHEDULED_EVENT_PERIOD: { every10minutes: '*/10 * * * *', diff --git a/connect/notificationServices/email.js b/connect/notificationServices/email.js index 3d608fc..fbc1dd2 100644 --- a/connect/notificationServices/email.js +++ b/connect/notificationServices/email.js @@ -13,6 +13,7 @@ const { SCHEDULED_EVENT_PERIOD, SETTINGS_EMAIL_SERVICE_ID, ACTIVE_USER_STATUSES, + EMAIL_USER_PHOTO_SIZE, } = require('../constants'); const { EVENT_BUNDLES } = require('../events-config'); const helpers = require('../helpers'); @@ -236,7 +237,8 @@ function handler(topicName, messageJSON, notification) { projectId: messageJSON.projectId, authorHandle: notification.contents.userHandle, authorFullName: notification.contents.userFullName, - photoURL: notification.contents.photoURL, + photoURL: `${config.TC_CDN_URL}/avatar/${encodeURIComponent(notification.contents.photoURL)}` + + `?size=${EMAIL_USER_PHOTO_SIZE}`, type: notificationType, emailToAffectedUser: notification.contents.userEmail === userEmail, }, From b98052f9bdf6c0d19d2828b2be6624a47e128b98 Mon Sep 17 00:00:00 2001 From: Maksym Mykhailenko Date: Tue, 14 Apr 2020 10:28:28 +0300 Subject: [PATCH 2/2] chore: remove config files with real values --- config/development.js | 3 --- config/production.js | 3 --- 2 files changed, 6 deletions(-) delete mode 100644 config/development.js delete mode 100644 config/production.js diff --git a/config/development.js b/config/development.js deleted file mode 100644 index f4ad9c8..0000000 --- a/config/development.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - TC_CDN_URL: 'https://d1aahxkjiobka8.cloudfront.net', -}; diff --git a/config/production.js b/config/production.js deleted file mode 100644 index 7ee53e0..0000000 --- a/config/production.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - TC_CDN_URL: 'https://d2nl5eqipnb33q.cloudfront.net' -};