[FIX] mail: notify guest when joining the channel
Before this PR, the guest that just connect wouldn't receive the longpolling message before the current one expire. task-2664831 closes odoo/odoo#82170 X-original-commit: 0006123dba46d32d062a581e9a16f433f3ce05f3 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -360,6 +360,11 @@ class Channel(models.Model):
|
||||
'id': channel_partner.guest_id.id,
|
||||
'name': channel_partner.guest_id.name,
|
||||
})
|
||||
guest = channel_partner.guest_id
|
||||
if guest:
|
||||
self.env['bus.bus']._sendone(guest, 'mail.channel/joined', {
|
||||
'channel': channel_partner.channel_id.sudo().channel_info()[0],
|
||||
})
|
||||
self.env['bus.bus']._sendone(channel, 'mail.channel/insert', {
|
||||
'id': channel.id,
|
||||
'guestMembers': [('insert', guest_members_data)],
|
||||
|
||||
+2
-2
@@ -182,11 +182,11 @@ registerModel({
|
||||
* @private
|
||||
* @param {Object} payload
|
||||
* @param {Thread} payload.channel
|
||||
* @param {integer} payload.invited_by_user_id
|
||||
* @param {integer} [payload.invited_by_user_id]
|
||||
*/
|
||||
_handleNotificationChannelJoined({ channel: channelData, invited_by_user_id: invitedByUserId }) {
|
||||
const channel = this.messaging.models['Thread'].insert(this.messaging.models['Thread'].convertData(channelData));
|
||||
if (invitedByUserId !== this.messaging.currentUser.id) {
|
||||
if (this.messaging.currentUser && invitedByUserId !== this.messaging.currentUser.id) {
|
||||
// Current user was invited by someone else.
|
||||
this.env.services['notification'].notify({
|
||||
message: _.str.sprintf(
|
||||
|
||||
@@ -451,6 +451,7 @@ class TestChannelInternals(MailCommon):
|
||||
(self.cr.dbname, 'res.partner', self.user_employee.partner_id.id), # update of last interest (not asserted below)
|
||||
(self.cr.dbname, 'res.partner', test_user.partner_id.id), # update of last interest (not asserted below)
|
||||
(self.cr.dbname, 'mail.channel', channel.id), # new member (guest) (not asserted below)
|
||||
(self.cr.dbname, 'mail.guest', test_guest.id), # channel joined for guest (not asserted below)
|
||||
],
|
||||
[
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user