JC Brand 6 éve
szülő
commit
11ac846b31
5 módosított fájl, 75 hozzáadás és 3 törlés
  1. 2 1
      CHANGES.md
  2. 4 0
      dist/converse.js
  3. 2 2
      index.html
  4. 64 0
      spec/chatroom.js
  5. 3 0
      src/converse-muc-views.js

+ 2 - 1
CHANGES.md

@@ -4,9 +4,10 @@
 
 
 - Use [Lerna](https://lernajs.io/) to create the @converse/headless package
 - Use [Lerna](https://lernajs.io/) to create the @converse/headless package
 - Use ES2015 modules instead of UMD.
 - Use ES2015 modules instead of UMD.
+- #1252 Correctly reflect the state in bookmark icon title.
 - #1257 Prefer 'probably' over 'maybe' when evaluating audio play support.
 - #1257 Prefer 'probably' over 'maybe' when evaluating audio play support.
+- #1259 Don't inform of affiliation change after user leaves MUC
 - #1261 File upload not working
 - #1261 File upload not working
-- #1252 Correctly reflect the state in bookmark icon title.
 - #1272 Hiding MUC occupants leaves a blank space
 - #1272 Hiding MUC occupants leaves a blank space
 
 
 ## 4.0.3 (2018-10-22)
 ## 4.0.3 (2018-10-22)

+ 4 - 0
dist/converse.js

@@ -63342,6 +63342,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins
       },
       },
 
 
       informOfOccupantsRoleChange(occupant, changed) {
       informOfOccupantsRoleChange(occupant, changed) {
+        if (changed === "none") {
+          return;
+        }
+
         const previous_role = occupant._previousAttributes.role;
         const previous_role = occupant._previousAttributes.role;
 
 
         if (previous_role === 'moderator') {
         if (previous_role === 'moderator') {

+ 2 - 2
index.html

@@ -290,8 +290,8 @@
                         </p>
                         </p>
                         <p>
                         <p>
                             Currently the <strong>conversejs.org</strong> XMPP
                             Currently the <strong>conversejs.org</strong> XMPP
-                            server does not support HTTP-file upload, which means
-                            that we don't host any uploaded files of users.
+                            server does not support HTTP-file upload (although Converse the client does),
+                            which means that we don't host any uploaded files of users.
                         </p>
                         </p>
                         <p>
                         <p>
                             During normal operations we don't log or process IP
                             During normal operations we don't log or process IP

+ 64 - 0
spec/chatroom.js

@@ -930,6 +930,70 @@
                 }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL))
                 }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL))
             }));
             }));
 
 
+            it("role-change messages that follow a MUC leave are left out",
+                mock.initConverseWithPromises(
+                    null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
+                    async function (done, _converse) {
+
+                // See https://github.com/conversejs/converse.js/issues/1259
+
+                await test_utils.openAndEnterChatRoom(_converse, 'conversations', 'conference.siacs.eu', 'dummy');
+
+                const presence = $pres({
+                        to: 'dummy@localhost/resource',
+                        from: 'conversations@conference.siacs.eu/Guus'
+                    }).c('x', {
+                        'xmlns': Strophe.NS.MUC_USER
+                    }).c('item', {
+                        'affiliation': 'none',
+                        'jid': 'Guus@localhost/xxx',
+                        'role': 'visitor'
+                    });
+                _converse.connection._dataRecv(test_utils.createRequest(presence));
+
+                const view = _converse.chatboxviews.get('conversations@conference.siacs.eu');
+                const msg = $msg({
+                        'from': 'conversations@conference.siacs.eu/dummy',
+                        'id': (new Date()).getTime(),
+                        'to': 'dummy@localhost',
+                        'type': 'groupchat'
+                    }).c('body').t('Some message').tree();
+
+                view.model.onMessage(msg);
+                await new Promise((resolve, reject) => view.once('messageInserted', resolve));
+
+                let stanza = Strophe.xmlHtmlNode(
+                    `<presence xmlns="jabber:client" to="dummy@localhost/resource" type="unavailable" from="conversations@conference.siacs.eu/Guus">
+                        <x xmlns="http://jabber.org/protocol/muc#user">
+                            <item affiliation="none" role="none"/>
+                        </x>
+                    </presence>`
+                ).firstElementChild;
+                _converse.connection._dataRecv(test_utils.createRequest(stanza));
+
+                stanza = Strophe.xmlHtmlNode(
+                    `<presence xmlns="jabber:client" to="dummy@localhost/resource" from="conversations@conference.siacs.eu/Guus">
+                        <c xmlns="http://jabber.org/protocol/caps" node="http://conversations.im" ver="ISg6+9AoK1/cwhbNEDviSvjdPzI=" hash="sha-1"/>
+                        <x xmlns="vcard-temp:x:update">
+                            <photo>bf987c486c51fbc05a6a4a9f20dd19b5efba3758</photo>
+                        </x>
+                        <x xmlns="http://jabber.org/protocol/muc#user">
+                            <item affiliation="none" role="visitor"/>
+                        </x>
+                    </presence>`
+                ).firstElementChild;
+                _converse.connection._dataRecv(test_utils.createRequest(stanza));
+
+                const chat_content = view.el.querySelector('.chat-content');
+                const messages = chat_content.querySelectorAll('div.chat-info');
+                expect(messages.length).toBe(3);
+                expect(messages[0].textContent).toBe('dummy has entered the groupchat');
+                expect(messages[1].textContent).toBe('Guus has entered the groupchat');
+                expect(messages[2].textContent).toBe('Guus has left and re-entered the groupchat');
+                done();
+            }));
+
+
             it("shows a new day indicator if a join/leave message is received on a new day",
             it("shows a new day indicator if a join/leave message is received on a new day",
                 mock.initConverseWithPromises(
                 mock.initConverseWithPromises(
                     null, ['rosterGroupsFetched'], {},
                     null, ['rosterGroupsFetched'], {},

+ 3 - 0
src/converse-muc-views.js

@@ -645,6 +645,9 @@ converse.plugins.add('converse-muc-views', {
             },
             },
 
 
             informOfOccupantsRoleChange (occupant, changed) {
             informOfOccupantsRoleChange (occupant, changed) {
+                if (changed === "none") {
+                    return;
+                }
                 const previous_role = occupant._previousAttributes.role;
                 const previous_role = occupant._previousAttributes.role;
                 if (previous_role === 'moderator') {
                 if (previous_role === 'moderator') {
                     this.showChatEvent(__("%1$s is no longer a moderator", occupant.get('nick')))
                     this.showChatEvent(__("%1$s is no longer a moderator", occupant.get('nick')))