[FIX] mail: no crash when mentioning partner after channel mention

Steps to reproduce:
- Open channel general
- type "#" in composer so it prompts "#general"
- delete "#"
- type "@" in composer

This happens because the partner suggestion part relies on raw server
data in model thread, `thread.channel`, which is erased from the
channel suggestion. This was used to detect whether partner is member
or not, in `thread.channel.channelMembers`.

This commit fixes the issue by making partner suggestion relies on
more reliable data in models, `thread.channelMembers`.
`thread.channel` is deprecated, and will eventually be removed.

closes odoo/odoo#119935

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-04-28 13:33:17 +02:00
parent d11bf24dea
commit e155eda05c
@@ -216,9 +216,9 @@ export class SuggestionService {
if (!isAInternalUser && isBInternalUser) {
return 1;
}
if (thread?.channel) {
const isMember1 = thread.channel.channelMembers[0][1].includes(p1);
const isMember2 = thread.channel.channelMembers[0][1].includes(p2);
if (thread.model === "discuss.channel") {
const isMember1 = thread.channelMembers.some((member) => member.persona === p1);
const isMember2 = thread.channelMembers.some((member) => member.persona === p2);
if (isMember1 && !isMember2) {
return -1;
}