|
@@ -259,10 +259,16 @@ export default class ChatRoom extends Listenable {
|
259
|
259
|
* Sends the presence unavailable, signaling the server
|
260
|
260
|
* we want to leave the room.
|
261
|
261
|
*/
|
262
|
|
- doLeave() {
|
|
262
|
+ doLeave(reason) {
|
263
|
263
|
logger.log('do leave', this.myroomjid);
|
264
|
|
- const pres = $pres({ to: this.myroomjid,
|
265
|
|
- type: 'unavailable' });
|
|
264
|
+ const pres = $pres({
|
|
265
|
+ to: this.myroomjid,
|
|
266
|
+ type: 'unavailable'
|
|
267
|
+ });
|
|
268
|
+
|
|
269
|
+ if (reason) {
|
|
270
|
+ pres.c('status').t(reason).up();
|
|
271
|
+ }
|
266
|
272
|
|
267
|
273
|
this.presMap.length = 0;
|
268
|
274
|
|
|
@@ -937,15 +943,16 @@ export default class ChatRoom extends Listenable {
|
937
|
943
|
* @param jid the jid of the participant that leaves
|
938
|
944
|
* @param skipEvents optional params to skip any events, including check
|
939
|
945
|
* whether this is the focus that left
|
|
946
|
+ * @param reason the reason for leaving (optional).
|
940
|
947
|
*/
|
941
|
|
- onParticipantLeft(jid, skipEvents) {
|
|
948
|
+ onParticipantLeft(jid, skipEvents, reason) {
|
942
|
949
|
delete this.lastPresences[jid];
|
943
|
950
|
|
944
|
951
|
if (skipEvents) {
|
945
|
952
|
return;
|
946
|
953
|
}
|
947
|
954
|
|
948
|
|
- this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
|
|
955
|
+ this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid, reason);
|
949
|
956
|
|
950
|
957
|
this.moderator.onMucMemberLeft(jid);
|
951
|
958
|
}
|
|
@@ -1047,8 +1054,15 @@ export default class ChatRoom extends Listenable {
|
1047
|
1054
|
this.eventEmitter.emit(XMPPEvents.MUC_LEFT);
|
1048
|
1055
|
}
|
1049
|
1056
|
} else {
|
|
1057
|
+ const reasonSelect = $(pres).find('>status');
|
|
1058
|
+ let reason;
|
|
1059
|
+
|
|
1060
|
+ if (reasonSelect.length) {
|
|
1061
|
+ reason = reasonSelect.text();
|
|
1062
|
+ }
|
|
1063
|
+
|
1050
|
1064
|
delete this.members[from];
|
1051
|
|
- this.onParticipantLeft(from, false);
|
|
1065
|
+ this.onParticipantLeft(from, false, reason);
|
1052
|
1066
|
}
|
1053
|
1067
|
}
|
1054
|
1068
|
|
|
@@ -1829,7 +1843,7 @@ export default class ChatRoom extends Listenable {
|
1829
|
1843
|
* less than 5s after sending presence unavailable. Otherwise the promise is
|
1830
|
1844
|
* rejected.
|
1831
|
1845
|
*/
|
1832
|
|
- leave() {
|
|
1846
|
+ leave(reason) {
|
1833
|
1847
|
this.avModeration.dispose();
|
1834
|
1848
|
this.breakoutRooms.dispose();
|
1835
|
1849
|
|
|
@@ -1856,7 +1870,7 @@ export default class ChatRoom extends Listenable {
|
1856
|
1870
|
|
1857
|
1871
|
this.clean();
|
1858
|
1872
|
this.eventEmitter.on(XMPPEvents.MUC_LEFT, onMucLeft);
|
1859
|
|
- this.doLeave();
|
|
1873
|
+ this.doLeave(reason);
|
1860
|
1874
|
}));
|
1861
|
1875
|
|
1862
|
1876
|
return Promise.allSettled(promises);
|