Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0277.py @ 1268:bb30bf3ae932
plugins XEP-0060, XEP-0277, groupblog: make use of RSM (XEP-0059)
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 15 Dec 2014 14:04:19 +0100 |
parents | 0b87d029f0a3 |
children | 54a898821740 |
comparison
equal
deleted
inserted
replaced
1267:ea692d51a0ee | 1268:bb30bf3ae932 |
---|---|
42 "name": "Microblogging over XMPP Plugin", | 42 "name": "Microblogging over XMPP Plugin", |
43 "import_name": "XEP-0277", | 43 "import_name": "XEP-0277", |
44 "type": "XEP", | 44 "type": "XEP", |
45 "protocols": [], | 45 "protocols": [], |
46 "dependencies": ["XEP-0163", "XEP-0060", "TEXT-SYNTAXES"], | 46 "dependencies": ["XEP-0163", "XEP-0060", "TEXT-SYNTAXES"], |
47 "recommendations": ["XEP-0059"], | |
47 "main": "XEP_0277", | 48 "main": "XEP_0277", |
48 "handler": "no", | 49 "handler": "no", |
49 "description": _("""Implementation of microblogging Protocol""") | 50 "description": _("""Implementation of microblogging Protocol""") |
50 } | 51 } |
51 | 52 |
75 doc={}) | 76 doc={}) |
76 | 77 |
77 def parseCommentUrl(self, node_url): | 78 def parseCommentUrl(self, node_url): |
78 """Determine the fields comments_service and comments_node of a microblog data | 79 """Determine the fields comments_service and comments_node of a microblog data |
79 from the href attribute of an entry's link element. For example this input: | 80 from the href attribute of an entry's link element. For example this input: |
80 xmpp:sat-pubsub.libervia.org?node=urn%3Axmpp%3Acomments%3A_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn%3Axmpp%3Agroupblog%3Asouliane%libervia.org | 81 xmpp:sat-pubsub.libervia.org?node=urn%3Axmpp%3Acomments%3A_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn%3Axmpp%3Agroupblog%3Asouliane%40libervia.org |
81 will return (JID(u'sat-pubsub.libervia.org'), 'urn:xmpp:comments:_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:souliane%libervia.org') | 82 will return (JID(u'sat-pubsub.libervia.org'), 'urn:xmpp:comments:_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:souliane@libervia.org') |
82 @return: a tuple (JID, str) | 83 @return: a tuple (JID, str) |
83 """ | 84 """ |
84 parsed_url = urlparse.urlparse(node_url, 'xmpp') | 85 parsed_url = urlparse.urlparse(node_url, 'xmpp') |
85 service = jid.JID(parsed_url.path) | 86 service = jid.JID(parsed_url.path) |
86 queries = parsed_url.query.split(';') | 87 queries = parsed_url.query.split(';') |
313 def getLastMicroblogs(self, pub_jid, max_items=10, profile_key=C.PROF_KEY_NONE): | 314 def getLastMicroblogs(self, pub_jid, max_items=10, profile_key=C.PROF_KEY_NONE): |
314 """Get the last published microblogs | 315 """Get the last published microblogs |
315 @param pub_jid: jid of the publisher | 316 @param pub_jid: jid of the publisher |
316 @param max_items: how many microblogs we want to get | 317 @param max_items: how many microblogs we want to get |
317 @param profile_key: profile key | 318 @param profile_key: profile key |
319 | |
320 @return: a deferred couple with the list of items and RSM information. | |
318 """ | 321 """ |
319 d = self.host.plugins["XEP-0060"].getItems(jid.JID(pub_jid), NS_MICROBLOG, max_items=max_items, profile_key=profile_key) | 322 d = self.host.plugins["XEP-0060"].getItems(jid.JID(pub_jid), NS_MICROBLOG, max_items=max_items, profile_key=profile_key) |
320 d.addCallback(lambda items: defer.DeferredList(map(self.item2mbdata, items), consumeErrors=True)) | 323 d.addCallback(lambda res: (defer.DeferredList(map(self.item2mbdata, res[0]), consumeErrors=True), res[1])) |
321 d.addCallback(lambda result: [value for (success, value) in result if success]) | 324 d.addCallback(lambda res: ([value for (success, value) in res[0] if success], res[1])) |
322 return d | 325 return d |
323 | 326 |
324 def setMicroblogAccess(self, access="presence", profile_key=C.PROF_KEY_NONE): | 327 def setMicroblogAccess(self, access="presence", profile_key=C.PROF_KEY_NONE): |
325 """Create a microblog node on PEP with given access | 328 """Create a microblog node on PEP with given access |
326 If the node already exists, it change options | 329 If the node already exists, it change options |