summaryrefslogtreecommitdiff
path: root/addons/im_livechat/controllers
diff options
context:
space:
mode:
authorAurélien Warnon <awa@odoo.com>2019-01-09 13:26:25 +0000
committerjem-odoo <jem@openerp.com>2019-04-01 07:03:11 +0000
commit594c6e8a2a78d4592db62345194ca9b7e1575272 (patch)
tree017d29266b5656e4221f3d19aeef4b75129ff34e /addons/im_livechat/controllers
parent9b867cd12dbc8cca5da1e3d6426b5cadf8a0ec33 (diff)
[IMP] im_livechat: ensure that visitors always gets the same operator
Task #1919871 Purpose ======= If a visitor comes on the website and launches a livechat, it will be randomly assigned operator A. If he comes the next day and opens a livechat again, we want him to have the same operator if he's available. To handle that use case, we added a cookie that stores the "previous operator id" information for 7 days.
Diffstat (limited to 'addons/im_livechat/controllers')
-rw-r--r--addons/im_livechat/controllers/main.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py
index d87cf2329cb..5703563e95d 100644
--- a/addons/im_livechat/controllers/main.py
+++ b/addons/im_livechat/controllers/main.py
@@ -80,7 +80,7 @@ class LivechatController(http.Controller):
}
@http.route('/im_livechat/get_session', type="json", auth='public', cors="*")
- def get_session(self, channel_id, anonymous_name, **kwargs):
+ def get_session(self, channel_id, anonymous_name, previous_operator_id=None, **kwargs):
user_id = None
country_id = None
# if the user is identifiy (eg: portal user on the frontend), don't use the anonymous name. The user will be added to session.
@@ -94,7 +94,11 @@ class LivechatController(http.Controller):
country = request.env['res.country'].sudo().search([('code', '=', country_code)], limit=1) if country_code else None
if country:
anonymous_name, country_id = _("%s (%s)") % (anonymous_name, country.name), country.id
- return request.env["im_livechat.channel"].with_context(lang=False).sudo().browse(channel_id)._get_mail_channel(anonymous_name, user_id, country_id)
+
+ if previous_operator_id:
+ previous_operator_id = int(previous_operator_id)
+
+ return request.env["im_livechat.channel"].with_context(lang=False).sudo().browse(channel_id)._get_mail_channel(anonymous_name, previous_operator_id, user_id, country_id)
@http.route('/im_livechat/feedback', type='json', auth='public', cors="*")
def feedback(self, uuid, rate, reason=None, **kwargs):