Commit fa59b22f authored by JC Brand's avatar JC Brand

converse-message-view: Move methods from view to model

parent 21a9ea73
......@@ -219,7 +219,7 @@ converse.plugins.add('converse-message-view', {
* @example _converse.api.listen.on('beforeMessageBodyTransformed', (view, text) => { ... });
*/
await _converse.api.trigger('beforeMessageBodyTransformed', this, text, {'Synchronous': true});
text = this.isMeCommand() ? text.substring(4) : text;
text = this.model.isMeCommand() ? text.substring(4) : text;
text = xss.filterXSS(text, {'whiteList': {}, 'onTag': onTagFoundDuringXSSFilter});
text = u.geoUriToHttp(text, _converse.geouri_replacement);
text = u.addMentionsMarkup(text, this.model.get('references'), this.model.collection.chatbox);
......@@ -239,7 +239,7 @@ converse.plugins.add('converse-message-view', {
},
async renderChatMessage () {
const is_me_message = this.isMeCommand();
const is_me_message = this.model.isMeCommand();
const time = dayjs(this.model.get('time'));
const role = this.model.vcard ? this.model.vcard.get('role') : null;
const roles = role ? role.split(',') : [];
......@@ -265,7 +265,7 @@ converse.plugins.add('converse-message-view', {
msg.querySelector('.chat-msg__media').innerHTML = this.transformOOBURL(url);
}
const text = this.getMessageText();
const text = this.model.getMessageText();
const msg_content = msg.querySelector('.chat-msg__text');
if (text && text !== url) {
msg_content.innerHTML = await this.transformBodyText(text);
......@@ -353,27 +353,6 @@ converse.plugins.add('converse-message-view', {
this.model.message_versions_modal.show(ev);
},
getMessageText () {
if (this.model.get('is_encrypted')) {
return this.model.get('plaintext') ||
(_converse.debug ? __('Unencryptable OMEMO message') : null);
}
return this.model.get('message');
},
isMeCommand () {
const text = this.getMessageText();
if (!text) {
return false;
}
return text.startsWith('/me ');
},
processMessageText () {
var text = this.get('message');
text = u.geoUriToHttp(text, _converse.geouri_replacement);
},
getExtraMessageClasses () {
let extra_classes = this.model.get('is_delayed') && 'delayed' || '';
......
......@@ -150,6 +150,22 @@ converse.plugins.add('converse-chatboxes', {
}
},
getMessageText () {
if (this.get('is_encrypted')) {
return this.get('plaintext') ||
(_converse.debug ? __('Unencryptable OMEMO message') : null);
}
return this.get('message');
},
isMeCommand () {
const text = this.getMessageText();
if (!text) {
return false;
}
return text.startsWith('/me ');
},
sendSlotRequestStanza () {
/* Send out an IQ stanza to request a file upload slot.
*
......
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