Skip to content

Commit

Permalink
Merge pull request #1975 from Accenture/bug/1771-auto-retrieving-tran…
Browse files Browse the repository at this point in the history
…sactional-journeys-after-publishing-them-fails-to-find-transactionalemails

Bug/1771 auto retrieving transactional journeys after publishing them fails to find transactionalemails
  • Loading branch information
JoernBerkefeld authored Jan 10, 2025
2 parents 50b923f + 4bcbcd6 commit f0ce6ba
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Journey.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/util/cache.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/util/cache.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/metadataTypes/Journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,9 @@ class Journey extends MetadataType {
if (transactionalKeyArr.length) {
executedKeyArr.push(...transactionalKeyArr);

// reset transactionalEmail cache to trigger re-caching it.
cache.clearCache(this.buObject.mid, 'transactionalEmail');

Util.logger.info('Retrieving relevant journeys');
const retriever = new Retriever(this.properties, this.buObject);

Expand Down
11 changes: 8 additions & 3 deletions lib/util/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ export default {
/**
* clean cache for one BU if mid provided, otherwise whole cache
*
* @param {number} [mid] of business unit
* @param {number} [mid] limit clearing to provided business unit MID
* @param {string} [type] optionally limit clearing to specific metadata type; only used if mid is provided
* @returns {void}
*/
clearCache: (mid) =>
clearCache: (mid, type) =>
mid
? Object.keys(dataStore[mid]).forEach((key) => delete dataStore[mid][key])
? Object.keys(dataStore[mid]).forEach((key) => {
if (!type || type === key) {
delete dataStore[mid][key];
}
})
: Object.keys(dataStore).forEach((key) => delete dataStore[key]),
/* eslint-enable unicorn/no-array-for-each */

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"createdDate": "2024-08-23T02:01:00",
"definitionKey": "testExisting_temail_notPublished",
"description": "testExisting_temail_notPublis - 754cc4a10da14f538ecbd5470d771eaf",
"modifiedDate": "2024-08-23T02:01:00",
"name": "testExisting_temail_notPublis - 754cc4a10da14f538ecbd5470d771eaf",
"options": {
"trackLinks": true
},
"r__asset_key": "testExisting_asset_message",
"r__journey_key": "testExisting_temail_notPublished",
"r__sendClassification_key": "Default Transactional",
"status": "Active",
"subscriptions": {
"autoAddSubscriber": true,
"r__dataExtension_key": "testExisting_temail_notPublished",
"r__list_PathName": "my subscribers/All Subscribers",
"updateSubscriber": true
}
}
12 changes: 11 additions & 1 deletion test/type.journey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ describe('type: journey', () => {
'post',
'/interaction/v1/interactions/transactional/create'
);
// confirm created item
// confirm callouts
assert.deepEqual(
publishCallout,
{
Expand All @@ -604,6 +604,16 @@ describe('type: journey', () => {
'publish-payload JSON was not equal expected'
);

// confirm transactionalEmail was downloaded
assert.deepEqual(
await testUtils.getActualJson(
'testExisting_temail_notPublished',
'transactionalEmail'
),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'get-published'),
'returned JSON was not equal expected'
);

assert.equal(
testUtils.getAPIHistoryLength(),
35,
Expand Down

0 comments on commit f0ce6ba

Please sign in to comment.