Files
odoo_source/addons/im_support/models/ir_http.py
T
Aaron BohyandAdrien Dieudonne 2aeb763768 [ADD] im_support
This rev. adds a new module enabling the livechat support from
the webclient. It allows employee users to communicate with
livechat operators of another database, assuming that a counterpart
addon is installed on that database.

Task 26762

Co-authored-by: Adrien Dieudonne <adr@odoo.com>
2018-05-28 07:30:12 +02:00

28 lines
914 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import hmac
from hashlib import sha256
from odoo import models
from odoo.http import request
class Http(models.AbstractModel):
_inherit = 'ir.http'
def session_info(self):
result = super(Http, self).session_info()
if self.env.user.has_group('base.group_user'):
icp = request.env['ir.config_parameter'].sudo()
db_uuid = icp.get_param('database.uuid')
db_secret = icp.get_param('database.secret')
message = db_uuid + str(request.uid)
token = hmac.new(message.encode('utf-8'), db_secret.encode('utf-8'), sha256).hexdigest()
result['db_uuid'] = db_uuid
result['support_token'] = token
result['support_origin'] = False # must be overridden to specify the correct origin
return result