[FIX] im_livechat,web: partial revert of 7f8fe10766

Proxy.load is required by the livechat when it is embedded in an
external page, so that it is able to get the static xml files
(with the correct base_url).

opw-706497
This commit is contained in:
Aaron Bohy
2017-01-31 10:52:08 +01:00
parent 3c1f9ff156
commit f4bb9bc976
2 changed files with 24 additions and 9 deletions
@@ -82,16 +82,15 @@ var LivechatButton = Widget.extend({
},
load_qweb_template: function(){
return $.when(
$.get('/mail/static/src/xml/chat_window.xml'),
$.get('/mail/static/src/xml/thread.xml'),
$.get('/im_livechat/static/src/xml/im_livechat.xml')
).then(function (chat_window, mail_thread, livechat) {
// results are triplets of [dom: XMLDocument, status: String, xhr: jqXHR]
QWeb.add_template(chat_window[0]);
QWeb.add_template(mail_thread[0]);
QWeb.add_template(livechat[0]);
var xml_files = ['/mail/static/src/xml/chat_window.xml',
'/mail/static/src/xml/thread.xml',
'/im_livechat/static/src/xml/im_livechat.xml'];
var defs = _.map(xml_files, function (tmpl) {
return session.rpc('/web/proxy/load', {path: tmpl}).then(function (xml) {
QWeb.add_template(xml);
});
});
return $.when.apply($, defs);
},
open_chat: _.debounce(function () {
+16
View File
@@ -586,6 +586,22 @@ class WebClient(http.Controller):
class Proxy(http.Controller):
@http.route('/web/proxy/load', type='json', auth="none")
def load(self, path):
""" Proxies an HTTP request through a JSON request.
It is strongly recommended to not request binary files through this,
as the result will be a binary data blob as well.
:param path: actual request path
:return: file content
"""
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse
base_url = request.httprequest.base_url
return Client(request.httprequest.app, BaseResponse).get(path, base_url=base_url).data
@http.route('/web/proxy/post/<path:path>', type='http', auth='user', methods=['GET'])
def post(self, path):
"""Effectively execute a POST request that was hooked through user login"""