Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0277.py @ 3661:cbb988a6f507
merge bookmark `@`
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Sep 2021 11:20:37 +0200 |
parents | d390ff50af0f 30196b9a2b4c |
children | 68f2a9c171d1 |
comparison
equal
deleted
inserted
replaced
3639:05db744f194f | 3661:cbb988a6f507 |
---|---|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 import time | 19 import time |
20 import dateutil | 20 import dateutil |
21 import calendar | 21 import calendar |
22 import urllib.parse | |
23 from secrets import token_urlsafe | 22 from secrets import token_urlsafe |
24 from typing import Optional | 23 from typing import Optional |
25 from functools import partial | 24 from functools import partial |
26 | 25 |
27 import shortuuid | 26 import shortuuid |
1030 from the href attribute of an entry's link element. For example this input: | 1029 from the href attribute of an entry's link element. For example this input: |
1031 xmpp:sat-pubsub.example.net?;node=urn%3Axmpp%3Acomments%3A_af43b363-3259-4b2a-ba4c-1bc33aa87634__urn%3Axmpp%3Agroupblog%3Asomebody%40example.net | 1030 xmpp:sat-pubsub.example.net?;node=urn%3Axmpp%3Acomments%3A_af43b363-3259-4b2a-ba4c-1bc33aa87634__urn%3Axmpp%3Agroupblog%3Asomebody%40example.net |
1032 will return(JID(u'sat-pubsub.example.net'), 'urn:xmpp:comments:_af43b363-3259-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:somebody@example.net') | 1031 will return(JID(u'sat-pubsub.example.net'), 'urn:xmpp:comments:_af43b363-3259-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:somebody@example.net') |
1033 @return (tuple[jid.JID, unicode]): service and node | 1032 @return (tuple[jid.JID, unicode]): service and node |
1034 """ | 1033 """ |
1035 parsed_url = urllib.parse.urlparse(node_url, "xmpp") | 1034 try: |
1036 service = jid.JID(parsed_url.path) | 1035 parsed_url = xmpp_uri.parseXMPPUri(node_url) |
1037 parsed_queries = urllib.parse.parse_qs(parsed_url.query) | 1036 service = jid.JID(parsed_url["path"]) |
1038 node = parsed_queries.get("node", [""])[0] | 1037 node = parsed_url["node"] |
1039 | 1038 except Exception as e: |
1040 if not node: | 1039 raise exceptions.DataError(f"Invalid comments link: {e}") |
1041 raise exceptions.DataError("Invalid comments link") | |
1042 | 1040 |
1043 return (service, node) | 1041 return (service, node) |
1044 | 1042 |
1045 ## configure ## | 1043 ## configure ## |
1046 | 1044 |