# HG changeset patch # User Goffi # Date 1493247203 -7200 # Node ID ebc0c1701811b1dbe7918beb369a7c54752aaf4b # Parent 761fa220a717b2c18d1e681ddc9c52c5130d083f plugin invitations: added invitationList command diff -r 761fa220a717 -r ebc0c1701811 src/plugins/plugin_misc_invitations.py --- a/src/plugins/plugin_misc_invitations.py Thu Apr 20 17:20:44 2017 +0200 +++ b/src/plugins/plugin_misc_invitations.py Thu Apr 27 00:53:23 2017 +0200 @@ -80,6 +80,9 @@ host.bridge.addMethod("invitationModify", ".plugin", in_sign='sa{ss}b', out_sign='', method=self._modify, async=True) + host.bridge.addMethod("invitationList", ".plugin", in_sign='s', out_sign='a{sa{ss}}', + method=self._list, + async=True) def checkExtra(self, extra): if EXTRA_RESERVED.intersection(extra): @@ -103,6 +106,7 @@ d = self.create(**kwargs) def serialize(data): data[KEY_JID] = data[KEY_JID].full() + return data d.addCallback(serialize) return d @@ -270,7 +274,7 @@ log.warning(_(u"Not all arguments have been consumed: {}").format(kwargs)) extra[KEY_ID] = id_ - extra[KEY_JID] = jid + extra[KEY_JID] = jid_ defer.returnValue(extra) def get(self, id_): @@ -313,3 +317,20 @@ d = self.invitations[id_] d.addCallback(gotCurrentData) return d + + def _list(self, profile=C.PROF_KEY_NONE): + return self.list(profile) + + @defer.inlineCallbacks + def list(self, profile=C.PROF_KEY_NONE): + """List invitations + + @param profile(unicode): return invitation linked to this profile only + C.PROF_KEY_NONE: don't filter invitations + @return list(unicode): invitations uids + """ + invitations = yield self.invitations.items() + if profile != C.PROF_KEY_NONE: + invitations = {id_:data for id_, data in invitations.iteritems() if data.get(u'profile') == profile} + + defer.returnValue(invitations)