소스 검색

feat: participant kick reason add

dev1
muammer.yilmaz.x 4 년 전
부모
커밋
7f5d7ce192
2개의 변경된 파일22개의 추가작업 그리고 8개의 파일을 삭제
  1. 7
    5
      JitsiConference.js
  2. 15
    3
      modules/xmpp/ChatRoom.js

+ 7
- 5
JitsiConference.js 파일 보기

@@ -1473,14 +1473,15 @@ JitsiConference.prototype.grantOwner = function(id) {
1473 1473
 /**
1474 1474
  * Kick participant from this conference.
1475 1475
  * @param {string} id id of the participant to kick
1476
+ * @param {string} reason reason of the participant to kick
1476 1477
  */
1477
-JitsiConference.prototype.kickParticipant = function(id) {
1478
+JitsiConference.prototype.kickParticipant = function(id, reason) {
1478 1479
     const participant = this.getParticipantById(id);
1479 1480
 
1480 1481
     if (!participant) {
1481 1482
         return;
1482 1483
     }
1483
-    this.room.kick(participant.getJid());
1484
+    this.room.kick(participant.getJid(), reason);
1484 1485
 };
1485 1486
 
1486 1487
 /**
@@ -1708,8 +1709,9 @@ JitsiConference.prototype.onMemberLeft = function(jid) {
1708 1709
  * of the kick.
1709 1710
  * @param {string?} kickedParticipantId - when it is not a kick for local participant,
1710 1711
  * this is the id of the participant which was kicked.
1712
+ * @param {string} reason - reason of the participant to kick
1711 1713
  */
1712
-JitsiConference.prototype.onMemberKicked = function(isSelfPresence, actorId, kickedParticipantId) {
1714
+JitsiConference.prototype.onMemberKicked = function(isSelfPresence, actorId, kickedParticipantId, reason) {
1713 1715
     // This check which be true when we kick someone else. With the introduction of lobby
1714 1716
     // the ChatRoom KICKED event is now also emitted for ourselves (the kicker) so we want to
1715 1717
     // avoid emitting an event where `undefined` kicked someone.
@@ -1721,7 +1723,7 @@ JitsiConference.prototype.onMemberKicked = function(isSelfPresence, actorId, kic
1721 1723
 
1722 1724
     if (isSelfPresence) {
1723 1725
         this.eventEmitter.emit(
1724
-            JitsiConferenceEvents.KICKED, actorParticipant);
1726
+            JitsiConferenceEvents.KICKED, actorParticipant, reason);
1725 1727
 
1726 1728
         this.leave();
1727 1729
 
@@ -1731,7 +1733,7 @@ JitsiConference.prototype.onMemberKicked = function(isSelfPresence, actorId, kic
1731 1733
     const kickedParticipant = this.participants[kickedParticipantId];
1732 1734
 
1733 1735
     this.eventEmitter.emit(
1734
-        JitsiConferenceEvents.PARTICIPANT_KICKED, actorParticipant, kickedParticipant);
1736
+        JitsiConferenceEvents.PARTICIPANT_KICKED, actorParticipant, kickedParticipant, reason);
1735 1737
 };
1736 1738
 
1737 1739
 /**

+ 15
- 3
modules/xmpp/ChatRoom.js 파일 보기

@@ -987,6 +987,16 @@ export default class ChatRoom extends Listenable {
987 987
                 actorNick = actorSelect.attr('nick');
988 988
             }
989 989
 
990
+            let reason;
991
+            const reasonSelect
992
+                = $(pres).find(
993
+                '>x[xmlns="http://jabber.org/protocol/muc#user"]'
994
+                + '>item>reason');
995
+
996
+            if (reasonSelect.length) {
997
+                reason = reasonSelect.text();
998
+            }
999
+
990 1000
             // we first fire the kicked so we can show the participant
991 1001
             // who kicked, before notifying that participant left
992 1002
             // we fire kicked for us and for any participant kicked
@@ -994,7 +1004,8 @@ export default class ChatRoom extends Listenable {
994 1004
                 XMPPEvents.KICKED,
995 1005
                 isSelfPresence,
996 1006
                 actorNick,
997
-                Strophe.getResourceFromJid(from));
1007
+                Strophe.getResourceFromJid(from),
1008
+                reason);
998 1009
         }
999 1010
 
1000 1011
         if (isSelfPresence) {
@@ -1201,14 +1212,15 @@ export default class ChatRoom extends Listenable {
1201 1212
     /**
1202 1213
      *
1203 1214
      * @param jid
1215
+     * @param reason
1204 1216
      */
1205
-    kick(jid) {
1217
+    kick(jid, reason = 'You have been kicked.') {
1206 1218
         const kickIQ = $iq({ to: this.roomjid,
1207 1219
             type: 'set' })
1208 1220
             .c('query', { xmlns: 'http://jabber.org/protocol/muc#admin' })
1209 1221
             .c('item', { nick: Strophe.getResourceFromJid(jid),
1210 1222
                 role: 'none' })
1211
-            .c('reason').t('You have been kicked.').up().up().up();
1223
+            .c('reason').t(reason).up().up().up();
1212 1224
 
1213 1225
         this.connection.sendIQ(
1214 1226
             kickIQ,

Loading…
취소
저장