plugin invitations: invitation id and invitee jid are now added to return dict in invitationCreate, bridge signature has changed too

This commit is contained in:
Goffi 2017-03-29 19:35:55 +02:00
commit e70fc0d62f

View file

@ -44,9 +44,11 @@ PLUGIN_INFO = {
SUFFIX_MAX = 5
INVITEE_PROFILE_TPL = u"guest@@{uuid}"
KEY_ID = u'id'
KEY_JID = u'jid'
KEY_CREATED = u'created'
KEY_LAST_CONNECTION = u'last_connection'
EXTRA_RESERVED = {KEY_CREATED, u'jid_', u'jid', KEY_LAST_CONNECTION}
EXTRA_RESERVED = {KEY_ID, KEY_JID, KEY_CREATED, u'jid_', u'jid', KEY_LAST_CONNECTION}
DEFAULT_SUBJECT = D_(u"You have been invited by {host_name} to {app_name}")
DEFAULT_BODY = D_(u"""Hello {name}!
@ -67,7 +69,7 @@ class InvitationsPlugin(object):
log.info(_(u"plugin Invitations initialization"))
self.host = host
self.invitations = persistent.LazyPersistentBinaryDict(u'invitations')
host.bridge.addMethod("invitationCreate", ".plugin", in_sign='sssssssssa{ss}s', out_sign='(sa{ss})',
host.bridge.addMethod("invitationCreate", ".plugin", in_sign='sssssssssa{ss}s', out_sign='a{ss}',
method=self._createInvitation,
async=True)
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''):
@ -84,7 +86,11 @@ class InvitationsPlugin(object):
value = locals()[key]
if value:
kwargs[key] = unicode(value)
return self.createInvitation(**kwargs)
d = self.createInvitation(**kwargs)
def serialize(data):
data[KEY_JID] = data[KEY_JID].full()
d.addCallback(serialize)
return d
@defer.inlineCallbacks
def createInvitation(self, **kwargs):
@ -129,8 +135,8 @@ class InvitationsPlugin(object):
- created (creation date)
if email argument is used, "email" key can't be used
profile(unicode, None): profile of the host (person who is inviting)
@return (unicode, dict[unicode, unicode]): tuple with:
- UUID associated with the invitee
@return (dict[unicode, unicode]): dictionary with:
- UUID associated with the invitee (key: id)
- filled extra dictionary, as saved in the databae
"""
## initial checks
@ -250,4 +256,6 @@ class InvitationsPlugin(object):
if kwargs:
log.warning(_(u"Not all arguments have been consumed: {}").format(kwargs))
defer.returnValue((id_, extra))
extra[KEY_ID] = id_
extra[KEY_JID] = jid
defer.returnValue(extra)