[FIX] bus: fix websocket json routes
Transform the /websocket/update_bus_presence route to type='json' which makes more sense as a POST than a get, seeing it does things with a parameter and doesn't return anything. Also fixes the _update_bus_presence method that leads to access errors when accessed from HTTP when the user is the public one (only portal/ internal users should update their presences). Part-of: odoo/odoo#100416
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user