The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/packages/rocketchat-lib/lib/Message.js

30 lines
879 B

9 years ago
RocketChat.Message = {
parse(msg, language) {
const messageType = RocketChat.MessageTypes.getType(msg);
if (messageType) {
if (messageType.render) {
return messageType.render(msg);
} else if (messageType.template) {
// Render message
return;
} else if (messageType.message) {
if (!language && typeof localStorage !== 'undefined') {
language = localStorage.getItem('userLanguage');
}
const data = (typeof messageType.data === 'function' && messageType.data(msg)) || {};
return TAPi18n.__(messageType.message, data, language);
}
}
if (msg.u && msg.u.username === RocketChat.settings.get('Chatops_Username')) {
msg.html = msg.msg;
return msg.html;
}
msg.html = msg.msg;
if (_.trim(msg.html) !== '') {
msg.html = _.escapeHTML(msg.html);
}
msg.html = msg.html.replace(/\n/gm, '<br/>');
return msg.html;
}
};