Mercurial > libervia-backend
changeset 2341:f9580b4a105a
plugin XEP-0277: added microblog namespace to disco info
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 20 Aug 2017 17:37:43 +0200 |
parents | 4fd499d14b27 |
children | f047d5410040 |
files | src/plugins/plugin_xep_0277.py |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 []