diff --git a/core/server/api/canary/email.js b/core/server/api/canary/email.js index 627f98d762..15c472cc94 100644 --- a/core/server/api/canary/email.js +++ b/core/server/api/canary/email.js @@ -1,8 +1,13 @@ const models = require('../../models'); -const i18n = require('../../../shared/i18n'); +const tpl = require('@tryghost/tpl'); const errors = require('@tryghost/errors'); const megaService = require('../../services/mega'); +const messages = { + emailNotFound: 'Email not found.', + retryNotAllowed: 'Only failed emails can be retried' +}; + module.exports = { docName: 'emails', @@ -38,7 +43,7 @@ module.exports = { .then((model) => { if (!model) { throw new errors.NotFoundError({ - message: i18n.t('errors.models.email.emailNotFound') + message: tpl(messages.emailNotFound) }); } @@ -57,13 +62,13 @@ module.exports = { .then(async (model) => { if (!model) { throw new errors.NotFoundError({ - message: i18n.t('errors.models.email.emailNotFound') + message: tpl(messages.emailNotFound) }); } if (model.get('status') !== 'failed') { throw new errors.IncorrectUsageError({ - message: i18n.t('errors.models.email.retryNotAllowed') + message: tpl(messages.retryNotAllowed) }); } diff --git a/core/server/api/canary/integrations.js b/core/server/api/canary/integrations.js index 9f3c1093da..2afb70515c 100644 --- a/core/server/api/canary/integrations.js +++ b/core/server/api/canary/integrations.js @@ -1,8 +1,12 @@ -const i18n = require('../../../shared/i18n'); +const tpl = require('@tryghost/tpl'); const errors = require('@tryghost/errors'); const models = require('../../models'); const getIntegrationsServiceInstance = require('../../services/integrations/integrations-service'); +const messages = { + resourceNotFound: '{resource} not found.' +}; + const integrationsService = getIntegrationsServiceInstance({ IntegrationModel: models.Integration, ApiKeyModel: models.ApiKey @@ -51,9 +55,7 @@ module.exports = { return models.Integration.findOne(data, Object.assign(options, {require: true})) .catch(models.Integration.NotFoundError, () => { throw new errors.NotFoundError({ - message: i18n.t('errors.api.resource.resourceNotFound', { - resource: 'Integration' - }) + message: tpl(messages.resourceNotFound, {resource: 'Integration'}) }); }); } @@ -136,9 +138,7 @@ module.exports = { return models.Integration.destroy(Object.assign(options, {require: true})) .catch(models.Integration.NotFoundError, () => { return Promise.reject(new errors.NotFoundError({ - message: i18n.t('errors.api.resource.resourceNotFound', { - resource: 'Integration' - }) + message: tpl(messages.resourceNotFound, {resource: 'Integration'}) })); }); }