# HG changeset patch # User Goffi # Date 1503243463 -7200 # Node ID f9580b4a105a061da7e034d62de68a7684824283 # Parent 4fd499d14b270b9c802b00f9e9c232625238619d plugin XEP-0277: added microblog namespace to disco info diff -r 4fd499d14b27 -r f9580b4a105a src/plugins/plugin_xep_0277.py --- a/src/plugins/plugin_xep_0277.py Sun Aug 20 15:01:35 2017 +0200 +++ b/src/plugins/plugin_xep_0277.py Sun Aug 20 17:37:43 2017 +0200 @@ -22,6 +22,7 @@ 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 @@ # 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 @@ 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 @@ 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 @@ 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 []