فهرست منبع

Bugfix. Handle case where user accepts request.

But other user is not online to quickly subscribe back.
JC Brand 11 سال پیش
والد
کامیت
1705aa8f48
2فایلهای تغییر یافته به همراه26 افزوده شده و 7 حذف شده
  1. 18 6
      converse.js
  2. 8 1
      docs/DEVELOPER.rst

+ 18 - 6
converse.js

@@ -2883,7 +2883,12 @@
 
                 this.$el.addClass(chat_status).data('status', chat_status);
 
-                if (ask === 'subscribe') {
+                if ((ask === 'subscribe') || (subscription === 'from')) {
+                    // if subscription === 'from', then they are subscribed to
+                    // us, but not vice versa. We assume that there is a
+                    // pending subscription from us to them (otherwise we're in
+                    // a state not supported by converse.js), so the user is a
+                    // "pending" contact.
                     this.$el.addClass('pending-xmpp-contact');
                     this.$el.html(converse.templates.pending_contact(
                         _.extend(item.toJSON(), {
@@ -3293,7 +3298,7 @@
             },
 
             removeAllRosterItemViews: function () {
-                var views = this.removeAll();
+                this.removeAll();
                 this.updateRoster();
                 return this;
             },
@@ -3334,11 +3339,18 @@
                     if ((ask === 'subscribe') && (subscription == 'none')) {
                         $pending_contacts.after(view.render().el);
                         $pending_contacts.after($pending_contacts.siblings('dd.pending-xmpp-contact').tsort(crit));
-                    } else if ((ask === 'subscribe') && (subscription == 'from')) {
-                        // TODO: We have accepted an incoming subscription
+                    } else if ((ask === 'subscribe' || ask === null) && (subscription === 'from')) {
+                        // We have accepted an incoming subscription
                         // request and (automatically) made our own subscription request back.
-                        // It would be useful to update the roster here to show
-                        // things are happening... (see docs/DEVELOPER.rst)
+                        //
+                        // From what I can tell: (see docs/DEVELOPER.rst)
+                        //  if ask == 'subscribe', then the other user is online.
+                        //  if ask == null, then the other user is not online currently.
+                        //
+                        // In either case, the other user is now subscribed to
+                        // us (i.e. "from" them to us), and we have a pending
+                        // subscription to them, so we show the user as a
+                        // pending contact.
                         $pending_contacts.after(view.render().el);
                         $pending_contacts.after($pending_contacts.siblings('dd.pending-xmpp-contact').tsort(crit));
                     } else if (requesting === true) {

+ 8 - 1
docs/DEVELOPER.rst

@@ -30,7 +30,7 @@ subscription and subscribes back.
     <presence type="subscribed" to="contact1@localhost"/>
     <presence type="subscribe" to="contact1@localhost"/>
 
-Contact2 receives a roster update
+IF Contact1 is still online and likewise subscribes back, Contact2 will receive a roster update
 
 ::
     <iq type="set" to="contact2@localhost">
@@ -39,6 +39,13 @@ Contact2 receives a roster update
         </query>
     </iq>
 
+ELSE, Contact 2 will receive a roster update (but not an IQ stanza)
+
+::
+    ask = null
+    subscription = "from"
+
+
 Contact1's converse.js client will automatically
 approve.