plugin invitations: name is now registered as nickname on XMPP server thanks to plugin identity
This commit is contained in:
parent
9ce44321cf
commit
0b154647e4
1 changed files with 16 additions and 3 deletions
|
|
@ -36,6 +36,7 @@ PLUGIN_INFO = {
|
|||
C.PI_IMPORT_NAME: "INVITATIONS",
|
||||
C.PI_TYPE: C.PLUG_TYPE_MISC,
|
||||
C.PI_DEPENDENCIES: ['XEP-0077'],
|
||||
C.PI_RECOMMENDATIONS: ["IDENTITY"],
|
||||
C.PI_MAIN: "InvitationsPlugin",
|
||||
C.PI_HANDLER: "no",
|
||||
C.PI_DESCRIPTION: _(u"""invitation of people without XMPP account""")
|
||||
|
|
@ -125,6 +126,7 @@ class InvitationsPlugin(object):
|
|||
password(unicode, None): password to use (will be used for XMPP account and profile)
|
||||
None to automatically generate one
|
||||
name(unicode, None): name of the invitee
|
||||
will be set as profile identity if present
|
||||
host_name(unicode, None): name of the host
|
||||
email(unicode, None): email to send the invitation to
|
||||
if None, no invitation email is sent, you can still associate email using extra
|
||||
|
|
@ -170,7 +172,6 @@ class InvitationsPlugin(object):
|
|||
if email is not None and not 'url_template' in kwargs and not 'message_body' in kwargs:
|
||||
raise ValueError(_(u"You need to provide url_template if you use default message body"))
|
||||
|
||||
|
||||
## uuid
|
||||
log.info(_(u"creating an invitation"))
|
||||
id_ = unicode(shortuuid.uuid())
|
||||
|
|
@ -220,12 +221,25 @@ class InvitationsPlugin(object):
|
|||
log.info(_(u"account {jid_} created").format(jid_=jid_.full()))
|
||||
|
||||
## profile creation
|
||||
|
||||
extra[KEY_GUEST_PROFILE] = guest_profile = INVITEE_PROFILE_TPL.format(uuid=id_)
|
||||
# profile creation should not fail as we generate unique name ourselves
|
||||
yield self.host.memory.createProfile(guest_profile, password)
|
||||
yield self.host.memory.startSession(password, guest_profile)
|
||||
yield self.host.memory.setParam("JabberID", jid_.full(), "Connection", profile_key=guest_profile)
|
||||
yield self.host.memory.setParam("Password", password, "Connection", profile_key=guest_profile)
|
||||
name = kwargs.pop(u'name', None)
|
||||
if name is not None:
|
||||
extra[u'name'] = name
|
||||
try:
|
||||
id_plugin = self.host.plugins[u'IDENTITY']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
yield self.host.connect(guest_profile, password)
|
||||
guest_client = self.host.getClient(guest_profile)
|
||||
yield id_plugin.setIdentity(guest_client, {u'nick': name})
|
||||
yield self.host.disconnect(guest_profile)
|
||||
|
||||
## email
|
||||
language = kwargs.pop(u'language', None)
|
||||
|
|
@ -240,11 +254,10 @@ class InvitationsPlugin(object):
|
|||
u'app_name': C.APP_NAME,
|
||||
u'app_url': C.APP_URL}
|
||||
|
||||
name = kwargs.pop(u'name', None)
|
||||
if name is None:
|
||||
format_args[u'name'] = email
|
||||
else:
|
||||
format_args[u'name'] = extra[u'name'] = name
|
||||
format_args[u'name'] = name
|
||||
|
||||
profile = kwargs.pop(u'profile', None)
|
||||
if profile is None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue