Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added /emails/:id/retry/ endpoint for retrying failed emails (#11410)
We want to allow admin users to trigger a retry of failed emails without having to go through the unpublish/republish dance. - fixed resource identifier in email permissions migration so email permissions are added correctly - added new email permissions migration so that beta releases can be upgraded without rollback (will be a no-op for any non-beta upgrades) - added `/emails/:id/retry/` canary Admin API endpoint - follows same URL pattern as theme activation - only triggers mega service retry endpoint if the email has a `'failed'` status
- Loading branch information
1 parent
d7d5d9a
commit 6a057fa
Showing
8 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,9 @@ module.exports = { | |
frame.response = { | ||
emails: [email] | ||
}; | ||
}, | ||
|
||
get retry() { | ||
return this.read; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
core/server/data/migrations/versions/3.1/09-add-further-email-permissions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const _ = require('lodash'); | ||
const utils = require('../../../schema/fixtures/utils'); | ||
const permissions = require('../../../../services/permissions'); | ||
const logging = require('../../../../lib/common/logging'); | ||
|
||
const resources = ['email']; | ||
const _private = {}; | ||
|
||
_private.getPermissions = function getPermissions(resource) { | ||
return utils.findModelFixtures('Permission', {object_type: resource}); | ||
}; | ||
|
||
_private.printResult = function printResult(result, message) { | ||
if (result.done === result.expected) { | ||
logging.info(message); | ||
} else { | ||
logging.warn(`(${result.done}/${result.expected}) ${message}`); | ||
} | ||
}; | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; | ||
|
||
module.exports.up = (options) => { | ||
const localOptions = _.merge({ | ||
context: {internal: true} | ||
}, options); | ||
|
||
return Promise.map(resources, (resource) => { | ||
const modelToAdd = _private.getPermissions(resource); | ||
|
||
return utils.addFixturesForModel(modelToAdd, localOptions) | ||
.then(result => _private.printResult(result, `Adding permissions fixtures for ${resource}`)) | ||
.then(() => permissions.init(localOptions)); | ||
}); | ||
}; | ||
|
||
module.exports.down = (options) => { | ||
const localOptions = _.merge({ | ||
context: {internal: true} | ||
}, options); | ||
|
||
return Promise.map(resources, (resource) => { | ||
const modelToRemove = _private.getPermissions(resource); | ||
|
||
// permission model automatically cleans up permissions_roles on .destroy() | ||
return utils.removeFixturesForModel(modelToRemove, localOptions) | ||
.then(result => _private.printResult(result, `Removing permissions fixtures for ${resource}s`)); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters