Просмотр исходного кода

Merge pull request #503 from teseo/master

Fix roster push when new contact is pushed from server and emit rosterPush event
JC Brand 9 лет назад
Родитель
Сommit
cf25670ccb
3 измененных файлов с 12 добавлено и 2 удалено
  1. 5 2
      converse.js
  2. 5 0
      docs/CHANGES.rst
  3. 2 0
      docs/source/development.rst

+ 5 - 2
converse.js

@@ -4362,7 +4362,7 @@
                  */
                 var id = iq.getAttribute('id');
                 var from = iq.getAttribute('from');
-                if (from && from !== "" && Strophe.getNodeFromJid(from) != converse.bare_jid) {
+                if (from && from !== "" && from !== converse.connection.jid) {
                     // Receiving client MUST ignore stanza unless it has no from or from = user's bare JID.
                     converse.connection.send(
                         $iq({type: 'error', id: id, from: converse.connection.jid})
@@ -4375,7 +4375,10 @@
                 $(iq).children('query').find('item').each(function (idx, item) {
                     this.updateContact(item);
                 }.bind(this));
-                return true;
+
+                converse.emit('rosterPush', iq);
+
+		return true;
             },
 
             fetchFromServer: function (callback, errback) {

+ 5 - 0
docs/CHANGES.rst

@@ -1,6 +1,11 @@
 Changelog
 =========
 
+0.9.7 (Unreleased)
+------------------
+
+* #493 Refactor previous bugfix and now an event is emitted when a roster push event from server happens. [teseo]
+
 0.9.6 (2015-10-12)
 ------------------
 

+ 2 - 0
docs/source/development.rst

@@ -773,6 +773,8 @@ Here are the different events that are emitted:
 +---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
 | **roster**                      | When the roster is updated.                                                                       | ``converse.listen.on('roster', function (event, items) { ... });``                                   |
 +---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
+| **rosterPush**                  | When the roster receives a push event from server. (i.e. New entry in your buddy list)            | ``converse.listen.on('rosterPush', function (event, items) { ... });``                               |
++---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
 | **statusChanged**               | When own chat status has changed.                                                                 | ``converse.listen.on('statusChanged', function (event, status) { ... });``                           |
 +---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
 | **statusMessageChanged**        | When own custom status message has changed.                                                       | ``converse.listen.on('statusMessageChanged', function (event, message) { ... });``                   |