Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/1771 auto retrieving transactional journeys after publishing them fails to find transactionalemails #1975

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading