Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0277.py @ 3763:b2ade5ecdbab
plugin XEP-0277: be sure to have `service` set in `item2mbdata` and `node` when provided
rel 365
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 13 May 2022 18:50:33 +0200 |
parents | becd7f1aa033 |
children | 5b192a5eb72d |
comparison
equal
deleted
inserted
replaced
3762:becd7f1aa033 | 3763:b2ade5ecdbab |
---|---|
267 profile's PEP is used when service is None | 267 profile's PEP is used when service is None |
268 @param node: PubSub node where the item has been retrieved | 268 @param node: PubSub node where the item has been retrieved |
269 if None, "uri" won't be set | 269 if None, "uri" won't be set |
270 @return: microblog data | 270 @return: microblog data |
271 """ | 271 """ |
272 microblog_data = {} | 272 if service is None: |
273 service = client.jid.userhostJID() | |
274 | |
275 microblog_data = {"service": service.full()} | |
273 | 276 |
274 def check_conflict(key, increment=False): | 277 def check_conflict(key, increment=False): |
275 """Check if key is already in microblog data | 278 """Check if key is already in microblog data |
276 | 279 |
277 @param key(unicode): key to check | 280 @param key(unicode): key to check |
341 raise failure.Failure(exceptions.DataError(msg)) | 344 raise failure.Failure(exceptions.DataError(msg)) |
342 | 345 |
343 # uri | 346 # uri |
344 # FIXME: node should alway be set in the future, check FIXME in method signature | 347 # FIXME: node should alway be set in the future, check FIXME in method signature |
345 if node is not None: | 348 if node is not None: |
349 microblog_data["node"] = node | |
346 microblog_data['uri'] = xmpp_uri.buildXMPPUri( | 350 microblog_data['uri'] = xmpp_uri.buildXMPPUri( |
347 "pubsub", | 351 "pubsub", |
348 path=service.full() if service is not None else client.jid.userhost(), | 352 path=service.full(), |
349 node=node, | 353 node=node, |
350 item=id_, | 354 item=id_, |
351 ) | 355 ) |
352 | 356 |
353 # language | 357 # language |
443 uri = link_elt["href"] | 447 uri = link_elt["href"] |
444 comments_data = { | 448 comments_data = { |
445 "uri": uri, | 449 "uri": uri, |
446 } | 450 } |
447 try: | 451 try: |
448 service, node = self.parseCommentUrl(uri) | 452 comment_service, comment_node = self.parseCommentUrl(uri) |
449 except Exception as e: | 453 except Exception as e: |
450 log.warning(f"Can't parse comments url: {e}") | 454 log.warning(f"Can't parse comments url: {e}") |
451 continue | 455 continue |
452 else: | 456 else: |
453 comments_data["service"] = service.full() | 457 comments_data["service"] = comment_service.full() |
454 comments_data["node"] = node | 458 comments_data["node"] = comment_node |
455 comments.append(comments_data) | 459 comments.append(comments_data) |
456 else: | 460 else: |
457 rel = link_elt.getAttribute("rel", "") | 461 rel = link_elt.getAttribute("rel", "") |
458 title = link_elt.getAttribute("title", "") | 462 title = link_elt.getAttribute("title", "") |
459 href = link_elt.getAttribute("href", "") | 463 href = link_elt.getAttribute("href", "") |