From b568560df4b212f15789af1a2d22cddf038326f4 Mon Sep 17 00:00:00 2001 From: Leonardo Crauss Daronco <leonardodaronco@gmail.com> Date: Mon, 24 Nov 2014 13:01:13 -0200 Subject: [PATCH] Webhooks: any 2xx status should be taken as successful --- labs/bbb-webhooks/README.md | 2 +- labs/bbb-webhooks/callback_emitter.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/labs/bbb-webhooks/README.md b/labs/bbb-webhooks/README.md index 2a6ae6acf4..a781130d30 100644 --- a/labs/bbb-webhooks/README.md +++ b/labs/bbb-webhooks/README.md @@ -228,7 +228,7 @@ More details * The application assumes that events are never duplicated on pubsub. If they happen to be duplicated, the callback calls will also be duplicated. * Hooks are only removed if a call to `/destroy` is made or if the callbacks for the hook fail too many times (~12) for a long period of time (~5min). They are never removed otherwise. Valid for both global hooks and hooks for specific meetings. * Mappings are removed after 24 hours of inactivity. If there are no events at all for a given meeting, it will be assumed dead. This is done to prevent data from being stored forever on redis. -* External URLs are expected to respond with the HTTP status 200, 201 or 202. Anything different from these values will be considered an error and the callback will be called again. This includes URLs that redirect to some other place. +* External URLs are expected to respond with the HTTP status 2xx (200 would be the default expected). Anything different from these values will be considered an error and the callback will be called again. This includes URLs that redirect to some other place. * If a meeting is created while the webhooks app is down, callbacks will never be triggered for this meeting. The app needs to detect the create event (`meeting_created_message`) to have a mapping of internal to external meeting IDs. Development diff --git a/labs/bbb-webhooks/callback_emitter.coffee b/labs/bbb-webhooks/callback_emitter.coffee index 7f5152b0c2..bc4393b70c 100644 --- a/labs/bbb-webhooks/callback_emitter.coffee +++ b/labs/bbb-webhooks/callback_emitter.coffee @@ -69,7 +69,7 @@ module.exports = class CallbackEmitter extends EventEmitter form: data request requestOptions, (error, response, body) -> - if error? or response?.statusCode not in [200, 201, 202] + if error? or not (response?.statusCode >= 200 and response?.statusCode < 300) Logger.warn "xx> Error in the callback call to: [#{requestOptions.uri}] for #{simplifiedEvent(data.event)}" Logger.warn "xx> Error:", error Logger.warn "xx> Status:", response?.statusCode -- GitLab