Browse Source

Explicity set history to zero

If it's omitted, messages are returned.
JC Brand 3 tuần trước cách đây
mục cha
commit
b8c5137ef5

+ 2 - 2
package.json

@@ -55,7 +55,7 @@
     "build:website-min-css": "npm run build:website-css && npx clean-css-cli dist/website.css > dist/website.min.css",
     "cdn": "ASSET_PATH=https://cdn.conversejs.org/dist/ npm run build",
     "clean": "rm -rf node_modules dist *.zip src/headless/dist src/headless/node_modules",
-    "dev": "DROP_DEBUGGER=false rspack build --config rspack/rspack.build.js --mode=development",
+    "dev": "DROP_DEBUGGER=false npm run dev:headless && rspack build --config rspack/rspack.build.cjs.js --mode=development",
     "dev:headless": "DROP_DEBUGGER=false rspack build --config rspack/rspack.headless.js --mode=development",
     "devserver": "npm run dev:headless && npx rspack serve --config rspack/rspack.serve.js",
     "lint": "eslint src/**/*.js",
@@ -69,7 +69,7 @@
     "types:check": "tsc --noEmit",
     "watch": "concurrently \"npm run watch:headless\" \"npm run watch:main\"",
     "watch:headless": "DROP_DEBUGGER=false rspack --watch --config rspack/rspack.headless.js --mode=development",
-    "watch:main": "DROP_DEBUGGER=false rspack --watch --config rspack/rspack.build.js --mode=development"
+    "watch:main": "DROP_DEBUGGER=false rspack --watch --config rspack/rspack.build.cjs.js --mode=development"
   },
   "repository": {
     "type": "git",

+ 1 - 1
src/headless/plugins/muc/muc.js

@@ -237,7 +237,7 @@ class MUC extends ModelWithVCard(ModelWithMessages(ColorAwareModel(ChatBoxBase))
                       from="${api.connection.get().jid}"
                       to="${this.getRoomJIDAndNick()}">
                 <x xmlns="${Strophe.NS.MUC}">
-                    ${maxstanzas ? stx`<history maxstanzas="${maxstanzas}"/>` : ''}
+                    <history maxstanzas="${maxstanzas || 0}"/>
                     ${password ? stx`<password>${password}</password>` : ''}
                 </x>
                 ${PRES_SHOW_VALUES.includes(show) ? stx`<show>${show}</show>` : ''}

+ 3 - 3
src/headless/plugins/muc/tests/muc.js

@@ -57,7 +57,7 @@ describe("Groupchats", function () {
             let pres = await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName === 'presence').pop());
             expect(pres).toEqualStanza(stx`
                 <presence from="${_converse.jid}" id="${pres.getAttribute('id')}" to="${muc_jid}/romeo" xmlns="jabber:client">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <show>away</show>
                     <c hash="sha-1" node="https://conversejs.org" ver="t7NrIuCRhg80cJKAq33v3LKogjI=" xmlns="http://jabber.org/protocol/caps"/>
                 </presence>`);
@@ -86,7 +86,7 @@ describe("Groupchats", function () {
             pres = await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName === 'presence').pop());
             expect(pres).toEqualStanza(stx`
                 <presence from="${_converse.jid}" id="${pres.getAttribute('id')}" to="${muc2_jid}/romeo" xmlns="jabber:client">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <show>dnd</show>
                     <status>Do not disturb</status>
                     <c hash="sha-1" node="https://conversejs.org" ver="t7NrIuCRhg80cJKAq33v3LKogjI=" xmlns="http://jabber.org/protocol/caps"/>
@@ -144,7 +144,7 @@ describe("Groupchats", function () {
                 () => sent_stanzas.slice(index).filter(s => s.nodeName === 'presence').pop());
             expect(pres).toEqualStanza(stx`
                 <presence from="${_converse.jid}" id="${pres.getAttribute('id')}" to="coven@chat.shakespeare.lit/romeo" xmlns="jabber:client">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <c hash="sha-1" node="https://conversejs.org" ver="t7NrIuCRhg80cJKAq33v3LKogjI=" xmlns="http://jabber.org/protocol/caps"/>
                 </presence>`);
         }));

+ 1 - 1
src/headless/plugins/muc/tests/presence.js

@@ -40,7 +40,7 @@ describe('MUC presence history element', function () {
             );
             expect(sent_stanza).toEqualStanza(stx`
               <presence to="${muc2_jid}/${nick}" xmlns="jabber:client" id="${sent_stanza.getAttribute('id')}" from="${jid}">
-                <x xmlns="http://jabber.org/protocol/muc"/>
+                <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                 <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://conversejs.org" ver="t7NrIuCRhg80cJKAq33v3LKogjI="/>
               </presence>`);
         })

+ 1 - 1
src/headless/types/shared/constants.d.ts

@@ -1,5 +1,5 @@
 export const BOSH_WAIT: 59;
-export const VERSION_NAME: "v11.0.1";
+export const VERSION_NAME: "v12.0.0";
 export const PRES_SHOW_VALUES: string[];
 export const PRES_TYPE_VALUES: string[];
 export namespace STATUS_WEIGHTS {

+ 1 - 0
src/plugins/bookmark-views/tests/bookmarks.js

@@ -272,6 +272,7 @@ describe("Bookmarks", function () {
                 id="${sent_stanza.getAttribute('id')}"
                 to="${autojoin_muc}/JC">
             <x xmlns="http://jabber.org/protocol/muc">
+                <history maxstanzas="0"/>
                 <password>secret</password>
             </x>
             <c xmlns="http://jabber.org/protocol/caps"

+ 5 - 5
src/plugins/muc-views/tests/nickname.js

@@ -334,7 +334,7 @@ describe("A MUC", function () {
                         to="romeo@montague.lit/pda"
                         type="error"
                         xmlns="jabber:client">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <error by="${muc_jid}" type="cancel">
                         <conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
                     </error>
@@ -387,7 +387,7 @@ describe("A MUC", function () {
                         from="${connection.jid}"
                         to="${muc_jid}/romeo-2"
                         xmlns="jabber:client">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://conversejs.org"
                         ver="qgxN8hmrdSa2/4/7PUoM9bPFN2s="/>
                 </presence>`);
@@ -402,7 +402,7 @@ describe("A MUC", function () {
                         id="${u.getUniqueId()}"
                         to="romeo@montague.lit/pda"
                         type="error">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <error by="${muc_jid}" type="cancel">
                         <conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
                     </error>
@@ -417,7 +417,7 @@ describe("A MUC", function () {
                         from="${connection.jid}"
                         to="${muc_jid}/romeo-3"
                         xmlns="jabber:client">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://conversejs.org"
                         ver="qgxN8hmrdSa2/4/7PUoM9bPFN2s="/>
                 </presence>`);
@@ -447,7 +447,7 @@ describe("A MUC", function () {
                         from="${connection.jid}"
                         to="${muc_jid}/romeo-4"
                         xmlns="jabber:client">
-                    <x xmlns="http://jabber.org/protocol/muc"/>
+                    <x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>
                     <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://conversejs.org"
                         ver="qgxN8hmrdSa2/4/7PUoM9bPFN2s="/>
                 </presence>`);