changeset 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
files sat/plugins/plugin_xep_0277.py
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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):]