|
@@ -1,18 +1,13 @@
|
|
|
-// Converse.js (A browser based XMPP chat client)
|
|
|
+// Converse.js
|
|
|
// http://conversejs.org
|
|
|
//
|
|
|
-// Copyright (c) 2012-2018, Jan-Carel Brand <jc@opkode.com>
|
|
|
+// Copyright (c) 2012-2018, the Converse.js developers
|
|
|
// Licensed under the Mozilla Public License (MPLv2)
|
|
|
-//
|
|
|
|
|
|
-/* This is a Converse.js plugin which add support for multi-user chat rooms, as
|
|
|
- * specified in XEP-0045 Multi-user chat.
|
|
|
- */
|
|
|
(function (root, factory) {
|
|
|
define([
|
|
|
"converse-core",
|
|
|
"muc-utils",
|
|
|
- "emojione",
|
|
|
"tpl!add_chatroom_modal",
|
|
|
"tpl!chatarea",
|
|
|
"tpl!chatroom",
|
|
@@ -39,7 +34,6 @@
|
|
|
}(this, function (
|
|
|
converse,
|
|
|
muc_utils,
|
|
|
- emojione,
|
|
|
tpl_add_chatroom_modal,
|
|
|
tpl_chatarea,
|
|
|
tpl_chatroom,
|
|
@@ -504,7 +498,6 @@
|
|
|
'click .occupant': 'onOccupantClicked',
|
|
|
'click .send-button': 'onFormSubmitted',
|
|
|
'click .toggle-call': 'toggleCall',
|
|
|
- 'click .toggle-clear': 'clearChatRoomMessages',
|
|
|
'click .toggle-occupants': 'toggleOccupants',
|
|
|
'click .toggle-smiley ul.emoji-picker li': 'insertEmoji',
|
|
|
'click .toggle-smiley': 'toggleEmojiMenu',
|
|
@@ -738,32 +731,6 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- sendChatRoomMessage (text) {
|
|
|
- /* Constuct a message stanza to be sent to this chat room,
|
|
|
- * and send it to the server.
|
|
|
- *
|
|
|
- * Parameters:
|
|
|
- * (String) text: The message text to be sent.
|
|
|
- */
|
|
|
- text = u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse)
|
|
|
- const msgid = _converse.connection.getUniqueId();
|
|
|
- const msg = $msg({
|
|
|
- to: this.model.get('jid'),
|
|
|
- from: _converse.connection.jid,
|
|
|
- type: 'groupchat',
|
|
|
- id: msgid
|
|
|
- }).c("body").t(text).up()
|
|
|
- .c("x", {xmlns: "jabber:x:event"}).c(_converse.COMPOSING);
|
|
|
- _converse.connection.send(msg);
|
|
|
- this.model.messages.create({
|
|
|
- 'fullname': this.model.get('nick'),
|
|
|
- 'sender': 'me',
|
|
|
- 'time': moment().format(),
|
|
|
- 'message': text,
|
|
|
- msgid
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
modifyRole(room, nick, role, reason, onSuccess, onError) {
|
|
|
const item = $build("item", {nick, role});
|
|
|
const iq = $iq({to: room, type: "set"}).c("query", {xmlns: Strophe.NS.MUC_ADMIN}).cnode(item.node);
|
|
@@ -787,30 +754,17 @@
|
|
|
return true;
|
|
|
},
|
|
|
|
|
|
- clearChatRoomMessages (ev) {
|
|
|
- /* Remove all messages from the chat room UI.
|
|
|
- */
|
|
|
- if (!_.isUndefined(ev)) { ev.stopPropagation(); }
|
|
|
- const result = confirm(__("Are you sure you want to clear the messages from this room?"));
|
|
|
- if (result === true) {
|
|
|
- this.content.innerHTML = '';
|
|
|
- }
|
|
|
- return this;
|
|
|
- },
|
|
|
-
|
|
|
onCommandError () {
|
|
|
this.showErrorMessage(__("Error: could not execute the command"), true);
|
|
|
},
|
|
|
|
|
|
- onMessageSubmitted (text, spoiler_hint) {
|
|
|
- /* Gets called when the user presses enter to send off a
|
|
|
- * message in a chat room.
|
|
|
- *
|
|
|
- * Parameters:
|
|
|
- * (String) text - The message text.
|
|
|
- */
|
|
|
+ parseMessageForCommands (text) {
|
|
|
+ const _super_ = _converse.ChatBoxView.prototype;
|
|
|
+ if (_super_.parseMessageForCommands.apply(this, arguments)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
if (_converse.muc_disable_moderator_commands) {
|
|
|
- return this.sendChatRoomMessage(text);
|
|
|
+ return false;
|
|
|
}
|
|
|
const match = text.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false, '', ''],
|
|
|
args = match[2] && match[2].splitOnce(' ') || [],
|
|
@@ -830,9 +784,6 @@
|
|
|
'reason': args[1]
|
|
|
}]).then(null, this.onCommandError.bind(this));
|
|
|
break;
|
|
|
- case 'clear':
|
|
|
- this.clearChatRoomMessages();
|
|
|
- break;
|
|
|
case 'deop':
|
|
|
if (!this.validateRoleChangeCommand(command, args)) { break; }
|
|
|
this.modifyRole(
|
|
@@ -922,9 +873,9 @@
|
|
|
undefined, this.onCommandError.bind(this));
|
|
|
break;
|
|
|
default:
|
|
|
- this.sendChatRoomMessage(text);
|
|
|
- break;
|
|
|
+ return false;
|
|
|
}
|
|
|
+ return true;
|
|
|
},
|
|
|
|
|
|
registerHandlers () {
|