# HG changeset patch # User Goffi # Date 1448284765 -3600 # Node ID 25984ca4aef20b609a23b8af94f8d3b9701987d7 # Parent ad733b670cc3398f38564e1e87b74d8befa0d7b1 server side: special handling of Connection/JabberID and Connection/autoconnect parameter which has needed by QuickApp but restricted by security limit diff -r ad733b670cc3 -r 25984ca4aef2 src/server/blog.py --- a/src/server/blog.py Mon Nov 23 12:59:28 2015 +0100 +++ b/src/server/blog.py Mon Nov 23 14:19:25 2015 +0100 @@ -91,12 +91,12 @@ if key != "avatar": return log.debug(_(u"Received a new avatar for entity %s") % entity_s) - + url = os.path.join(C.AVATARS_DIR, value) self.avatars_cache[entity_s] = url self.waiting_deferreds[entity_s].callback(url) del self.waiting_deferreds[entity_s] - + def getAvatarURL(self, pub_jid): """Return avatar of a jid if in cache, else ask for it. @@ -128,7 +128,7 @@ return self.useTemplate(request, "static_blog_error", {'message': "Invalid nickname"}) d = defer.Deferred() - JID(self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', C.SERVER_SECURITY_LIMIT, prof_found, callback=d.callback, errback=d.errback)) + JID(self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', profile_key=prof_found, callback=d.callback, errback=d.errback)) d.addCallbacks(lambda pub_jid_s: self.gotJID(pub_jid_s, request, prof_found)) return server.NOT_DONE_YET @@ -154,7 +154,7 @@ else: self.getItems(pub_jid, max_items, request.extra_dict, request.extra_comments_dict, request, profile) - + def parseURLParams(self, request): """Parse the request URL parameters. @@ -202,7 +202,7 @@ def parseURLParamsCommentsRSM(self, request): """Parse RSM request data from the URL parameters for comments - + @param request: HTTP request """ request.extra_comments_dict = {} @@ -216,7 +216,7 @@ def getItemById(self, pub_jid, item_id, extra_dict, extra_comments_dict, request, profile): """ - + @param pub_jid (jid.JID): publisher JID @param item_id(unicode): ID of the item to retrieve @param extra_dict (dict): extra configuration for initial items only @@ -235,7 +235,7 @@ index_key = "rsm_index" if metadata_bis.get("rsm_index") else "rsm_count" metadata['rsm_index'] = unicode(int(metadata_bis[index_key]) - 1) metadata['rsm_first'] = metadata['rsm_last'] = item["id"] - + def gotComments(comments): # build the items as self.getItems would do it (and as self.render_html_blog expects them to be) comments = [(item['comments_service'], item['comments_node'], "", comments[0], comments[1])] @@ -257,7 +257,7 @@ def getItems(self, pub_jid, max_items, extra_dict, extra_comments_dict, request, profile): """ - + @param pub_jid (jid.JID): publisher JID @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit @param extra_dict (dict): extra configuration for initial items only @@ -271,10 +271,10 @@ service, node, failure, items, metadata = result if not failure: self.render_html_blog(items, metadata, request, pub_jid, profile) - + if remaining: self._getResults(rt_session) - + def getResult(rt_session): self.host.bridge.mbGetFromManyWithCommentsRTResult(rt_session, C.SERVICE_PROFILE, callback=lambda data: getResultCb(data, rt_session), @@ -284,7 +284,7 @@ self.host.bridge.mbGetFromManyWithComments(C.JID, [pub_jid.userhost()], max_items, max_comments, extra_dict, extra_comments_dict, C.SERVICE_PROFILE, callback=getResult) - + def render_html_blog(self, items, metadata, request, pub_jid, profile): """Retrieve the user parameters before actually rendering the static blog @@ -314,7 +314,7 @@ def __render_html_blog(self, items, metadata, options, request, pub_jid): """Actually render the static blog. - + If mblog_data is a list of dict, we are missing the comments items so we just display the main items. If mblog_data is a list of couple, each couple is associating a main item data with the list of its comments, so we render all. @@ -454,7 +454,7 @@ @param comments_count (int): total number of comments """ timestamp = float(entry.get('published', 0)) - + # FIXME: for now we assume that the comments' depth is only 1 is_comment = not entry.get('comments', False) diff -r ad733b670cc3 -r 25984ca4aef2 src/server/server.py --- a/src/server/server.py Mon Nov 23 12:59:28 2015 +0100 +++ b/src/server/server.py Mon Nov 23 14:19:25 2015 +0100 @@ -630,6 +630,12 @@ def jsonrpc_asyncGetParamA(self, param, category, attribute="value"): """Return the parameter value for profile""" profile = ISATSession(self.session).profile + if category == "Connection": + # we need to manage the followings params here, else SECURITY_LIMIT would block them + if param == "JabberID": + return self.asyncBridgeCall("asyncGetParamA", param, category, attribute, profile_key=profile) + elif param == "autoconnect": + return defer.succeed(C.BOOL_TRUE) d = self.asyncBridgeCall("asyncGetParamA", param, category, attribute, C.SECURITY_LIMIT, profile_key=profile) return d