From aa1fd1385a87d7f65ce3a07f49fe5f0cbafb7744 Mon Sep 17 00:00:00 2001 From: Raymond Jacobson Date: Tue, 30 Jun 2026 15:28:39 -0700 Subject: [PATCH] Route notification images through API content gateway --- apps/notifications/README.md | 1 + .../src/__tests__/contentNodeEnv.test.ts | 40 +++++++++++++++++++ .../mappings/addTrackToPlaylist.test.ts | 2 +- .../mappings/artistRemixContestEnded.test.ts | 2 +- .../artistRemixContestEndingSoon.test.ts | 2 +- .../artistRemixContestSubmissions.test.ts | 4 +- .../src/__tests__/mappings/comment.test.ts | 2 +- .../__tests__/mappings/commentMention.test.ts | 2 +- .../mappings/commentReaction.test.ts | 4 +- .../__tests__/mappings/commentThread.test.ts | 2 +- .../src/__tests__/mappings/cosign.test.ts | 2 +- .../src/__tests__/mappings/create.test.ts | 10 ++--- .../mappings/fanClubTextPost.test.ts | 2 +- .../mappings/fanRemixContestEnded.test.ts | 2 +- .../fanRemixContestEndingSoon.test.ts | 2 +- .../mappings/fanRemixContestStarted.test.ts | 2 +- .../fanRemixContestWinnersSelected.test.ts | 2 +- .../src/__tests__/mappings/milestone.test.ts | 2 +- .../src/__tests__/mappings/remix.test.ts | 2 +- .../__tests__/mappings/repostOfRepost.test.ts | 6 +-- .../src/__tests__/mappings/save.test.ts | 4 +- .../__tests__/mappings/saveOfRepost.test.ts | 6 +-- .../src/__tests__/mappings/tastemaker.test.ts | 2 +- .../__tests__/mappings/trendingTrack.test.ts | 2 +- .../mappings/trendingUnderground.test.ts | 2 +- .../mappings/usdcPurchaseSeller.test.ts | 4 +- .../src/email/notifications/renderEmail.ts | 16 +++----- apps/notifications/src/utils/env.ts | 8 +++- 28 files changed, 90 insertions(+), 47 deletions(-) create mode 100644 apps/notifications/src/__tests__/contentNodeEnv.test.ts diff --git a/apps/notifications/README.md b/apps/notifications/README.md index 2bdcb520..b84b2206 100644 --- a/apps/notifications/README.md +++ b/apps/notifications/README.md @@ -91,6 +91,7 @@ To find `targetARN`: query identity DB table `NotificationDeviceTokens`, e.g. `s - `NOTIFICATIONS_LOG_REMOTE_CONFIG_SNAPSHOT` – set to **`1`** to log a one-shot **`Remote config snapshot (Optimizely)`** at startup (all push flags + raw vs effective) - `GIT_COMMIT`, `IMAGE_TAG`, `BUILD_TIME` – (optional) deploy metadata for logs and `/health_check`; see Dockerfile build-args - `SENDGRID_API_KEY` – email +- `NOTIFICATIONS_CONTENT_NODE_ENDPOINT` – (optional) stable public `/content` gateway for email images; default **`https://api.audius.co`** - `ANNOUNCEMENT_SEND_SECRET` – (optional) if set, `POST /internal/send-notification` requires `Authorization: Bearer ` (used by notifications-dashboard). Optional body field **`notification_campaign_id`** is stored on the notification row and included on mobile push payloads. ### Push pipeline logs diff --git a/apps/notifications/src/__tests__/contentNodeEnv.test.ts b/apps/notifications/src/__tests__/contentNodeEnv.test.ts new file mode 100644 index 00000000..d702f58e --- /dev/null +++ b/apps/notifications/src/__tests__/contentNodeEnv.test.ts @@ -0,0 +1,40 @@ +import { getContentNode } from '../utils/env' +import { formatImageUrl } from '../utils/format' + +describe('content node env', () => { + const oldNotificationsEndpoint = + process.env.NOTIFICATIONS_CONTENT_NODE_ENDPOINT + const oldContentEndpoint = process.env.CONTENT_NODE_ENDPOINT + + afterEach(() => { + if (oldNotificationsEndpoint === undefined) { + delete process.env.NOTIFICATIONS_CONTENT_NODE_ENDPOINT + } else { + process.env.NOTIFICATIONS_CONTENT_NODE_ENDPOINT = oldNotificationsEndpoint + } + + if (oldContentEndpoint === undefined) { + delete process.env.CONTENT_NODE_ENDPOINT + } else { + process.env.CONTENT_NODE_ENDPOINT = oldContentEndpoint + } + }) + + it('uses the API content gateway by default', () => { + delete process.env.NOTIFICATIONS_CONTENT_NODE_ENDPOINT + delete process.env.CONTENT_NODE_ENDPOINT + + expect(getContentNode()).toBe('https://api.audius.co') + expect(formatImageUrl('image-cid', 150)).toBe( + 'https://api.audius.co/content/image-cid/150x150.jpg' + ) + }) + + it('allows notification-specific gateway overrides', () => { + process.env.NOTIFICATIONS_CONTENT_NODE_ENDPOINT = + 'https://images.example.com/' + process.env.CONTENT_NODE_ENDPOINT = 'https://generic.example.com' + + expect(getContentNode()).toBe('https://images.example.com') + }) +}) diff --git a/apps/notifications/src/__tests__/mappings/addTrackToPlaylist.test.ts b/apps/notifications/src/__tests__/mappings/addTrackToPlaylist.test.ts index 2ae9ba21..8a9fe49d 100644 --- a/apps/notifications/src/__tests__/mappings/addTrackToPlaylist.test.ts +++ b/apps/notifications/src/__tests__/mappings/addTrackToPlaylist.test.ts @@ -80,7 +80,7 @@ describe('Add track to playlist notification', () => { playlistId: 55, type: 'AddTrackToPlaylist' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/artistRemixContestEnded.test.ts b/apps/notifications/src/__tests__/mappings/artistRemixContestEnded.test.ts index c94a1fee..424c6b05 100644 --- a/apps/notifications/src/__tests__/mappings/artistRemixContestEnded.test.ts +++ b/apps/notifications/src/__tests__/mappings/artistRemixContestEnded.test.ts @@ -68,7 +68,7 @@ describe('Artist Remix Contest Ended Notification', () => { type: 'ArtistRemixContestEnded', entityId: 12345 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/artistRemixContestEndingSoon.test.ts b/apps/notifications/src/__tests__/mappings/artistRemixContestEndingSoon.test.ts index 1c2f5f15..75a8f4b5 100644 --- a/apps/notifications/src/__tests__/mappings/artistRemixContestEndingSoon.test.ts +++ b/apps/notifications/src/__tests__/mappings/artistRemixContestEndingSoon.test.ts @@ -77,7 +77,7 @@ describe('Artist Remix Contest Ending Soon Notification', () => { entityId: 12345, entityUserId: 99 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/artistRemixContestSubmissions.test.ts b/apps/notifications/src/__tests__/mappings/artistRemixContestSubmissions.test.ts index 76715238..54eb5ed3 100644 --- a/apps/notifications/src/__tests__/mappings/artistRemixContestSubmissions.test.ts +++ b/apps/notifications/src/__tests__/mappings/artistRemixContestSubmissions.test.ts @@ -69,7 +69,7 @@ describe('Artist Remix Contest Submissions Notification', () => { eventId: 999, milestone: 1 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) @@ -119,7 +119,7 @@ describe('Artist Remix Contest Submissions Notification', () => { eventId: 999, milestone: 10 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/comment.test.ts b/apps/notifications/src/__tests__/mappings/comment.test.ts index e6cf41d6..08a4f7c3 100644 --- a/apps/notifications/src/__tests__/mappings/comment.test.ts +++ b/apps/notifications/src/__tests__/mappings/comment.test.ts @@ -88,7 +88,7 @@ describe('Comment Notification', () => { entityId: 10, commentId: 1 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/commentMention.test.ts b/apps/notifications/src/__tests__/mappings/commentMention.test.ts index 590f1b93..41f1d475 100644 --- a/apps/notifications/src/__tests__/mappings/commentMention.test.ts +++ b/apps/notifications/src/__tests__/mappings/commentMention.test.ts @@ -93,7 +93,7 @@ describe('Comment Mention Notification', () => { entityId: 1, commentId: 1 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/commentReaction.test.ts b/apps/notifications/src/__tests__/mappings/commentReaction.test.ts index 2be96d3a..21da0c71 100644 --- a/apps/notifications/src/__tests__/mappings/commentReaction.test.ts +++ b/apps/notifications/src/__tests__/mappings/commentReaction.test.ts @@ -97,7 +97,7 @@ describe('Comment Reaction Notification', () => { userIds: [2], commentId: 1 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) @@ -246,7 +246,7 @@ describe('Comment Reaction Notification', () => { commentId: 1 }, imageUrl: - 'https://creatornode2.audius.co/content/contest-hash/150x150.jpg' + 'https://api.audius.co/content/contest-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/commentThread.test.ts b/apps/notifications/src/__tests__/mappings/commentThread.test.ts index 7b3523b1..2fc42c7b 100644 --- a/apps/notifications/src/__tests__/mappings/commentThread.test.ts +++ b/apps/notifications/src/__tests__/mappings/commentThread.test.ts @@ -100,7 +100,7 @@ describe('Comment Thread Notification', () => { userIds: [2], commentId: 2 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/cosign.test.ts b/apps/notifications/src/__tests__/mappings/cosign.test.ts index e5027acc..cae88550 100644 --- a/apps/notifications/src/__tests__/mappings/cosign.test.ts +++ b/apps/notifications/src/__tests__/mappings/cosign.test.ts @@ -84,7 +84,7 @@ describe('Cosign Notification', () => { id: 'timestamp:1589373217:group_id:cosign:parent_track10:original_track:20', type: 'RemixCosign' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/create.test.ts b/apps/notifications/src/__tests__/mappings/create.test.ts index 5bc5c6ce..b0813cdf 100644 --- a/apps/notifications/src/__tests__/mappings/create.test.ts +++ b/apps/notifications/src/__tests__/mappings/create.test.ts @@ -78,7 +78,7 @@ describe('Create Notification', () => { userId: 1, entityType: 'Track' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) @@ -138,7 +138,7 @@ describe('Create Notification', () => { userId: 1, entityType: 'Track' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) @@ -162,7 +162,7 @@ describe('Create Notification', () => { userId: 1, entityType: 'Track' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) @@ -260,7 +260,7 @@ describe('Create Notification', () => { userId: 1, entityType: 'Playlist' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) @@ -350,7 +350,7 @@ describe('Create Notification', () => { userId: 1, entityType: 'Album' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/fanClubTextPost.test.ts b/apps/notifications/src/__tests__/mappings/fanClubTextPost.test.ts index ee170f72..42780281 100644 --- a/apps/notifications/src/__tests__/mappings/fanClubTextPost.test.ts +++ b/apps/notifications/src/__tests__/mappings/fanClubTextPost.test.ts @@ -72,7 +72,7 @@ describe('Fan Club Text Post Notification', () => { commentId: 100 }), imageUrl: - 'https://creatornode2.audius.co/content/artist-pfp-hash/150x150.jpg' + 'https://api.audius.co/content/artist-pfp-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/fanRemixContestEnded.test.ts b/apps/notifications/src/__tests__/mappings/fanRemixContestEnded.test.ts index 033dea91..93b2c79d 100644 --- a/apps/notifications/src/__tests__/mappings/fanRemixContestEnded.test.ts +++ b/apps/notifications/src/__tests__/mappings/fanRemixContestEnded.test.ts @@ -78,7 +78,7 @@ describe('Fan Remix Contest Ended Notification', () => { entityId: 12345, entityUserId: 99 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/fanRemixContestEndingSoon.test.ts b/apps/notifications/src/__tests__/mappings/fanRemixContestEndingSoon.test.ts index 46ab3511..5ef11abd 100644 --- a/apps/notifications/src/__tests__/mappings/fanRemixContestEndingSoon.test.ts +++ b/apps/notifications/src/__tests__/mappings/fanRemixContestEndingSoon.test.ts @@ -77,7 +77,7 @@ describe('Fan Remix Contest Ending Soon Notification', () => { entityId: 12345, entityUserId: 99 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/fanRemixContestStarted.test.ts b/apps/notifications/src/__tests__/mappings/fanRemixContestStarted.test.ts index b5543050..47eacb5c 100644 --- a/apps/notifications/src/__tests__/mappings/fanRemixContestStarted.test.ts +++ b/apps/notifications/src/__tests__/mappings/fanRemixContestStarted.test.ts @@ -77,7 +77,7 @@ describe('Fan Remix Contest Started Notification', () => { entityId: 12345, entityUserId: 99 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/fanRemixContestWinnersSelected.test.ts b/apps/notifications/src/__tests__/mappings/fanRemixContestWinnersSelected.test.ts index 0020bfb6..1adfb90b 100644 --- a/apps/notifications/src/__tests__/mappings/fanRemixContestWinnersSelected.test.ts +++ b/apps/notifications/src/__tests__/mappings/fanRemixContestWinnersSelected.test.ts @@ -78,7 +78,7 @@ describe('Fan Remix Contest Winners Selected Notification', () => { entityId: 12345, entityUserId: 99 }), - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' }) ) }) diff --git a/apps/notifications/src/__tests__/mappings/milestone.test.ts b/apps/notifications/src/__tests__/mappings/milestone.test.ts index 701fa0ef..071e1c7a 100644 --- a/apps/notifications/src/__tests__/mappings/milestone.test.ts +++ b/apps/notifications/src/__tests__/mappings/milestone.test.ts @@ -173,7 +173,7 @@ describe('Milestone Notification', () => { id: 'timestamp:1589373217:group_id:milestone:TRACK_REPOST_COUNT:id:2:threshold:10', type: 'MilestoneRepost' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/remix.test.ts b/apps/notifications/src/__tests__/mappings/remix.test.ts index 0cd004db..4866a443 100644 --- a/apps/notifications/src/__tests__/mappings/remix.test.ts +++ b/apps/notifications/src/__tests__/mappings/remix.test.ts @@ -72,7 +72,7 @@ describe('Remix Notification', () => { id: 'timestamp:1589373217:group_id:remix:track:20:parent_track:10', type: 'RemixCreate' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/repostOfRepost.test.ts b/apps/notifications/src/__tests__/mappings/repostOfRepost.test.ts index ea23b9c3..48b6e52f 100644 --- a/apps/notifications/src/__tests__/mappings/repostOfRepost.test.ts +++ b/apps/notifications/src/__tests__/mappings/repostOfRepost.test.ts @@ -118,7 +118,7 @@ describe('Repost Of Repost Notification', () => { entityId: 10, userIds: [3] }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ]) }) @@ -148,7 +148,7 @@ describe('Repost Of Repost Notification', () => { entityType: 'Playlist', entityId: 10 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ]) }) @@ -178,7 +178,7 @@ describe('Repost Of Repost Notification', () => { entityType: 'Album', entityId: 10 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ]) }) diff --git a/apps/notifications/src/__tests__/mappings/save.test.ts b/apps/notifications/src/__tests__/mappings/save.test.ts index 93ec5e06..ae1ed10f 100644 --- a/apps/notifications/src/__tests__/mappings/save.test.ts +++ b/apps/notifications/src/__tests__/mappings/save.test.ts @@ -68,7 +68,7 @@ describe('Save Notification', () => { type: 'Favorite', userIds: [2] }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) @@ -112,7 +112,7 @@ describe('Save Notification', () => { type: 'Favorite', userIds: [2] }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/saveOfRepost.test.ts b/apps/notifications/src/__tests__/mappings/saveOfRepost.test.ts index 3de1cd95..696e2f18 100644 --- a/apps/notifications/src/__tests__/mappings/saveOfRepost.test.ts +++ b/apps/notifications/src/__tests__/mappings/saveOfRepost.test.ts @@ -119,7 +119,7 @@ describe('Save Of Repost Notification', () => { entityType: 'Track', entityId: 10 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ]) }) @@ -149,7 +149,7 @@ describe('Save Of Repost Notification', () => { entityType: 'Playlist', entityId: 10 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ]) }) @@ -179,7 +179,7 @@ describe('Save Of Repost Notification', () => { entityType: 'Album', entityId: 10 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ]) }) diff --git a/apps/notifications/src/__tests__/mappings/tastemaker.test.ts b/apps/notifications/src/__tests__/mappings/tastemaker.test.ts index 736ef17a..21984168 100644 --- a/apps/notifications/src/__tests__/mappings/tastemaker.test.ts +++ b/apps/notifications/src/__tests__/mappings/tastemaker.test.ts @@ -89,7 +89,7 @@ describe('Tastemaker Notification', () => { entityType: 'Track', entityId: 3 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/trendingTrack.test.ts b/apps/notifications/src/__tests__/mappings/trendingTrack.test.ts index 960eb7da..955fff49 100644 --- a/apps/notifications/src/__tests__/mappings/trendingTrack.test.ts +++ b/apps/notifications/src/__tests__/mappings/trendingTrack.test.ts @@ -85,7 +85,7 @@ describe('Trending Track Notification', () => { id: 'timestamp:1589373217:group_id:trending:time_range:week:genre:all:rank:3:track_id:10:timestamp:1677261600', type: 'TrendingTrack' }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/trendingUnderground.test.ts b/apps/notifications/src/__tests__/mappings/trendingUnderground.test.ts index 4b5e9d2c..bc6cb72c 100644 --- a/apps/notifications/src/__tests__/mappings/trendingUnderground.test.ts +++ b/apps/notifications/src/__tests__/mappings/trendingUnderground.test.ts @@ -78,7 +78,7 @@ describe('Trending Underground Notification', () => { title: "📈 You're Trending", body: `track_title_10 is #3 on Underground Trending right now!`, data: {}, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) }) diff --git a/apps/notifications/src/__tests__/mappings/usdcPurchaseSeller.test.ts b/apps/notifications/src/__tests__/mappings/usdcPurchaseSeller.test.ts index d01fec75..44ef36bd 100644 --- a/apps/notifications/src/__tests__/mappings/usdcPurchaseSeller.test.ts +++ b/apps/notifications/src/__tests__/mappings/usdcPurchaseSeller.test.ts @@ -95,7 +95,7 @@ describe('USDC Purchase Seller', () => { type: 'USDCPurchaseSeller', entityId: 10 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) @@ -250,7 +250,7 @@ describe('USDC Purchase Seller', () => { type: 'USDCPurchaseSeller', entityId: 15 }, - imageUrl: 'https://creatornode2.audius.co/content/test-hash/150x150.jpg' + imageUrl: 'https://api.audius.co/content/test-hash/150x150.jpg' } ) diff --git a/apps/notifications/src/email/notifications/renderEmail.ts b/apps/notifications/src/email/notifications/renderEmail.ts index 36f422a6..02626b10 100644 --- a/apps/notifications/src/email/notifications/renderEmail.ts +++ b/apps/notifications/src/email/notifications/renderEmail.ts @@ -116,25 +116,21 @@ const getUserProfileUrl = (user: UserResource) => { } const getTrackCoverArt = (track: TrackResource) => { - // Match getUserProfileUrl: when the owner's creator_node_endpoint is missing - // we still want a working URL, so fall back to the stable CN gateway. - const primaryEndpoint = - track.creator_node_endpoint?.split(',')[0]?.trim() || getContentNode() + const contentNode = getContentNode() if (track.cover_art_sizes) { - return `${primaryEndpoint}/content/${track.cover_art_sizes}/1000x1000.jpg` + return `${contentNode}/content/${track.cover_art_sizes}/1000x1000.jpg` } else if (track.cover_art) { - return `${primaryEndpoint}/content/${track.cover_art}` + return `${contentNode}/content/${track.cover_art}` } return DEFAULT_TRACK_COVER_ART_URL } const getPlaylistImage = (playlist: PlaylistResource) => { - const primaryEndpoint = - playlist.creator_node_endpoint?.split(',')[0]?.trim() || getContentNode() + const contentNode = getContentNode() if (playlist.playlist_image_sizes_multihash) { - return `${primaryEndpoint}/content/${playlist.playlist_image_sizes_multihash}/1000x1000.jpg` + return `${contentNode}/content/${playlist.playlist_image_sizes_multihash}/1000x1000.jpg` } else if (playlist.playlist_image_multihash) { - return `${primaryEndpoint}/content/${playlist.playlist_image_multihash}` + return `${contentNode}/content/${playlist.playlist_image_multihash}` } return DEFAULT_PLAYLIST_IMAGE_URL } diff --git a/apps/notifications/src/utils/env.ts b/apps/notifications/src/utils/env.ts index 9cc42827..5ef62b18 100644 --- a/apps/notifications/src/utils/env.ts +++ b/apps/notifications/src/utils/env.ts @@ -6,6 +6,12 @@ export const getHostname = () => { return 'https://audius.co' } +const DEFAULT_CONTENT_NODE = 'https://api.audius.co' + export const getContentNode = () => { - return 'https://creatornode2.audius.co' + return ( + process.env.NOTIFICATIONS_CONTENT_NODE_ENDPOINT || + process.env.CONTENT_NODE_ENDPOINT || + DEFAULT_CONTENT_NODE + ).replace(/\/+$/, '') }