Page MenuHomekolab.org

Wallace is not processing invitations for members of a group (edited)
Open, NormalPublic

Description

Hi,

wallace is ignoring itip requests if the appointment is addressed to a static kolab group instead of an individual.

wallace-0.8.7-2.5.el7.kolab_16.noarch
pykolab-0.8.7-2.5.el7.kolab_16.noarch

This patch should fix this by adding the individual attendee to this itip message if it is addressed indirectly via a kolab group:

---/usr/lib/python2.7/site-packages/wallace/module_invitationpolicy.py.orig	2018-03-19 11:12:55.321272385 +0100
+++ /usr/lib/python2.7/site-packages/wallace/module_invitationpolicy.py	2018-03-19 11:13:05.062383549 +0100
@@ -28,6 +28,7 @@
import re
 
 from email import message_from_string
+from email import message_from_file
 from email.parser import Parser
 from email.utils import formataddr
 from email.utils import getaddresses
@@ -165,7 +166,16 @@
     cleanup()
     os.rename(filepath, new_filepath)
     filepath = new_filepath
-    exec('modules.cb_action_ACCEPT(%r, %r)' % ('invitationpolicy',filepath))
+    
+    # Adding invitation policy header
+    message = message_from_file(open(filepath, 'r'))
+    message.add_header("X-Wallace-InvitationPolicy_Processed", "YES")
+    (fp, new_filepath) = tempfile.mkstemp(dir="/var/spool/pykolab/wallace/footer/ACCEPT")
+    os.write(fp, message.as_string())
+    os.close(fp)
+    os.unlink(filepath)
+                
+    exec('modules.cb_action_ACCEPT(%r, %r)' % ('invitationpolicy',new_filepath))
 
 def reject(filepath):
     new_filepath = os.path.join(
@@ -323,10 +333,37 @@
         user_attendees = [organizer_mailto] if organizer_mailto in recipient_emails else []
 
     else:
-        # Limit the attendees to the one that is actually invited with the current message.
+        # If attendee is a group, add all group members to the attendee list
         attendees = [str(a).split(':')[-1] for a in (itip_event['attendees'] if itip_event.has_key('attendees') else [])]
-        user_attendees = [a for a in attendees if a in recipient_emails]
+        itip_attendees = list(attendees)
+                
+        group_member_attr = conf.get_list('ldap', 'group_member_attribute')
+        if not group_member_attr:
+            group_member_attr = "uniquemember"
+                                    
+        for attendee in attendees:
+            attendee_dn = auth.find_recipient(attendee)
+            if attendee_dn:
+                members = auth.get_entry_attributes(None, attendee_dn, [group_member_attr])
+                if members and members.has_key(group_member_attr):
+                    members_emails = []
+                    for member_dn in members[group_member_attr]:
+                        member = auth.get_entry_attributes(None, member_dn, ['mail'])
+                        if member:
+                            members_emails.append(member['mail'])
+                    if members_emails:
+                        log.debug(_("Adding members for %s : %r") % (attendee,members_emails),level=8)
+                        attendees += members_emails
 
+        # Limit the attendees to the one that is actually invited with the current message.
+        user_attendees = [a for a in attendees if a in recipient_emails]
+        
+        # make sure that the attendee is in xml attendee list (need to add this attendee if it comes from a group substitute)
+        if 0 < len(user_attendees):
+          if not user_attendees[0] in itip_attendees:
+            log.debug(_("Adding user substitute: %r into %r") % (user_attendees,itip_attendees),level=9)
+            itip_event['xml'].add_attendee(user_attendees[0])
+        
         if itip_event.has_key('organizer'):
             sender_email = itip_event['xml'].get_organizer().email()
 
@@ -1238,6 +1275,9 @@
     msg['Subject'] = utils.str2unicode(_('"%s" has been updated') % (object.get_summary()))
     msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '')
     msg['From'].append("<%s>" % orgemail)
+    
+    msg.add_header("X-Wallace-InvitationPolicy_Processed", "YES")
+    msg.add_header("X-Wallace-InvitationPolicy_CalendarAction", "YES")
 
     smtp = smtplib.SMTP("localhost", 10027)
 
@@ -1320,6 +1360,9 @@
     msg['Subject'] = utils.str2unicode(_('"%s" has been cancelled') % (object.get_summary()))
     msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '')
     msg['From'].append("<%s>" % orgemail)
+    
+    msg.add_header("X-Wallace-InvitationPolicy_Processed", "YES")                
+    msg.add_header("X-Wallace-InvitationPolicy_CalendarAction", "YES")
 
     smtp = smtplib.SMTP("localhost", 10027)

Kind Regards,
Jürgen

Details

Ticket Type
Task

Event Timeline

juwo created this task.Mar 19 2018, 12:00 PM
juwo updated the task description. (Show Details)Mar 28 2018, 5:33 PM
juwo renamed this task from Wallace is not processing invitations for members of a group to Wallace is not processing invitations for members of a group (edited).Mar 28 2018, 5:39 PM
juwo updated the task description. (Show Details)
juwo updated the task description. (Show Details)Apr 13 2018, 9:49 AM

What do you expect to happen when an invitation is created, and 'group@example.org' is invited?

Please also note you're using an outdated version of pykolab/wallace. The current version is 0.8.10.

Patches are reviewed and possibly accepted through Differential. Please git clone, make your edits, and 'arc diff'.

vanmeeuwen lowered the priority of this task from 60 to Normal.Mar 28 2019, 8:03 AM
pasik added a subscriber: pasik.May 23 2019, 2:24 PM