Skip to content

Commit 8571b03

Browse files
committed
Only open room if it was in a conference domain
1 parent b450861 commit 8571b03

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/plugins/muc-views/modals/muc-list.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class MUCListModal extends BaseModal {
8686
'server_placeholder': this.model.get('muc_domain') || __('conference.example.org'),
8787
'items': this.items,
8888
'loading_items': this.loading_items,
89-
'openRoom': ev => this.openRoom(ev),
89+
'openItem': ev => this.openItem(ev),
9090
'setDomainFromEvent': ev => this.setDomainFromEvent(ev),
9191
'submitForm': ev => this.showRooms(ev),
9292
'toggleRoomInfo': ev => this.toggleRoomInfo(ev)
@@ -97,12 +97,31 @@ export default class MUCListModal extends BaseModal {
9797
return __('Query for Groupchats');
9898
}
9999

100-
openRoom (ev) {
100+
openRoom (jid, name) {
101+
this.modal.hide();
102+
api.rooms.open(jid, {'name': name}, true);
103+
}
104+
105+
onInfoReceived (iq, jid, name) {
106+
const identity = sizzle('query identity', iq).pop();
107+
if (identity.getAttribute('category') === 'conference') {
108+
this.openRoom(jid, name);
109+
} else {
110+
this.model.setDomain(jid);
111+
}
112+
}
113+
114+
openItem (ev) {
101115
ev.preventDefault();
102116
const jid = ev.target.getAttribute('data-room-jid');
103117
const name = ev.target.getAttribute('data-room-name');
104-
this.modal.hide();
105-
api.rooms.open(jid, {'name': name}, true);
118+
const iq = $iq({
119+
'to': this.model.get('muc_domain'),
120+
'from': api.connection.get().jid,
121+
'type': "get"
122+
}).c("query", {xmlns: Strophe.NS.DISCO_INFO});
123+
api.sendIQ(iq)
124+
.then(iq => this.onInfoReceived(iq, jid, name))
106125
}
107126

108127
toggleRoomInfo (ev) {

src/plugins/muc-views/templates/muc-list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const tplItem = (o, item) => {
3434
<li class="room-item list-group-item">
3535
<div class="available-chatroom d-flex flex-row">
3636
<a class="open-room available-room w-100"
37-
@click=${o.openRoom}
37+
@click=${o.openItem}
3838
data-room-jid="${item.jid}"
3939
data-room-name="${item.name}"
4040
title="${i18n_open_title}"

0 commit comments

Comments
 (0)