mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Updated webhook request header and last triggered error mssg (#10035)
refs #9942 - Added error message if unknown status code on request failure - Added event to payload
This commit is contained in:
parent
99a2f3ba3a
commit
e2d0b2e543
3 changed files with 11 additions and 4 deletions
|
@ -38,6 +38,7 @@ function listener(event, model, options) {
|
|||
if (model) {
|
||||
payload = generatePayload(event, model);
|
||||
}
|
||||
payload.event = event;
|
||||
|
||||
// avoid triggering webhooks when importing
|
||||
if (options && options.importing) {
|
||||
|
|
|
@ -40,9 +40,11 @@ function makeRequests(webhooksCollection, payload, options) {
|
|||
common.logging.warn(`Unable to destroy webhook ${webhookId}`);
|
||||
});
|
||||
}
|
||||
let lastTriggeredError = err.statusCode ? '' : `Failed to send request to ${targetUrl}`;
|
||||
updateWebhookTriggerData(webhookId, {
|
||||
last_triggered_at: triggeredAt,
|
||||
last_triggered_status: err.statusCode
|
||||
last_triggered_status: err.statusCode,
|
||||
last_triggered_error: lastTriggeredError
|
||||
});
|
||||
|
||||
common.logging.error(new common.errors.GhostError({
|
||||
|
|
|
@ -49,7 +49,8 @@ describe('Webhooks', function () {
|
|||
triggerArgs = webhooksStub.trigger.getCall(0).args;
|
||||
triggerArgs[0].should.eql('subscriber.added');
|
||||
triggerArgs[1].should.deepEqual({
|
||||
subscribers: [testSubscriber]
|
||||
subscribers: [testSubscriber],
|
||||
event: 'subscriber.added'
|
||||
});
|
||||
|
||||
resetWebhooks();
|
||||
|
@ -74,7 +75,8 @@ describe('Webhooks', function () {
|
|||
triggerArgs = webhooksStub.trigger.getCall(0).args;
|
||||
triggerArgs[0].should.eql('subscriber.deleted');
|
||||
triggerArgs[1].should.deepEqual({
|
||||
subscribers: [testSubscriber]
|
||||
subscribers: [testSubscriber],
|
||||
event: 'subscriber.deleted'
|
||||
});
|
||||
|
||||
resetWebhooks();
|
||||
|
@ -94,7 +96,9 @@ describe('Webhooks', function () {
|
|||
|
||||
triggerArgs = webhooksStub.trigger.getCall(0).args;
|
||||
triggerArgs[0].should.eql('site.changed');
|
||||
triggerArgs[1].should.eql({});
|
||||
triggerArgs[1].should.eql({
|
||||
event: 'site.changed'
|
||||
});
|
||||
|
||||
resetWebhooks();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue