mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
Add some type checking on event body
This commit is contained in:
parent
7900e2292d
commit
c663a57dff
1 changed files with 6 additions and 4 deletions
|
@ -412,11 +412,13 @@ export function bodyToHtml(content, highlights, opts={}) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let formattedBody = content.formatted_body;
|
let formattedBody = typeof content.formatted_body === 'string' ? content.formatted_body : null;
|
||||||
if (opts.stripReplyFallback && formattedBody) formattedBody = ReplyThread.stripHTMLReply(formattedBody);
|
const plainBody = typeof content.body === 'string' ? content.body : null;
|
||||||
strippedBody = opts.stripReplyFallback ? ReplyThread.stripPlainReply(content.body) : content.body;
|
|
||||||
|
|
||||||
bodyHasEmoji = mightContainEmoji(isHtmlMessage ? formattedBody : content.body);
|
if (opts.stripReplyFallback && formattedBody) formattedBody = ReplyThread.stripHTMLReply(formattedBody);
|
||||||
|
strippedBody = opts.stripReplyFallback ? ReplyThread.stripPlainReply(plainBody) : plainBody;
|
||||||
|
|
||||||
|
bodyHasEmoji = mightContainEmoji(isHtmlMessage ? formattedBody : plainBody);
|
||||||
|
|
||||||
// Only generate safeBody if the message was sent as org.matrix.custom.html
|
// Only generate safeBody if the message was sent as org.matrix.custom.html
|
||||||
if (isHtmlMessage) {
|
if (isHtmlMessage) {
|
||||||
|
|
Loading…
Reference in a new issue