mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Replaced i18n.t w/ tpl helper in webhooks (#13482)
refs: #13380 - The i18n package is deprecated. It is being replaced with the tpl package.
This commit is contained in:
parent
d02cd54cde
commit
368b5e41db
1 changed files with 9 additions and 26 deletions
|
@ -8,8 +8,7 @@ const messages = {
|
|||
noPermissionToEdit: {
|
||||
message: 'You do not have permission to {method} this webhook.',
|
||||
context: 'You may only {method} webhooks that belong to the authenticated integration. Check the supplied Admin API Key.'
|
||||
},
|
||||
webhookAlreadyExists: 'Target URL has already been used for this event.'
|
||||
}
|
||||
};
|
||||
|
||||
const webhooksService = getWebhooksServiceInstance({
|
||||
|
@ -41,20 +40,14 @@ module.exports = {
|
|||
.then((webhook) => {
|
||||
if (!webhook) {
|
||||
throw new errors.NotFoundError({
|
||||
message: tpl(messages.resourceNotFound, {
|
||||
resource: 'Webhook'
|
||||
})
|
||||
message: tpl(messages.resourceNotFound, {resource: 'Webhook'})
|
||||
});
|
||||
}
|
||||
|
||||
if (webhook.get('integration_id') !== frame.options.context.integration.id) {
|
||||
throw new errors.NoPermissionError({
|
||||
message: tpl(messages.noPermissionToEdit.message, {
|
||||
method: 'edit'
|
||||
}),
|
||||
context: tpl(messages.noPermissionToEdit.context, {
|
||||
method: 'edit'
|
||||
})
|
||||
message: tpl(messages.noPermissionToEdit.message, {method: 'edit'}),
|
||||
context: tpl(messages.noPermissionToEdit.context, {method: 'edit'})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -82,9 +75,7 @@ module.exports = {
|
|||
return models.Webhook.edit(data.webhooks[0], Object.assign(options, {require: true}))
|
||||
.catch(models.Webhook.NotFoundError, () => {
|
||||
throw new errors.NotFoundError({
|
||||
message: tpl(messages.resourceNotFound, {
|
||||
resource: 'Webhook'
|
||||
})
|
||||
message: tpl(messages.resourceNotFound, {resource: 'Webhook'})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -110,20 +101,14 @@ module.exports = {
|
|||
.then((webhook) => {
|
||||
if (!webhook) {
|
||||
throw new errors.NotFoundError({
|
||||
message: tpl(messages.resourceNotFound, {
|
||||
resource: 'Webhook'
|
||||
})
|
||||
message: tpl(messages.resourceNotFound, {resource: 'Webhook'})
|
||||
});
|
||||
}
|
||||
|
||||
if (webhook.get('integration_id') !== frame.options.context.integration.id) {
|
||||
throw new errors.NoPermissionError({
|
||||
message: tpl(messages.noPermissionToEdit.message, {
|
||||
method: 'destroy'
|
||||
}),
|
||||
context: tpl(messages.noPermissionToEdit.context, {
|
||||
method: 'destroy'
|
||||
})
|
||||
message: tpl(messages.noPermissionToEdit.message, {method: 'destroy'}),
|
||||
context: tpl(messages.noPermissionToEdit.context, {method: 'destroy'})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -137,9 +122,7 @@ module.exports = {
|
|||
.then(() => null)
|
||||
.catch(models.Webhook.NotFoundError, () => {
|
||||
return Promise.reject(new errors.NotFoundError({
|
||||
message: tpl(messages.resourceNotFound, {
|
||||
resource: 'Webhook'
|
||||
})
|
||||
message: tpl(messages.resourceNotFound, {resource: 'Webhook'})
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue