Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0277.py @ 855:03addfe98b64
plugin XEP-0277: last commit was actually a part of the next one
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 23 Feb 2014 23:59:02 +0100 |
parents | 762b191e1e1e |
children | 660b3f5b6c78 |
comparison
equal
deleted
inserted
replaced
854:762b191e1e1e | 855:03addfe98b64 |
---|---|
69 method=self.setMicroblogAccess, | 69 method=self.setMicroblogAccess, |
70 async=True, | 70 async=True, |
71 doc={}) | 71 doc={}) |
72 | 72 |
73 def parseCommentUrl(self, node_url): | 73 def parseCommentUrl(self, node_url): |
74 """Determine the fields comments_service and comments_node of a microblog data | |
75 from the href attribute of an entry's link element. For example this input: | |
76 xmpp:sat-pubsub.libervia.org?node=urn%3Axmpp%3Acomments%3A_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn%3Axmpp%3Agroupblog%3Asouliane%libervia.org | |
77 will return (JID(u'sat-pubsub.libervia.org'), 'urn:xmpp:comments:_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:souliane%libervia.org') | |
78 @return: a tuple (JID, str) | |
79 """ | |
80 parsed_url = urlparse.urlparse(node_url, 'xmpp') | 74 parsed_url = urlparse.urlparse(node_url, 'xmpp') |
81 service = jid.JID(parsed_url.path) | 75 service = jid.JID(parsed_url.path) |
82 queries = parsed_url.query.split(';') | 76 queries = parsed_url.query.split(';') |
83 parsed_queries = dict() | 77 parsed_queries = dict() |
84 for query in queries: | 78 for query in queries: |
158 service, node = self.parseCommentUrl(microblog_data["comments"]) | 152 service, node = self.parseCommentUrl(microblog_data["comments"]) |
159 microblog_data['comments_service'] = service.full() | 153 microblog_data['comments_service'] = service.full() |
160 microblog_data['comments_node'] = node | 154 microblog_data['comments_node'] = node |
161 break | 155 break |
162 except (KeyError, exceptions.DataError, RuntimeError): | 156 except (KeyError, exceptions.DataError, RuntimeError): |
163 warning(_("Can't parse the link element of pubsub entry %s") % item['id']) | 157 warning("Can't parse link") |
164 continue | 158 continue |
165 except (AttributeError, KeyError): | 159 except (AttributeError, KeyError): |
166 error(_('Error while parsing atom entry for microblogging event')) | 160 error(_('Error while parsing atom entry for microblogging event')) |
167 raise exceptions.DataError | 161 raise exceptions.DataError |
168 | 162 |