comparison src/plugins/plugin_misc_invitations.py @ 2212:eaf2467d19ce

plugin invitations: added getInvitation method, it return invitation data and raise an error if it is not found
author Goffi <goffi@goffi.org>
date Wed, 29 Mar 2017 19:42:42 +0200
parents df115e4a36c7
children 77a3d0a28642
comparison
equal deleted inserted replaced
2211:df115e4a36c7 2212:eaf2467d19ce
70 self.host = host 70 self.host = host
71 self.invitations = persistent.LazyPersistentBinaryDict(u'invitations') 71 self.invitations = persistent.LazyPersistentBinaryDict(u'invitations')
72 host.bridge.addMethod("invitationCreate", ".plugin", in_sign='sssssssssa{ss}s', out_sign='a{ss}', 72 host.bridge.addMethod("invitationCreate", ".plugin", in_sign='sssssssssa{ss}s', out_sign='a{ss}',
73 method=self._createInvitation, 73 method=self._createInvitation,
74 async=True) 74 async=True)
75 host.bridge.addMethod("invitationGet", ".plugin", in_sign='s', out_sign='a{ss}',
76 method=self.getInvitation,
77 async=True)
78
75 def _createInvitation(self, jid_=u'', password=u'', name=u'', host_name=u'', email=u'', language=u'', url_template=u'', message_subject=u'', message_body=u'', extra=None, profile=u''): 79 def _createInvitation(self, jid_=u'', password=u'', name=u'', host_name=u'', email=u'', language=u'', url_template=u'', message_subject=u'', message_body=u'', extra=None, profile=u''):
76 # XXX: we don't use **kwargs here to keep arguments name for introspection with D-Bus bridge 80 # XXX: we don't use **kwargs here to keep arguments name for introspection with D-Bus bridge
77 81
78 if extra is None: 82 if extra is None:
79 extra = {} 83 extra = {}
257 log.warning(_(u"Not all arguments have been consumed: {}").format(kwargs)) 261 log.warning(_(u"Not all arguments have been consumed: {}").format(kwargs))
258 262
259 extra[KEY_ID] = id_ 263 extra[KEY_ID] = id_
260 extra[KEY_JID] = jid 264 extra[KEY_JID] = jid
261 defer.returnValue(extra) 265 defer.returnValue(extra)
266
267 def getInvitation(self, id_):
268 """Retrieve invitation linked to uuid if it exists
269
270 @param id_(unicode): UUID linked to an invitation
271 @return dict(unicode, unicode): data associated to the invitation
272 @raise KeyError: there is not invitation with this id_
273 """
274 return self.invitations[id_]