[FIX] mail: load around not formatting parent messages

This results in parent message being displayed as text when it is part
of the result of a load around call.

closes odoo/odoo#125439

X-original-commit: 783a5186cf7529161d95c34c9290dc57a32b8200
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Sébastien Theys
2023-06-16 23:01:24 +02:00
parent d619908772
commit 70b4ba4539
2 changed files with 21 additions and 6 deletions
@@ -316,12 +316,15 @@ export class ThreadService {
...this.getFetchParams(thread),
around: messageId,
});
thread.messages = messages.reverse().map((message) =>
this.messageService.insert({
thread.messages = messages.reverse().map((message) => {
if (message.parentMessage?.body) {
message.parentMessage.body = markup(message.parentMessage.body);
}
return this.messageService.insert({
...message,
body: message.body ? markup(message.body) : message.body,
})
);
});
});
thread.loadNewer = messageId ? true : false;
thread.loadOlder = true;
if (messages.length < FETCH_LIMIT) {
@@ -62,15 +62,22 @@ QUnit.test("Jump to old reply should prompt jump to presence", async (assert) =>
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({ name: "General" });
const oldestMessageId = pyEnv["mail.message"].create({
body: "Hello world!",
body: "<p>Hello world!</p>",
model: "discuss.channel",
res_id: channelId,
});
for (let i = 0; i < 100; i++) {
pyEnv["mail.message"].create({
body: "Non Empty Body ".repeat(100),
body: "<p>Non Empty Body</p>".repeat(100),
message_type: "comment",
model: "discuss.channel",
/**
* The first message following the oldest message should have it as its parent message
* so that the oldest message is inserted through the parent field during "load around"
* to have the coverage of this part of the code (in particular having parent message
* body being inserted with markup).
*/
parent_id: i === 0 ? oldestMessageId : undefined,
res_id: channelId,
});
}
@@ -84,6 +91,11 @@ QUnit.test("Jump to old reply should prompt jump to presence", async (assert) =>
await openDiscuss(channelId);
await click(".o-mail-MessageInReply .cursor-pointer");
assert.isVisible($(".o-mail-Message:contains(Hello world!):eq(0)")[0]);
assert.strictEqual(
$(".o-mail-Message-body:contains(Hello world!):eq(0)").text(),
"Hello world!",
"should correctly execute HTML tags in parent message when using 'load around' feature"
);
assert.containsOnce($, ".o-mail-Thread:contains(You're viewing older messagesJump to Present)");
await click(".o-mail-Thread-jumpPresent");
await nextAnimationFrame();