comparison src/server/server.py @ 586:3eb3a2c0c011

browser and server side: uses RSM (XEP-0059)
author souliane <souliane@mailoo.org>
date Fri, 28 Nov 2014 00:31:27 +0100
parents 8a607044ecfa
children a90cc8fc9605
comparison
equal deleted inserted replaced
585:bade589dbd5a 586:3eb3a2c0c011
299 if node and text: 299 if node and text:
300 return self.sat_host.bridge.sendGroupBlogComment(node, text, extra, profile) 300 return self.sat_host.bridge.sendGroupBlogComment(node, text, extra, profile)
301 else: 301 else:
302 raise Exception("Invalid data") 302 raise Exception("Invalid data")
303 303
304 def jsonrpc_getMblogs(self, publisher_jid, item_ids): 304 def jsonrpc_getMblogs(self, publisher_jid, item_ids, max_items=C.RSM_MAX_ITEMS):
305 """Get specified microblogs posted by a contact 305 """Get specified microblogs posted by a contact
306 @param publisher_jid: jid of the publisher 306 @param publisher_jid: jid of the publisher
307 @param item_ids: list of microblogs items IDs 307 @param item_ids: list of microblogs items IDs
308 @return list of microblog data (dict)""" 308 @return list of microblog data (dict)"""
309 profile = ISATSession(self.session).profile 309 profile = ISATSession(self.session).profile
310 d = self.asyncBridgeCall("getGroupBlogs", publisher_jid, item_ids, profile) 310 d = self.asyncBridgeCall("getGroupBlogs", publisher_jid, item_ids, {'max': unicode(max_items)}, False, profile)
311 return d 311 return d
312 312
313 def jsonrpc_getMblogsWithComments(self, publisher_jid, item_ids): 313 def jsonrpc_getMblogsWithComments(self, publisher_jid, item_ids, max_comments=C.RSM_MAX_COMMENTS):
314 """Get specified microblogs posted by a contact and their comments 314 """Get specified microblogs posted by a contact and their comments
315 @param publisher_jid: jid of the publisher 315 @param publisher_jid: jid of the publisher
316 @param item_ids: list of microblogs items IDs 316 @param item_ids: list of microblogs items IDs
317 @return list of couple (microblog data, list of microblog data)""" 317 @return list of couple (microblog data, list of microblog data)"""
318 profile = ISATSession(self.session).profile 318 profile = ISATSession(self.session).profile
319 d = self.asyncBridgeCall("getGroupBlogsWithComments", publisher_jid, item_ids, profile) 319 d = self.asyncBridgeCall("getGroupBlogsWithComments", publisher_jid, item_ids, {}, max_comments, profile)
320 return d 320 return d
321 321
322 def jsonrpc_getLastMblogs(self, publisher_jid, max_item): 322 def jsonrpc_getMassiveMblogs(self, publishers_type, publishers_list, rsm=None):
323 """Get last microblogs posted by a contact
324 @param publisher_jid: jid of the publisher
325 @param max_item: number of items to ask
326 @return list of microblog data (dict)"""
327 profile = ISATSession(self.session).profile
328 d = self.asyncBridgeCall("getLastGroupBlogs", publisher_jid, max_item, profile)
329 return d
330
331 def jsonrpc_getMassiveLastMblogs(self, publishers_type, publishers_list, max_item):
332 """Get lasts microblogs posted by several contacts at once 323 """Get lasts microblogs posted by several contacts at once
333 @param publishers_type: one of "ALL", "GROUP", "JID" 324 @param publishers_type: one of "ALL", "GROUP", "JID"
334 @param publishers_list: list of publishers type (empty list of all, list of groups or list of jids) 325 @param publishers_list: list of publishers type (empty list of all, list of groups or list of jids)
335 @param max_item: number of items to ask 326 @param max_item: number of items to ask
336 @return: dictionary key=publisher's jid, value=list of microblog data (dict)""" 327 @return: dictionary key=publisher's jid, value=list of microblog data (dict)"""
337 profile = ISATSession(self.session).profile 328 profile = ISATSession(self.session).profile
338 d = self.asyncBridgeCall("getMassiveLastGroupBlogs", publishers_type, publishers_list, max_item, profile) 329 if rsm is None:
330 rsm = {'max': unicode(C.RSM_MAX_ITEMS)}
331 d = self.asyncBridgeCall("getMassiveGroupBlogs", publishers_type, publishers_list, rsm, profile)
339 self.sat_host.bridge.massiveSubscribeGroupBlogs(publishers_type, publishers_list, profile) 332 self.sat_host.bridge.massiveSubscribeGroupBlogs(publishers_type, publishers_list, profile)
340 return d 333 return d
341 334
342 def jsonrpc_getMblogComments(self, service, node): 335 def jsonrpc_getMblogComments(self, service, node, rsm=None):
343 """Get all comments of given node 336 """Get all comments of given node
344 @param service: jid of the service hosting the node 337 @param service: jid of the service hosting the node
345 @param node: comments node 338 @param node: comments node
346 """ 339 """
347 profile = ISATSession(self.session).profile 340 profile = ISATSession(self.session).profile
348 d = self.asyncBridgeCall("getGroupBlogComments", service, node, profile) 341 if rsm is None:
342 rsm = {'max': unicode(C.RSM_MAX_COMMENTS)}
343 d = self.asyncBridgeCall("getGroupBlogComments", service, node, rsm, profile)
349 return d 344 return d
350 345
351 def jsonrpc_getPresenceStatuses(self): 346 def jsonrpc_getPresenceStatuses(self):
352 """Get Presence information for connected contacts""" 347 """Get Presence information for connected contacts"""
353 profile = ISATSession(self.session).profile 348 profile = ISATSession(self.session).profile