comparison sat/plugins/plugin_xep_0277.py @ 3762:becd7f1aa033

plugin XEP-0277: bridge method `mbIsCommentNode` + methods renaming
author Goffi <goffi@goffi.org>
date Fri, 13 May 2022 18:48:41 +0200
parents e0ff2f277e13
children b2ade5ecdbab
comparison
equal deleted inserted replaced
3761:e0ff2f277e13 3762:becd7f1aa033
187 "mbGetFromManyWithComments", 187 "mbGetFromManyWithComments",
188 ".plugin", 188 ".plugin",
189 in_sign="sasiia{ss}a{ss}s", 189 in_sign="sasiia{ss}a{ss}s",
190 out_sign="s", 190 out_sign="s",
191 method=self._mbGetFromManyWithComments, 191 method=self._mbGetFromManyWithComments,
192 )
193 host.bridge.addMethod(
194 "mbIsCommentNode",
195 ".plugin",
196 in_sign="s",
197 out_sign="b",
198 method=self.isCommentNode,
192 ) 199 )
193 200
194 def getHandler(self, client): 201 def getHandler(self, client):
195 return XEP_0277_handler() 202 return XEP_0277_handler()
196 203
697 704
698 return item_elt 705 return item_elt
699 706
700 ## publish/preview ## 707 ## publish/preview ##
701 708
702 def isCommentsNode(self, item_id: str) -> bool: 709 def isCommentNode(self, node: str) -> bool:
703 """Indicate if the node is prefixed with comments namespace""" 710 """Indicate if the node is prefixed with comments namespace"""
704 return item_id.startswith(NS_COMMENT_PREFIX) 711 return node.startswith(NS_COMMENT_PREFIX)
705 712
706 def getParentNode(self, item_id: str) -> str: 713 def getParentItem(self, item_id: str) -> str:
707 """Return parent of a comment node 714 """Return parent of a comment node
708 715
709 @param item_id: a comment node 716 @param item_id: a comment node
710 """ 717 """
711 if not self.isCommentsNode(item_id): 718 if not self.isCommentNode(item_id):
712 raise ValueError("This node is not a comment node") 719 raise ValueError("This node is not a comment node")
713 return item_id[len(NS_COMMENT_PREFIX):] 720 return item_id[len(NS_COMMENT_PREFIX):]
714 721
715 def getCommentsNode(self, item_id): 722 def getCommentsNode(self, item_id):
716 """Generate comment node 723 """Generate comment node