8000 [FIX] mail: ensure call starter name is displayed correctly · odoo/odoo@3604b52 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3604b52

Browse files
jayp-odooalexkuhn
authored andcommitted
[FIX] mail: ensure call starter name is displayed correctly
purpose of this commit : The name was appearing as undefined because message.author.name was not set for portal users. to handle this, we used message.authorName directly. also it was changed to message.authorName to be consistent with the rest of the code. task-4782291 closes #209389 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
1 parent da58fe6 commit 3604b52

File tree

5 files changed

+60
-4
lines changed

5 files changed

+60
-4
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
click,
3+
contains,
4+
mockGetMedia,
5+
setupChatHub,
6+
start,
7+
startServer,
8+
} from "@mail/../tests/mail_test_helpers";
9+
10+
import { defineLivechatModels } from "@im_livechat/../tests/livechat_test_helpers";
11+
12+
import { test } from "@odoo/hoot";
13+
import { mockDate } from "@odoo/hoot-mock";
14+
15+
import { Command, serverState } from "@web/../tests/web_test_helpers";
16+
17+
defineLivechatModels();
18+
19+
test.tags("desktop");
20+
test("should display started a call message with operator livechat username", async () => {
21+
mockDate("2025-01-01 12:00:00", +1);
22+
mockGetMedia();
23+
const pyEnv = await startServer();
24+
pyEnv["res.partner"].write(serverState.partnerId, {
25+
user_livechat_username: "mitchell boss",
26+
});
27+
const guestId = pyEnv["mail.guest"].create({ name: "Visitor" });
28+
const channelId = pyEnv["discuss.channel"].create({
29+
anonymous_name: "Visitor",
30+
channel_member_ids: [
31+
Command.create({ partner_id: serverState.partnerId }),
32+
Command.create({ guest_id: guestId }),
33+
],
34+
channel_type: "livechat",
35+
livechat_active: true,
36+
livechat_operator_id: serverState.partnerId,
37+
});
38+
setupChatHub({ opened: [channelId] });
39+
await start();
40+
await contains(".o-mail-ChatWindow", { text: "Visitor" });
41+
await click("[title='Start a Call']");
42+
await contains(".o-mail-NotificationMessage", { text: "mitchell boss started a call.1:00 PM" });
43+
});

addons/mail/static/src/core/common/message_model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class Message extends Record {
357357
/** @this {import("models").Message} */
358358
compute() {
359359
if (this.notificationType === "call") {
360-
return _t("%(caller)s started a call", { caller: this.author.name });
360+
return _t("%(caller)s started a call", { caller: this.authorName });
361361
}
362362
if (this.isEmpty) {
363363
return _t("This message has been removed");

addons/mail/static/src/core/common/notification_message.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class NotificationMessage extends Component {
5353
get callInformation() {
5454
const history = this.message.call_history_ids[0];
5555
if (history?.duration_hour === undefined || !history?.end_dt) {
56-
return _t("%(author)s started a call.", { author: this.message.author.name });
56+
return _t("%(author)s started a call.", { author: this.message.authorName });
5757
}
5858
let duration = luxon.Duration.fromObject({
5959
seconds: Math.max(1, Math.round(history.duration_hour * 3600)),

addons/mail/static/src/core/common/out_of_focus_service.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export class OutOfFocusService {
4444
icon = author.avatarUrl;
4545
if (message.thread?.channel_type === "channel") {
4646
notificationTitle = _t("%(author name)s from %(channel name)s", {
47-
"author name": author.name,
47+
"author name": message.authorName,
4848
"channel name": message.thread.displayName,
4949
});
5050
} else {
51-
notificationTitle = author.name;
51+
notificationTitle = message.authorName;
5252
}
5353
}
5454
const notificationContent = message.previewText

addons/mail/static/tests/mock_server/mock_models/discuss_channel_rtc_session.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ export class DiscussChannelRtcSession extends models.ServerModel {
3838
}).get_result(),
3939
]);
4040
}
41+
for (const record of rtcSessions) {
42+
const [channel] = DiscussChannel.browse(record.channel_id);
43+
if (channel.rtc_session_ids.length === 1) {
44+
DiscussChannel.message_post(
45+
channel.id,
46+
makeKwArgs({
47+
body: `<div data-oe-type="call" class="o_mail_notification"></div>`,
48+
message_type: "notification",
49+
subtype_xmlid: "mail.mt_comment",
50+
})
51+
);
52+
}
53+
}
4154
BusBus._sendmany(notifications);
4255
return sessionIds;
4356
}

0 commit comments

Comments
 (0)
0