From 6ad80151f972fe45ee69f1c2300cbed7c9d2d760 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 20 Aug 2017 17:37:43 +0200 Subject: [PATCH] plugin XEP-0277: added microblog namespace to disco info --- src/plugins/plugin_xep_0277.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin_xep_0277.py b/src/plugins/plugin_xep_0277.py index b89b93c6..b6049f86 100755 --- a/src/plugins/plugin_xep_0277.py +++ b/src/plugins/plugin_xep_0277.py @@ -22,6 +22,7 @@ from sat.core.constants import Const as C from sat.core.log import getLogger log = getLogger(__name__) from twisted.words.protocols.jabber import jid, error +from twisted.words.protocols.jabber.xmlstream import XMPPHandler from twisted.words.xish import domish from twisted.internet import defer from twisted.python import failure @@ -33,6 +34,8 @@ from sat.tools.common import data_format # XXX: tmp.pubsub is actually used instead of wokkel version from wokkel import pubsub +from wokkel import disco, iwokkel +from zope.interface import implements import uuid import time import dateutil @@ -53,7 +56,7 @@ PLUGIN_INFO = { C.PI_DEPENDENCIES: ["XEP-0163", "XEP-0060", "TEXT-SYNTAXES"], C.PI_RECOMMENDATIONS: ["XEP-0059", "EXTRA-PEP"], C.PI_MAIN: "XEP_0277", - C.PI_HANDLER: "no", + C.PI_HANDLER: "yes", C.PI_DESCRIPTION: _("""Implementation of microblogging Protocol""") } @@ -98,6 +101,9 @@ class XEP_0277(object): host.bridge.addMethod("mbGetFromManyWithComments", ".plugin", in_sign='sasiia{ss}a{ss}s', out_sign='s', method=self._mbGetFromManyWithComments) + def getHandler(self, client): + return XEP_0277_handler() + def _checkFeaturesCb(self, available): return {'available': C.BOOL_TRUE} @@ -934,3 +940,13 @@ class XEP_0277(object): d.addErrback(lambda failure: (unicode(failure.value), ([],{}))) return self.rt_sessions.newSession(deferreds, client.profile) + + +class XEP_0277_handler(XMPPHandler): + implements(iwokkel.IDisco) + + def getDiscoInfo(self, requestor, target, nodeIdentifier=''): + return [disco.DiscoFeature(NS_MICROBLOG)] + + def getDiscoItems(self, requestor, target, nodeIdentifier=''): + return []