diff options
| author | David Beguin <dbe@odoo.com> | 2018-12-03 15:26:18 +0000 |
|---|---|---|
| committer | David Beguin <dbe@odoo.com> | 2018-12-05 14:37:10 +0000 |
| commit | 8c8f219b4764173fb1ac924d8a46d9dcdbb85d57 (patch) | |
| tree | bb7a517120e446671ef7676beaa017df42c98e3b /addons/im_livechat/controllers | |
| parent | 9281ae81f90cb58cdeb9b3e09ae2a1f1faca0d2c (diff) | |
[IMP] im_livechat : uses anonymous name only if visitor is anonymous
Before, if the visitor was logged in, anonymous name = user.name.
But if we use anonymous name field even if visitor is not anonymous,
we cannot know, in stat e.g., if the session was really made with
an anonymous visitor or not as the field is always filled in.
Now, if the visitor is not anonymous, we use directly the user.name
but we do not fill in the anonymous name. So that if anonymous name
is null, we know afterwards that the session was made we a real
anonymous visitor.
Since the anonymous name is empty if visitor is logged in,
we cannot use anonymous_name anymore to get the title of the session window.
Task ID : 1895998
Closes PR #28283
Diffstat (limited to 'addons/im_livechat/controllers')
| -rw-r--r-- | addons/im_livechat/controllers/main.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py index 4ba6a731581..904aba2689b 100644 --- a/addons/im_livechat/controllers/main.py +++ b/addons/im_livechat/controllers/main.py @@ -69,13 +69,15 @@ class LivechatController(http.Controller): @http.route('/im_livechat/get_session', type="json", auth='public') def get_session(self, channel_id, anonymous_name, **kwargs): - # if geoip, add the country name to the anonymous name - if request.session.geoip: - anonymous_name = anonymous_name + " ("+request.session.geoip.get('country_name', "")+")" + user_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. if request.session.uid: - anonymous_name = request.env.user.name - return request.env["im_livechat.channel"].with_context(lang=False).get_mail_channel(channel_id, anonymous_name) + user_id = request.env.user.id + # if geoip, add the country name to the anonymous name + elif request.session.geoip: + anonymous_name = anonymous_name + " ("+request.session.geoip.get('country_name', "")+")" + return request.env["im_livechat.channel"].with_context(lang=False).get_mail_channel(channel_id, anonymous_name, user_id) + @http.route('/im_livechat/feedback', type='json', auth='public') def feedback(self, uuid, rate, reason=None, **kwargs): |
