Procházet zdrojové kódy

fix: Set affiliation. (#1966)

* fix: Set affiliation.

XEP-0045:
Affiliations are granted, revoked, and maintained based on the user’s bare JID, not the nick as with roles.

* squash: Fixes own revokeOwner.
release-8443
Дамян Минков před 3 roky
rodič
revize
b71481a8b2
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 4
- 4
JitsiConference.js Zobrazit soubor

@@ -1721,7 +1721,7 @@ JitsiConference.prototype.grantOwner = function(id) {
1721 1721
     if (!participant) {
1722 1722
         return;
1723 1723
     }
1724
-    this.room.setAffiliation(participant.getJid(), 'owner');
1724
+    this.room.setAffiliation(participant.getConnectionJid(), 'owner');
1725 1725
 };
1726 1726
 
1727 1727
 /**
@@ -1735,13 +1735,12 @@ JitsiConference.prototype.revokeOwner = function(id) {
1735 1735
     const role = this.isMembersOnly() ? 'member' : 'none';
1736 1736
 
1737 1737
     if (isMyself) {
1738
-        this.room.setAffiliation(this.room.myroomjid, role);
1738
+        this.room.setAffiliation(this.connection.getJid(), role);
1739 1739
     } else if (participant) {
1740
-        this.room.setAffiliation(participant.getJid(), role);
1740
+        this.room.setAffiliation(participant.getConnectionJid(), role);
1741 1741
     }
1742 1742
 };
1743 1743
 
1744
-
1745 1744
 /**
1746 1745
  * Kick participant from this conference.
1747 1746
  * @param {string} id id of the participant to kick
@@ -1844,6 +1843,7 @@ JitsiConference.prototype.onMemberJoined = function(
1844 1843
     const participant
1845 1844
         = new JitsiParticipant(jid, this, nick, isHidden, statsID, status, identity);
1846 1845
 
1846
+    participant.setConnectionJid(fullJid);
1847 1847
     participant.setRole(role);
1848 1848
     participant.setBotType(botType);
1849 1849
     participant.setFeatures(features);

+ 17
- 0
JitsiParticipant.js Zobrazit soubor

@@ -327,4 +327,21 @@ export default class JitsiParticipant {
327 327
     setBotType(newBotType) {
328 328
         this._botType = newBotType;
329 329
     }
330
+
331
+    /**
332
+     * Returns the connection jid for the participant.
333
+     *
334
+     * @returns {string|undefined} - The connection jid of the participant.
335
+     */
336
+    getConnectionJid() {
337
+        return this._connectionJid;
338
+    }
339
+
340
+    /**
341
+     * Sets the connection jid for the participant.
342
+     * @param {String} newJid - The connection jid to set.
343
+     */
344
+    setConnectionJid(newJid) {
345
+        this._connectionJid = newJid;
346
+    }
330 347
 }

+ 2
- 2
modules/xmpp/ChatRoom.js Zobrazit soubor

@@ -1230,7 +1230,7 @@ export default class ChatRoom extends Listenable {
1230 1230
         .c('query', { xmlns: 'http://jabber.org/protocol/muc#admin' })
1231 1231
         .c('item', {
1232 1232
             affiliation,
1233
-            nick: Strophe.getResourceFromJid(jid)
1233
+            jid: Strophe.getBareJidFromJid(jid)
1234 1234
         })
1235 1235
         .c('reason').t(`Your affiliation has been changed to '${affiliation}'.`)
1236 1236
         .up().up().up();
@@ -1376,7 +1376,7 @@ export default class ChatRoom extends Listenable {
1376 1376
                             xmlns: 'http://jabber.org/protocol/muc#admin' })
1377 1377
                         .c('item', {
1378 1378
                             'affiliation': 'member',
1379
-                            'jid': m.jid
1379
+                            'jid': Strophe.getBareJidFromJid(m.jid)
1380 1380
                         }).up().up());
1381 1381
                 }
1382 1382
             });

+ 12
- 0
types/auto/JitsiParticipant.d.ts Zobrazit soubor

@@ -203,5 +203,17 @@ export default class JitsiParticipant {
203 203
      */
204 204
     setBotType(newBotType: string): void;
205 205
     _botType: string;
206
+    /**
207
+     * Returns the connection jid for the participant.
208
+     *
209
+     * @returns {string|undefined} - The connection jid of the participant.
210
+     */
211
+    getConnectionJid(): string | undefined;
212
+    /**
213
+     * Sets the connection jid for the participant.
214
+     * @param {String} newJid - The connection jid to set.
215
+     */
216
+    setConnectionJid(newJid: string): void;
217
+    _connectionJid: string;
206 218
 }
207 219
 import { MediaType } from "./service/RTC/MediaType";

Načítá se…
Zrušit
Uložit