<commit_before>var currentDialog;
var dialogs = {};
var users = {};
var opponentId;


// submit form after press "ENTER"
function submit_handler(form) {
  return false;
}

function retrieveChatDialogs() {

    // get the chat dialogs list
    //
    QB.chat.dialog.list(null, function(err, resDialogs) {
      if (err) {
        console.log(err);
      } else {

        // repackage dialogs data and collect all occupants ids
        // 
        var occupantsIds = [];  
        resDialogs.items.forEach(function(item, i, arr) {
          var dialogId = item._id;
          dialogs[dialogId] = item;

          // join room
          if (item.type != 3) {
            QB.chat.muc.join(item.xmpp_room_jid, function() {
               console.log("Joined dialog " + dialogId);
            });
            opponentId = null;
          } else {
            opponentId = QB.chat.helpers.getRecipientId(item.occupants_ids, currentUser.id);
          }
<commit_msg>added a handler for room join errors<commit_after>var currentDialog;
var dialogs = {};
var users = {};
var opponentId;


// submit form after press "ENTER"
function submit_handler(form) {
  return false;
}

function retrieveChatDialogs() {

    // get the chat dialogs list
    //
    QB.chat.dialog.list(null, function(err, resDialogs) {
      if (err) {
        console.log(err);
      } else {

        // repackage dialogs data and collect all occupants ids
        // 
        var occupantsIds = [];  
        resDialogs.items.forEach(function(item, i, arr) {
          var dialogId = item._id;
          dialogs[dialogId] = item;

          // join room
          if (item.type != 3) {
            QB.chat.muc.join(item.xmpp_room_jid, function(stanza) {
               var joined = true;

               for (var i = 0; i < stanza.childNodes.length; i++) {
                 var elItem = stanza.childNodes.item(i);
                 if (elItem.tagName === 'error'){
                   joined = false; 
                 }
               }
               
               console.log("Joined dialog " + dialogId + ": " + joined);
            });
            opponentId = null;
          } else {
            opponentId = QB.chat.helpers.getRecipientId(item.occupants_ids, currentUser.id);
          }

{'fraction_non_alphanumeric': 0.11543564794338788, 'fraction_numerical': 0.0013268465280849183, 'mean_word_length': 1.7285886610373944, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3489355', 'n_tokens_mistral': 683, 'n_tokens_neox': 660, 'n_words': 155}