# HG changeset patch # User Goffi # Date 1652460521 -7200 # Node ID becd7f1aa03394d3b74a40e3b7b36826398ce037 # Parent e0ff2f277e13a438267c9f52fb5da3595efbbfb7 plugin XEP-0277: bridge method `mbIsCommentNode` + methods renaming diff -r e0ff2f277e13 -r becd7f1aa033 sat/plugins/plugin_xep_0277.py --- a/sat/plugins/plugin_xep_0277.py Fri May 13 18:46:51 2022 +0200 +++ b/sat/plugins/plugin_xep_0277.py Fri May 13 18:48:41 2022 +0200 @@ -190,6 +190,13 @@ out_sign="s", method=self._mbGetFromManyWithComments, ) + host.bridge.addMethod( + "mbIsCommentNode", + ".plugin", + in_sign="s", + out_sign="b", + method=self.isCommentNode, + ) def getHandler(self, client): return XEP_0277_handler() @@ -699,16 +706,16 @@ ## publish/preview ## - def isCommentsNode(self, item_id: str) -> bool: + def isCommentNode(self, node: str) -> bool: """Indicate if the node is prefixed with comments namespace""" - return item_id.startswith(NS_COMMENT_PREFIX) + return node.startswith(NS_COMMENT_PREFIX) - def getParentNode(self, item_id: str) -> str: + def getParentItem(self, item_id: str) -> str: """Return parent of a comment node @param item_id: a comment node """ - if not self.isCommentsNode(item_id): + if not self.isCommentNode(item_id): raise ValueError("This node is not a comment node") return item_id[len(NS_COMMENT_PREFIX):]