[REF] mail: use the channelMember relation for RtcSession
part of task-2692836 closes odoo/odoo#96394 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -99,6 +99,7 @@ class MailRtcSession(models.Model):
|
||||
self.ensure_one()
|
||||
vals = {
|
||||
'id': self.id,
|
||||
'channelMember': [('insert-and-replace', self.channel_member_id.mail_channel_member_format()[0])],
|
||||
}
|
||||
if complete_info:
|
||||
vals.update({
|
||||
@@ -107,16 +108,6 @@ class MailRtcSession(models.Model):
|
||||
'isSelfMuted': self.is_muted,
|
||||
'isScreenSharingOn': self.is_screen_sharing_on,
|
||||
})
|
||||
if self.guest_id:
|
||||
vals['guest'] = [('insert', {
|
||||
'id': self.guest_id.id,
|
||||
'name': self.guest_id.name,
|
||||
})]
|
||||
else:
|
||||
vals['partner'] = [('insert', {
|
||||
'id': self.partner_id.id,
|
||||
'name': self.partner_id.name,
|
||||
})]
|
||||
return vals
|
||||
|
||||
def _mail_rtc_session_format_by_channel(self):
|
||||
|
||||
+2
-2
@@ -7,10 +7,10 @@
|
||||
<t t-if="callInviteRequestPopup.thread.rtcInvitingSession">
|
||||
<div class="o_CallInviteRequestPopup_partnerInfo d-flex flex-column justify-content-around align-items-center text-nowrap">
|
||||
<img class="o_CallInviteRequestPopup_partnerInfoImage mb-2 rounded-circle o_cursor_pointer"
|
||||
t-att-src="callInviteRequestPopup.thread.rtcInvitingSession.avatarUrl"
|
||||
t-att-src="callInviteRequestPopup.thread.rtcInvitingSession.channelMember.avatarUrl"
|
||||
t-on-click="callInviteRequestPopup.onClickAvatar"
|
||||
alt="Avatar"/>
|
||||
<span class="o_CallInviteRequestPopup_partnerInfoName w-100 fw-bolder text-truncate text-center overflow-hidden" t-esc="callInviteRequestPopup.thread.rtcInvitingSession.name"/>
|
||||
<span class="o_CallInviteRequestPopup_partnerInfoName w-100 fw-bolder text-truncate text-center overflow-hidden" t-esc="callInviteRequestPopup.thread.rtcInvitingSession.channelMember.persona.name"/>
|
||||
<span class="o_CallInviteRequestPopup_partnerInfoText fst-italic opacity-75">Incoming Call...</span>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -75,7 +75,7 @@ registerModel({
|
||||
return;
|
||||
}
|
||||
if (this.rtcSession) {
|
||||
return this.rtcSession.avatarUrl;
|
||||
return this.rtcSession.channelMember.avatarUrl;
|
||||
}
|
||||
if (this.invitedMember) {
|
||||
return this.invitedMember.avatarUrl;
|
||||
@@ -136,7 +136,7 @@ registerModel({
|
||||
*/
|
||||
_computeName() {
|
||||
if (this.rtcSession) {
|
||||
return this.rtcSession.name;
|
||||
return this.rtcSession.channelMember.persona.name;
|
||||
}
|
||||
if (this.invitedMember) {
|
||||
return this.invitedMember.name;
|
||||
|
||||
@@ -51,9 +51,6 @@ registerModel({
|
||||
readonly: true,
|
||||
required: true,
|
||||
}),
|
||||
rtcSessions: many('RtcSession', {
|
||||
inverse: 'guest',
|
||||
}),
|
||||
volumeSetting: one('res.users.settings.volumes', {
|
||||
inverse: 'guest_id',
|
||||
}),
|
||||
|
||||
@@ -444,9 +444,6 @@ registerModel({
|
||||
readonly: true,
|
||||
required: true,
|
||||
}),
|
||||
rtcSessions: many('RtcSession', {
|
||||
inverse: 'partner',
|
||||
}),
|
||||
suggestable: one('ComposerSuggestable', {
|
||||
default: insertAndReplace(),
|
||||
inverse: 'partner',
|
||||
|
||||
@@ -74,18 +74,18 @@ registerModel({
|
||||
if (this.isOwnSession) {
|
||||
return;
|
||||
}
|
||||
if (this.partner && this.partner.volumeSetting) {
|
||||
this.partner.volumeSetting.update({ volume });
|
||||
if (this.channelMember.persona.partner && this.channelMember.persona.partner.volumeSetting) {
|
||||
this.channelMember.persona.partner.volumeSetting.update({ volume });
|
||||
}
|
||||
if (this.guest && this.guest.volumeSetting) {
|
||||
this.guest.volumeSetting.update({ volume });
|
||||
if (this.channelMember.persona.guest && this.channelMember.persona.guest.volumeSetting) {
|
||||
this.channelMember.persona.guest.volumeSetting.update({ volume });
|
||||
}
|
||||
if (this.messaging.isCurrentUserGuest) {
|
||||
return;
|
||||
}
|
||||
this.messaging.userSetting.saveVolumeSetting({
|
||||
partnerId: this.partner && this.partner.id,
|
||||
guestId: this.guest && this.guest.id,
|
||||
partnerId: this.channelMember.persona.partner && this.channelMember.persona.partner.id,
|
||||
guestId: this.channelMember.persona.guest && this.channelMember.persona.guest.id,
|
||||
volume,
|
||||
});
|
||||
},
|
||||
@@ -162,21 +162,6 @@ registerModel({
|
||||
this.update({ videoStream: stream });
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {string}
|
||||
*/
|
||||
_computeAvatarUrl() {
|
||||
if (!this.channel) {
|
||||
return;
|
||||
}
|
||||
if (this.partner) {
|
||||
return `/mail/channel/${this.channel.id}/partner/${this.partner.id}/avatar_128`;
|
||||
}
|
||||
if (this.guest) {
|
||||
return `/mail/channel/${this.channel.id}/guest/${this.guest.id}/avatar_128?unique=${this.guest.name}`;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {boolean}
|
||||
@@ -189,11 +174,11 @@ registerModel({
|
||||
* @returns {boolean}
|
||||
*/
|
||||
_computeIsOwnSession() {
|
||||
if (!this.messaging) {
|
||||
if (!this.messaging || !this.channelMember) {
|
||||
return;
|
||||
}
|
||||
return (this.partner && this.messaging.currentPartner === this.partner) ||
|
||||
(this.guest && this.messaging.currentGuest === this.guest);
|
||||
return (this.channelMember.persona.partner && this.messaging.currentPartner === this.channelMember.persona.partner) ||
|
||||
(this.channelMember.persona.guest && this.messaging.currentGuest === this.channelMember.persona.guest);
|
||||
},
|
||||
/**
|
||||
* Updates the track that is broadcasted to the remote of this session.
|
||||
@@ -247,18 +232,6 @@ registerModel({
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {string}
|
||||
*/
|
||||
_computeName() {
|
||||
if (this.partner) {
|
||||
return this.partner.name;
|
||||
}
|
||||
if (this.guest) {
|
||||
return this.guest.name;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {FieldCommand}
|
||||
@@ -284,10 +257,12 @@ registerModel({
|
||||
* @returns {number} float
|
||||
*/
|
||||
_computeVolume() {
|
||||
if (this.partner && this.partner.volumeSetting) {
|
||||
return this.partner.volumeSetting.volume;
|
||||
} else if (this.guest && this.guest.volumeSetting) {
|
||||
return this.guest.volumeSetting.volume;
|
||||
if (this.channelMember) {
|
||||
if (this.channelMember.persona.partner && this.channelMember.persona.partner.volumeSetting) {
|
||||
return this.channelMember.persona.partner.volumeSetting.volume;
|
||||
} else if (this.channelMember.persona.guest && this.channelMember.persona.guest.volumeSetting) {
|
||||
return this.channelMember.persona.guest.volumeSetting.volume;
|
||||
}
|
||||
}
|
||||
if (this.audioElement) {
|
||||
return this.audioElement.volume;
|
||||
@@ -333,10 +308,10 @@ registerModel({
|
||||
console.error(error);
|
||||
}
|
||||
audioElement.load();
|
||||
if (this.partner && this.partner.volumeSetting) {
|
||||
audioElement.volume = this.partner.volumeSetting.volume;
|
||||
} else if (this.guest && this.guest.volumeSetting) {
|
||||
audioElement.volume = this.guest.volumeSetting.volume;
|
||||
if (this.channelMember.persona.partner && this.channelMember.persona.partner.volumeSetting) {
|
||||
audioElement.volume = this.channelMember.persona.partner.volumeSetting.volume;
|
||||
} else if (this.channelMember.persona.guest && this.channelMember.persona.guest.volumeSetting) {
|
||||
audioElement.volume = this.channelMember.persona.guest.volumeSetting.volume;
|
||||
} else {
|
||||
audioElement.volume = this.volume;
|
||||
}
|
||||
@@ -379,12 +354,6 @@ registerModel({
|
||||
* MediaStream
|
||||
*/
|
||||
audioStream: attr(),
|
||||
/**
|
||||
* The relative url of the image that represents the session.
|
||||
*/
|
||||
avatarUrl: attr({
|
||||
compute: '_computeAvatarUrl',
|
||||
}),
|
||||
broadcastTimer: one('Timer', {
|
||||
inverse: 'rtcSessionOwnerAsBroadcast',
|
||||
isCausal: true,
|
||||
@@ -396,6 +365,7 @@ registerModel({
|
||||
channel: one('Thread', {
|
||||
inverse: 'rtcSessions',
|
||||
}),
|
||||
channelMember: one('ChannelMember'),
|
||||
connectionRecoveryTimeout: attr(),
|
||||
/**
|
||||
* State of the connection with this session, uses RTCPeerConnection.iceConnectionState
|
||||
@@ -404,9 +374,6 @@ registerModel({
|
||||
connectionState: attr({
|
||||
default: 'Waiting for the peer to send a RTC offer',
|
||||
}),
|
||||
guest: one('Guest', {
|
||||
inverse: 'rtcSessions',
|
||||
}),
|
||||
/**
|
||||
* Id of the record on the server.
|
||||
*/
|
||||
@@ -499,21 +466,6 @@ registerModel({
|
||||
* RTCIceCandidate.type String
|
||||
*/
|
||||
localCandidateType: attr(),
|
||||
/**
|
||||
* Name of the session, based on the partner name if set.
|
||||
*/
|
||||
name: attr({
|
||||
compute: '_computeName',
|
||||
}),
|
||||
/**
|
||||
* If set, the partner who owns this rtc session,
|
||||
* there can be multiple rtc sessions per partner if the partner
|
||||
* has open sessions in multiple channels, but only one session per
|
||||
* channel is allowed.
|
||||
*/
|
||||
partner: one('Partner', {
|
||||
inverse: 'rtcSessions',
|
||||
}),
|
||||
/**
|
||||
* Token to identify the session, it is currently just the toString
|
||||
* id of the record.
|
||||
|
||||
@@ -47,14 +47,21 @@ class TestChannelInternals(MailCommon):
|
||||
'id': channel.id,
|
||||
'rtcSessions': [('insert', [{
|
||||
'id': channel_member.rtc_session_ids.id + 1,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member.partner_id.id,
|
||||
"name": channel_member.partner_id.name,
|
||||
"im_status": channel_member.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': self.user_employee.partner_id.id,
|
||||
'name': "Ernest Employee",
|
||||
})],
|
||||
}])],
|
||||
},
|
||||
},
|
||||
@@ -66,14 +73,21 @@ class TestChannelInternals(MailCommon):
|
||||
'rtcSessions': [
|
||||
('insert', [{
|
||||
'id': channel_member.rtc_session_ids.id,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member.partner_id.id,
|
||||
"name": channel_member.partner_id.name,
|
||||
"im_status": channel_member.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': self.user_employee.partner_id.id,
|
||||
'name': "Ernest Employee",
|
||||
})],
|
||||
}]),
|
||||
('insert-and-unlink', [{'id': channel_member.rtc_session_ids.id - 1}]),
|
||||
],
|
||||
@@ -108,14 +122,21 @@ class TestChannelInternals(MailCommon):
|
||||
'id': channel.id,
|
||||
'rtcSessions': [('insert', [{
|
||||
'id': last_rtc_session_id + 1,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member.partner_id.id,
|
||||
"name": channel_member.partner_id.name,
|
||||
"im_status": channel_member.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': self.user_employee.partner_id.id,
|
||||
'name': "Ernest Employee",
|
||||
})],
|
||||
}])],
|
||||
},
|
||||
},
|
||||
@@ -184,14 +205,21 @@ class TestChannelInternals(MailCommon):
|
||||
'id': channel.id,
|
||||
'rtcSessions': [('insert', [{
|
||||
'id': last_rtc_session_id + 1,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member.partner_id.id,
|
||||
"name": channel_member.partner_id.name,
|
||||
"im_status": channel_member.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': self.user_employee.partner_id.id,
|
||||
'name': "Ernest Employee",
|
||||
})],
|
||||
}])],
|
||||
},
|
||||
},
|
||||
@@ -201,14 +229,21 @@ class TestChannelInternals(MailCommon):
|
||||
'id': channel.id,
|
||||
'rtcSessions': [('insert', [{
|
||||
'id': last_rtc_session_id + 1,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member.partner_id.id,
|
||||
"name": channel_member.partner_id.name,
|
||||
"im_status": channel_member.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': self.user_employee.partner_id.id,
|
||||
'name': "Ernest Employee",
|
||||
})],
|
||||
}])],
|
||||
},
|
||||
},
|
||||
@@ -319,14 +354,21 @@ class TestChannelInternals(MailCommon):
|
||||
'rtcSessions': [('insert', [
|
||||
{
|
||||
'id': channel_member.rtc_session_ids.id + 1,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member_test_user.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member_test_user.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member_test_user.partner_id.id,
|
||||
"name": channel_member_test_user.partner_id.name,
|
||||
"im_status": channel_member_test_user.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': test_user.partner_id.id,
|
||||
'name': 'Test User',
|
||||
})],
|
||||
},
|
||||
])],
|
||||
},
|
||||
@@ -374,14 +416,20 @@ class TestChannelInternals(MailCommon):
|
||||
'rtcSessions': [('insert', [
|
||||
{
|
||||
'id': channel_member.rtc_session_ids.id + 2,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member_test_guest.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member_test_guest.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"guest": [("insert-and-replace", {
|
||||
"id": channel_member_test_guest.guest_id.id,
|
||||
"name": channel_member_test_guest.guest_id.name,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'guest': [('insert', {
|
||||
'id': test_guest.id,
|
||||
'name': 'Test Guest',
|
||||
})],
|
||||
},
|
||||
])],
|
||||
},
|
||||
@@ -591,14 +639,21 @@ class TestChannelInternals(MailCommon):
|
||||
'id': channel.id,
|
||||
'rtcInvitingSession': [('insert', {
|
||||
'id': channel_member.rtc_session_ids.id,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member.partner_id.id,
|
||||
"name": channel_member.partner_id.name,
|
||||
"im_status": channel_member.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': self.user_employee.partner_id.id,
|
||||
'name': "Ernest Employee",
|
||||
})],
|
||||
})],
|
||||
},
|
||||
},
|
||||
@@ -608,14 +663,21 @@ class TestChannelInternals(MailCommon):
|
||||
'id': channel.id,
|
||||
'rtcInvitingSession': [('insert', {
|
||||
'id': channel_member.rtc_session_ids.id,
|
||||
'channelMember': [("insert-and-replace", {
|
||||
"id": channel_member.id,
|
||||
"channel": [("insert-and-replace", {"id": channel_member.channel_id.id})],
|
||||
"persona": [("insert-and-replace", {
|
||||
"partner": [("insert-and-replace", {
|
||||
"id": channel_member.partner_id.id,
|
||||
"name": channel_member.partner_id.name,
|
||||
"im_status": channel_member.partner_id.im_status,
|
||||
})],
|
||||
})],
|
||||
})],
|
||||
'isCameraOn': False,
|
||||
'isDeaf': False,
|
||||
'isSelfMuted': False,
|
||||
'isScreenSharingOn': False,
|
||||
'partner': [('insert', {
|
||||
'id': self.user_employee.partner_id.id,
|
||||
'name': "Ernest Employee",
|
||||
})],
|
||||
})],
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user