Skip to content

Commit

Permalink
#1857: ensure upserted sendClassifications are saved with CreatedDate…
Browse files Browse the repository at this point in the history
… and ModifiedDate
  • Loading branch information
JoernBerkefeld committed Jan 7, 2025
1 parent 3261321 commit 8ae3b06
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
20 changes: 20 additions & 0 deletions lib/metadataTypes/SendClassification.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ class SendClassification extends MetadataType {
return metadata;
}

/**
* Gets executed after deployment of metadata type
*
* @param {MetadataTypeMap} upsertResults metadata mapped by their keyField as returned by update/create
* @returns {Promise.<void>} -
*/
static async postDeployTasks(upsertResults) {
// re-retrieve all upserted items to ensure we have all fields (createdDate and modifiedDate are otherwise not present)
Util.logger.debug(
`Caching all ${this.definition.type} post-deploy to ensure we have all fields`
);
const typeCache = await this.retrieveForCache();
// update values in upsertResults with retrieved values before saving to disk
for (const key of Object.keys(upsertResults)) {
if (typeCache.metadata[key]) {
upsertResults[key] = typeCache.metadata[key];
}
}
}

/**
* manages post retrieve steps
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"CreatedDate": "2016-08-31T11:29:00",
"ModifiedDate": "2024-04-15T15:33:00",
"CustomerKey": "testExisting_sendClassification",
"Name": "testExisting_sendClassification",
"Description": "updated on deploy",
"Description": "",
"c__classification": "Commercial",
"r__senderProfile_key": "testExisting_senderProfile",
"r__deliveryProfile_key": "Default"
Expand Down
2 changes: 1 addition & 1 deletion test/type.sendClassification.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('type: sendClassification', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
5,
6,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down

0 comments on commit 8ae3b06

Please sign in to comment.