plugin email invitation: simple invitation creation
The new `invitationSimpleCreate` is a simplified way to create an email invitation.
This commit is contained in:
parent
25a429fa1b
commit
3f739a8ac8
1 changed files with 26 additions and 3 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# SAT plugin for file tansfer
|
||||
# SàT plugin for sending invitations by email
|
||||
# Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -91,6 +90,10 @@ class InvitationsPlugin(object):
|
|||
out_sign='a{sa{ss}}',
|
||||
method=self._list,
|
||||
async_=True)
|
||||
host.bridge.addMethod("invitationSimpleCreate", ".plugin", in_sign='',
|
||||
out_sign='a{ss}',
|
||||
method=self._simpleCreate,
|
||||
async_=True)
|
||||
|
||||
def checkExtra(self, extra):
|
||||
if EXTRA_RESERVED.intersection(extra):
|
||||
|
|
@ -338,6 +341,26 @@ class InvitationsPlugin(object):
|
|||
extra[KEY_JID] = jid_
|
||||
defer.returnValue(extra)
|
||||
|
||||
def _simpleCreate(self, invitee_email, url_template, extra_s, profile):
|
||||
client = self.host.getClient(profile)
|
||||
# FIXME: needed because python-dbus use a specific string class
|
||||
invitee_email = str(invitee_email)
|
||||
url_template = str(url_template)
|
||||
extra = data_format.deserialise(extra_s)
|
||||
d = defer.ensureDeferred(
|
||||
self.simpleCreate(client, invitee_email, url_template, extra)
|
||||
)
|
||||
d.addCallback(lambda data: {k: str(v) for k,v in data.items()})
|
||||
return d
|
||||
|
||||
async def simpleCreate(self, client, invitee_email, url_template, extra):
|
||||
"""Simplified method to invite somebody by email"""
|
||||
return await self.create(
|
||||
email=invitee_email,
|
||||
url_template=url_template,
|
||||
profile=client.profile,
|
||||
)
|
||||
|
||||
def get(self, id_):
|
||||
"""Retrieve invitation linked to uuid if it exists
|
||||
|
||||
|
|
@ -374,7 +397,7 @@ class InvitationsPlugin(object):
|
|||
new_data = current_data
|
||||
for k,v in new_extra.items():
|
||||
if k in EXTRA_RESERVED:
|
||||
log.warning(_("Skipping reserved key {key}".format(k)))
|
||||
log.warning(_("Skipping reserved key {key}").format(key=k))
|
||||
continue
|
||||
if v:
|
||||
new_data[k] = v
|
||||
|
|
|
|||
Loading…
Reference in a new issue