[FIX] mail: selfFollower should be included in the followers

Before this PR, the current user was not considered has a follower, regarding
the mention suggestions.
This lead him to be lower than other entries.
This PR fix the issue by adding him back to the follower list.

Task-3531111

closes odoo/odoo#137583

X-original-commit: 50a785fedc5b5c7fd826548e52385bdf458c97a2
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Didier Debondt (did) <did@odoo.com>
This commit is contained in:
Didier (did)
2023-10-06 06:14:04 +00:00
parent 8e3ffe7800
commit f1abc4e4f3
2 changed files with 33 additions and 0 deletions
@@ -31,6 +31,9 @@ partnerCompareRegistry.add(
(p1, p2, { thread }) => {
if (thread) {
const followerList = [...thread.followers];
if (thread.selfFollower) {
followerList.push(thread.selfFollower);
}
const isFollower1 = followerList.some((follower) => p1.eq(follower.partner));
const isFollower2 = followerList.some((follower) => p2.eq(follower.partner));
if (isFollower1 && !isFollower2) {
@@ -285,3 +285,33 @@ QUnit.test("Internal user should be displayed first", async () => {
await contains(":nth-child(3 of .o-mail-Composer-suggestion) strong", { text: "Person B" });
await contains(":nth-child(4 of .o-mail-Composer-suggestion) strong", { text: "Person A" });
});
QUnit.test("Current user that is a follower should be considered as such", async () => {
const pyEnv = await startServer();
const userId = pyEnv["res.users"].create({ share: true });
pyEnv["res.partner"].create([
{ email: "a@test.com", name: "Person A" },
{ email: "b@test.com", name: "Person B", user_ids: [userId] },
]);
pyEnv["mail.followers"].create([
{
is_active: true,
partner_id: pyEnv.currentPartnerId,
res_id: pyEnv.currentPartnerId,
res_model: "res.partner",
},
]);
const { openFormView } = await start();
await openFormView("res.partner", pyEnv.currentPartnerId);
await click("button", { text: "Send message" });
await insertText(".o-mail-Composer-input", "@");
await contains(".o-mail-Composer-suggestion", { count: 3 });
await contains(".o-mail-Composer-suggestion", {
text: "Mitchell Admin",
before: [".o-mail-Composer-suggestion", { text: "Person B(b@test.com)" }],
});
await contains(".o-mail-Composer-suggestion", {
text: "Person B(b@test.com)",
before: [".o-mail-Composer-suggestion", { text: "Person A(a@test.com)" }],
});
});