From 17ae4f6e29c87d052e8e327577eb77032896d63a Mon Sep 17 00:00:00 2001 From: rolandojduartem Date: Fri, 13 Sep 2024 01:04:24 +0000 Subject: [PATCH] [FIX] auth_session_timeout: add /longpolling/im_status as ignored url auth_session_timeout [1] uses the time of the modification of the session file to calculate the time of inactivity, but any edition in the session file will change the time of modification of the file and cause inexact time of inactivity. The controller /longpolling/im_status is called several times (every 50 seconds) [2][3], so it is required taking it into account to avoid modifying the time of modification of the session file, so it is required adding /longpolling/im_status as a ignored url [4][5]. References: - [1] https://github.com/Oca/server-auth/blob/1db10f29/auth_session_timeout/models/res_users.py#L73 - [2] https://github.com/odoo/odoo/blob/e5b67f9c/addons/mail/static/src/models/partner/partner.js#L395 - [3] https://github.com/odoo/odoo/blob/e5b67f9c/addons/mail/static/src/models/partner/partner.js#L407 - [4] https://github.com/Oca/server-auth/blob/1db10f29/auth_session_timeout/data/ir_config_parameter_data.xml#L12 - [5] https://github.com/Oca/server-auth/blob/1db10f29/auth_session_timeout/models/res_users.py#L93 --- auth_session_timeout/__manifest__.py | 2 +- .../data/ir_config_parameter_data.xml | 4 ++- .../migrations/15.0.1.0.1/post-migration.py | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 auth_session_timeout/migrations/15.0.1.0.1/post-migration.py diff --git a/auth_session_timeout/__manifest__.py b/auth_session_timeout/__manifest__.py index e155747d1a..c9a28afbbf 100644 --- a/auth_session_timeout/__manifest__.py +++ b/auth_session_timeout/__manifest__.py @@ -13,7 +13,7 @@ "maintainer": "Odoo Community Association (OCA)", "website": "https://github.com/OCA/server-auth", "category": "Tools", - "version": "15.0.1.0.0", + "version": "15.0.1.0.1", "license": "AGPL-3", "data": ["data/ir_config_parameter_data.xml"], "installable": True, diff --git a/auth_session_timeout/data/ir_config_parameter_data.xml b/auth_session_timeout/data/ir_config_parameter_data.xml index b64c5a8c61..c7dfd81922 100644 --- a/auth_session_timeout/data/ir_config_parameter_data.xml +++ b/auth_session_timeout/data/ir_config_parameter_data.xml @@ -9,6 +9,8 @@ inactive_session_time_out_ignored_url - /calendar/notify,/longpolling/poll + /calendar/notify,/longpolling/poll,/longpolling/im_status diff --git a/auth_session_timeout/migrations/15.0.1.0.1/post-migration.py b/auth_session_timeout/migrations/15.0.1.0.1/post-migration.py new file mode 100644 index 0000000000..b565213e15 --- /dev/null +++ b/auth_session_timeout/migrations/15.0.1.0.1/post-migration.py @@ -0,0 +1,28 @@ +import logging + +from odoo import SUPERUSER_ID, api + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + add_controller_to_parameter(cr) + + +def add_controller_to_parameter(cr): + """Add /longpolling/im_status because it is executed several times (every 50 seconds)""" + env = api.Environment(cr, SUPERUSER_ID, {}) + new_url = "/longpolling/im_status" + ignored_path_key = "inactive_session_time_out_ignored_url" + param = env["ir.config_parameter"] + old_value = param.get_param(ignored_path_key, "") + if new_url in old_value: + _logger.info( + "%s is included in the parameter %s already.", new_url, ignored_path_key + ) + return + new_value = "%s,%s" % (old_value, new_url) + param.set_param(ignored_path_key, new_value) + _logger.info( + "%s was added to the parameter %s successfully.", new_url, ignored_path_key + )