@@ -211,18 +211,19 @@ func (wh *WebHooks) attemptRequest(sub *core.Subscription, event *core.EventDeli
211211
212212 if req .method == http .MethodPost || req .method == http .MethodPatch || req .method == http .MethodPut {
213213 switch {
214- case ! withData :
215- // We are just sending the event itself
216- req .r .SetBody (event )
217214 case req .body != nil :
218215 // We might have been told to extract a body from the first data record
219216 req .r .SetBody (req .body )
220217 case len (allData ) > 1 :
221218 // We've got an array of data to POST
222219 req .r .SetBody (allData )
223- default :
224- // Otherwise just send the first object directly
220+ case len ( allData ) == 1 :
221+ // Just send the first object directly
225222 req .r .SetBody (firstData )
223+ default :
224+ // Just send the event itself
225+ req .r .SetBody (event )
226+
226227 }
227228 }
228229
@@ -292,7 +293,7 @@ func (wh *WebHooks) doDelivery(connID string, reply bool, sub *core.Subscription
292293 log .L (wh .ctx ).Tracef ("Webhook response: %s" , string (b ))
293294
294295 // Emit the response
295- if reply {
296+ if reply && event . Message != nil {
296297 txType := fftypes .FFEnum (strings .ToLower (sub .Options .TransportOptions ().GetString ("replytx" )))
297298 if req != nil && req .replyTx != "" {
298299 txType = fftypes .FFEnum (strings .ToLower (req .replyTx ))
@@ -332,13 +333,8 @@ func (wh *WebHooks) doDelivery(connID string, reply bool, sub *core.Subscription
332333}
333334
334335func (wh * WebHooks ) DeliveryRequest (connID string , sub * core.Subscription , event * core.EventDelivery , data core.DataArray ) error {
335- if event .Message == nil && sub .Options .WithData != nil && * sub .Options .WithData {
336- log .L (wh .ctx ).Debugf ("Webhook withData=true subscription called with non-message event '%s'" , event .ID )
337- return nil
338- }
339-
340336 reply := sub .Options .TransportOptions ().GetBool ("reply" )
341- if reply && event .Message .Header .CID != nil {
337+ if reply && event .Message != nil && event . Message .Header .CID != nil {
342338 // We cowardly refuse to dispatch a message that is itself a reply, as it's hard for users to
343339 // avoid loops - and there's no way for us to detect here if a user has configured correctly
344340 // to avoid a loop.
0 commit comments