changeset 3336:e38ddaf477bd

plugin email invitation: guests are now automatically added to host roster in `guests` group
author Goffi <goffi@goffi.org>
date Thu, 13 Aug 2020 23:46:18 +0200
parents 83bc9d46a417
children 932cf08dfdc3
files sat/plugins/plugin_misc_email_invitation.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_email_invitation.py	Thu Aug 13 23:46:18 2020 +0200
+++ b/sat/plugins/plugin_misc_email_invitation.py	Thu Aug 13 23:46:18 2020 +0200
@@ -325,6 +325,17 @@
                 (kwargs.pop('message_body', None) or DEFAULT_BODY).format(**format_args),
             )
 
+        ## roster
+
+        # we automatically add guest to host roster (if host is specified)
+        # FIXME: a parameter to disable auto roster adding would be nice
+        if profile is not None:
+            try:
+                client = self.host.getClient(profile)
+            except Exception as e:
+                log.error(f"Can't get host profile: {profile}: {e}")
+            else:
+                await self.host.updateContact(client, jid_, name, ['guests'])
 
         if kwargs:
             log.warning(_("Not all arguments have been consumed: {}").format(kwargs))