@@ -489,24 +489,19 @@ function Facebookbot(configuration) {
489
489
facebook_botkit . middleware . receive . use ( function handleDelivery ( bot , message , next ) {
490
490
491
491
if ( message . type === 'message_delivered' && facebook_botkit . config . require_delivery ) {
492
- // get list of mids in this message
493
- for ( var m = 0 ; m < message . delivery . mids . length ; m ++ ) {
494
- var mid = message . delivery . mids [ m ] ;
495
-
496
- // loop through all active conversations this bot is having
497
- // and mark messages in conversations as delivered = true
498
- // note: we don't pass the real event in here because message_delivered events are excluded from conversations and won't ever match!
499
- bot . findConversation ( { user : message . user } , function ( convo ) {
500
- if ( convo ) {
501
- for ( var s = 0 ; s < convo . sent . length ; s ++ ) {
502
- if ( convo . sent [ s ] . sent_timestamp <= message . delivery . watermark ||
503
- ( convo . sent [ s ] . api_response && convo . sent [ s ] . api_response . message_id == mid ) ) {
504
- convo . sent [ s ] . delivered = true ;
505
- }
492
+ // loop through all active conversations this bot is having
493
+ // and mark messages in conversations as delivered = true
494
+ // note: we don't pass the real event in here because message_delivered events are excluded from conversations and won't ever match!
495
+ // also note: we only use message.delivery.watermark since message.delivery.mids can sometimes not be in the payload (#1311)
496
+ bot . findConversation ( { user : message . user } , function ( convo ) {
497
+ if ( convo ) {
498
+ for ( var s = 0 ; s < convo . sent . length ; s ++ ) {
499
+ if ( convo . sent [ s ] . sent_timestamp <= message . delivery . watermark ) {
500
+ convo . sent [ s ] . delivered = true ;
506
501
}
507
502
}
508
- } ) ;
509
- }
503
+ }
504
+ } ) ;
510
505
}
511
506
512
507
next ( ) ;
0 commit comments