Skip to content

Commit 12cef6f

Browse files
author
vikasrohit
authored
Merge pull request #189 from maxceem/hotfix/email-user-photo-size
[HOTFIX] [DEV] email user photo size
2 parents 501e03f + b98052f commit 12cef6f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

config/default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ module.exports = {
3434
API_CONTEXT_PATH: process.env.API_CONTEXT_PATH || '/v5/notifications',
3535
TC_API_BASE_URL: process.env.TC_API_BASE_URL || '',
3636

37+
// CloudFront CDN URL. It's used to host and resize images like user avatars.
38+
TC_CDN_URL: process.env.TC_CDN_URL || '',
39+
3740
// Configuration for generating machine to machine auth0 token.
3841
// The token will be used for calling another internal API.
3942
AUTH0_URL: process.env.AUTH0_URL,

connect/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
2+
// size for user photos in emails
3+
EMAIL_USER_PHOTO_SIZE: 80,
4+
25
// periods of time in cron format (node-cron)
36
SCHEDULED_EVENT_PERIOD: {
47
every10minutes: '*/10 * * * *',

connect/notificationServices/email.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const {
1313
SCHEDULED_EVENT_PERIOD,
1414
SETTINGS_EMAIL_SERVICE_ID,
1515
ACTIVE_USER_STATUSES,
16+
EMAIL_USER_PHOTO_SIZE,
1617
} = require('../constants');
1718
const { EVENT_BUNDLES } = require('../events-config');
1819
const helpers = require('../helpers');
@@ -236,7 +237,8 @@ function handler(topicName, messageJSON, notification) {
236237
projectId: messageJSON.projectId,
237238
authorHandle: notification.contents.userHandle,
238239
authorFullName: notification.contents.userFullName,
239-
photoURL: notification.contents.photoURL,
240+
photoURL: `${config.TC_CDN_URL}/avatar/${encodeURIComponent(notification.contents.photoURL)}`
241+
+ `?size=${EMAIL_USER_PHOTO_SIZE}`,
240242
type: notificationType,
241243
emailToAffectedUser: notification.contents.userEmail === userEmail,
242244
},

0 commit comments

Comments
 (0)