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

Fixes #1022 Include stored status message in presences.

JC Brand 7 лет назад
Родитель
Сommit
c4c154cfa1
3 измененных файлов с 29 добавлено и 1 удалено
  1. 1 0
      CHANGES.md
  2. 27 0
      spec/presence.js
  3. 1 1
      src/converse-core.js

+ 1 - 0
CHANGES.md

@@ -9,6 +9,7 @@
 
 - Avatars weren't being shown.
 - Bookmarks list and open rooms list weren't recreated after logging in for a 2nd time (without reloading the browser).
+- #1022 Status message not sent out on subsequent presences
 - #1024 null reference on MUC Invite
 - #1025 OTR lock icon disappears
 - #1027 `new Event` not supported in IE11

+ 27 - 0
spec/presence.js

@@ -45,6 +45,33 @@
                 "</presence>"
             );
         }));
+
+        it("includes the saved status message",
+            mock.initConverseWithPromises(
+                null, ['rosterGroupsFetched'], {},
+                function (done, _converse) {
+
+            test_utils.openControlBox();
+            var view = _converse.xmppstatusview;
+            spyOn(view.model, 'sendPresence').and.callThrough();
+            spyOn(_converse.connection, 'send').and.callThrough();
+
+            view.el.querySelector('a.change-xmpp-status-message').click();
+            var msg = 'My custom status';
+            view.el.querySelector('input.custom-xmpp-status').value = msg;
+            view.el.querySelector('[type="submit"]').click();
+            expect(view.model.sendPresence).toHaveBeenCalled();
+
+            expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
+                .toBe("<presence xmlns='jabber:client'><status>My custom status</status><priority>0</priority></presence>")
+
+            view.el.querySelector('a.choose-xmpp-status').click();
+            view.el.querySelectorAll('.dropdown dd ul li a')[1].click(); // Change status to "dnd"
+
+            expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
+                .toBe("<presence xmlns='jabber:client'><show>dnd</show><status>My custom status</status><priority>0</priority></presence>")
+            done();
+        }));
     });
 
     describe("A received presence stanza", function () {

+ 1 - 1
src/converse-core.js

@@ -1503,7 +1503,7 @@
             constructPresence (type, status_message) {
                 let presence;
                 type = _.isString(type) ? type : (this.get('status') || _converse.default_state);
-                status_message = _.isString(status_message) ? status_message : undefined;
+                status_message = _.isString(status_message) ? status_message : this.get('status_message');
                 // Most of these presence types are actually not explicitly sent,
                 // but I add all of them here for reference and future proofing.
                 if ((type === 'unavailable') ||