diff --git a/addons/bus/controllers/websocket.py b/addons/bus/controllers/websocket.py index f0121df7864..63048c088d5 100644 --- a/addons/bus/controllers/websocket.py +++ b/addons/bus/controllers/websocket.py @@ -42,9 +42,10 @@ class WebsocketController(Controller): notifications = request.env['bus.bus']._poll(channels, last) return {'channels': channels, 'notifications': notifications} - @route('/websocket/update_bus_presence', type='http', auth='public', cors='*') + @route('/websocket/update_bus_presence', type='json', auth='public', cors='*') def update_bus_presence(self, inactivity_period, im_status_ids_by_model): request.env['ir.websocket']._update_bus_presence(int(inactivity_period), im_status_ids_by_model) + return {} @route('/bus/websocket_worker_bundle', type='http', auth='public', cors='*') def get_websocket_worker_bundle(self): diff --git a/addons/bus/models/ir_websocket.py b/addons/bus/models/ir_websocket.py index 567abe1cd98..8f663d16b90 100644 --- a/addons/bus/models/ir_websocket.py +++ b/addons/bus/models/ir_websocket.py @@ -34,7 +34,7 @@ class IrWebsocket(models.AbstractModel): dispatch.subscribe(channels, data['last'], self.env.registry.db_name, wsrequest.ws) def _update_bus_presence(self, inactivity_period, im_status_ids_by_model): - if self.env.uid: + if self.env.user and not self.env.user._is_public(): self.env['bus.presence'].update( inactivity_period, identity_field='user_id', diff --git a/addons/mail/models/ir_websocket.py b/addons/mail/models/ir_websocket.py index 1461e3c55ac..733c756b44d 100644 --- a/addons/mail/models/ir_websocket.py +++ b/addons/mail/models/ir_websocket.py @@ -34,7 +34,7 @@ class IrWebsocket(models.AbstractModel): def _update_bus_presence(self, inactivity_period, im_status_ids_by_model): super()._update_bus_presence(inactivity_period, im_status_ids_by_model) - if not self.env.uid: + if not self.env.user or self.env.user._is_public(): # This method can either be called due to an http or a # websocket request. The request itself is necessary to # retrieve the current guest. Let's retrieve the proper