Commit 093fd7a2 authored by Seve's avatar Seve Committed by JC Brand

Start overriding renderMessage() properly

parent 226df674
...@@ -183,48 +183,11 @@ ...@@ -183,48 +183,11 @@
* The DOM element representing the message. * The DOM element representing the message.
*/ */
console.log(attrs); console.log(attrs);
let text = attrs.message, let msg = this.__super__.renderMessage.apply(this, arguments);
fullname = this.model.get('fullname') || attrs.fullname, console.log(msg);
template, username; // const msg_content = $msg[0].querySelector('.chat-msg-content');
const match = text.match(/^\/(.*?)(?: (.*))?$/); //Spoiler logic
if ((match) && (match[1] === 'me')) {
text = text.replace(/^\/me/, '');
template = tpl_action;
if (attrs.sender === 'me') {
fullname = _converse.xmppstatus.get('fullname') || attrs.fullname;
username = _.isNil(fullname)? _converse.bare_jid: fullname;
} else {
username = attrs.fullname;
}
} else {
template = tpl_message;
username = attrs.sender === 'me' && _('me') || fullname;
}
this.$content.find('div.chat-event').remove();
if (text.length > 8000) {
text = text.substring(0, 10) + '...';
this.showStatusNotification(
_("A very large message has been received. "+
"This might be due to an attack meant to degrade the chat performance. "+
"Output has been shortened."),
true, true);
}
const msg_time = moment(attrs.time) || moment;
const $msg = $(template(
_.extend(this.getExtraMessageTemplateAttributes(attrs), {
'msgid': attrs.msgid,
'sender': attrs.sender,
'time': msg_time.format(_converse.time_format),
'isodate': msg_time.format(),
'username': username,
'extra_classes': this.getExtraMessageClasses(attrs)
})
));
const msg_content = $msg[0].querySelector('.chat-msg-content');
//Spoiler logic
if ('spoiler' in attrs) { if ('spoiler' in attrs) {
let button = document.createElement("<button>"), let button = document.createElement("<button>"),
container = document.createElement("<div>"), container = document.createElement("<div>"),
...@@ -261,13 +224,10 @@ ...@@ -261,13 +224,10 @@
container.append(content); container.append(content);
msg_content.append(container); msg.append(container);
} else {
return this.__super__.renderMessage.apply(this, arguments);
} }
return $msg; return msg;
} }
}, },
'ChatBox': { 'ChatBox': {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment