src/receipts.js
function processMessage(message) {
      var recipients = Object.keys(message.recipient_status).filter(function(userId) {
        return hook.receipts.reportForStatus.indexOf(message.recipient_status[userId]) !== -1;
      });

      if (recipients.length) {
        var identities = [message.sender.user_id].concat(recipients);
        var identityHash = {};
        if (!hook.receipts.identities) {
          createJob(message, recipients, {});
        } else {
          if (!(hook.receipts.identities instanceof Function)) {
            hook.receipts.identities = getUserFromIdentities;
          }
          var getUser = hook.receipts.identities;
          var count = 0;
          identities.forEach(function(userId) {
            getUser(userId, function(err, data) {
              identityHash[userId] = data;
              count++;
              if (count === identities.length) createJob(message, recipients, identityHash);
            })
          });
        }
      }
    }
function processMessage(message) {
      var recipients = Object.keys(message.recipient_status).filter(function(userId) {
        return hook.receipts.reportForStatus.indexOf(message.recipient_status[userId]) !== -1;
      });

      if (recipients.length) {
        var identities = [message.sender.user_id].concat(recipients);
        var identityHash = {};
        if (!hook.receipts.identities) {
          createJob(message, recipients, {});
        } else {
          if (!(hook.receipts.identities instanceof Function)) {
            hook.receipts.identities = getUserFromIdentities;
          }
          var getUser = hook.receipts.identities;
          var count = 0;
          identities.forEach(function(userId) {
            getUser(userId, function(err, data) {
              identityHash[userId] = data;
              count++;
              if (count === identities.length) createJob(message, recipients, identityHash);
            })
          });
        }
      }
    }
function processMessage ( message ) { var recipients = Object . keys ( message . recipient_status ) . filter ( function ( userId ) { return hook . receipts . reportForStatus . indexOf ( message . recipient_status [ userId ] ) !== - 1 ; } ) ; if ( recipients . length ) { var identities = [ message . sender . user_id ] . concat ( recipients ) ; var identityHash = { } ; if ( ! hook . receipts . identities ) { createJob ( message , recipients , { } ) ; } else { if ( ! ( hook . receipts . identities instanceof Function ) ) { hook . receipts . identities = getUserFromIdentities ; } var getUser = hook . receipts . identities ; var count = 0 ; identities . forEach ( function ( userId ) { getUser ( userId , function ( err , data ) { identityHash [ userId ] = data ; count ++ ; if ( count === identities . length ) createJob ( message , recipients , identityHash ) ; } ) } ) ; } } }
Process an individual Message and create a job if there
are matching recipients.
Process an individual Message and create a job if there are matching recipients .