[CalendarServer-changes] [5726] CalendarServer/trunk/twistedcaldav/mail.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jun 10 17:14:27 PDT 2010
Revision: 5726
http://trac.macosforge.org/projects/calendarserver/changeset/5726
Author: sagen at apple.com
Date: 2010-06-10 17:14:22 -0700 (Thu, 10 Jun 2010)
Log Message:
-----------
If someone replies to an imip message as if it were a regular email (i.e., they reply to the server in their email client), forward that email to the event organizer.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/mail.py
Modified: CalendarServer/trunk/twistedcaldav/mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/mail.py 2010-06-11 00:01:28 UTC (rev 5725)
+++ CalendarServer/trunk/twistedcaldav/mail.py 2010-06-11 00:14:22 UTC (rev 5726)
@@ -708,6 +708,17 @@
self.log_error("Mail gateway couldn't parse To: address (%s) in message %s" % (msg['To'], msg['Message-ID']))
return
+ result = self.db.lookupByToken(token)
+ if result is None:
+ # This isn't a token we recognize
+ self.log_error("Mail gateway found a token (%s) but didn't recognize it in message %s" % (token, msg['Message-ID']))
+ return
+
+ organizer, attendee, icaluid = result
+ organizer = str(organizer)
+ attendee = str(attendee)
+ icaluid = str(icaluid)
+
for part in msg.walk():
if part.get_content_type() == "text/calendar":
calBody = part.get_payload(decode=True)
@@ -715,23 +726,46 @@
else:
# No icalendar attachment
self.log_error("Mail gateway didn't find an icalendar attachment in message %s" % (msg['Message-ID'],))
- return
+ if not organizer.startswith("mailto:"):
+ self.log_error("Don't have an email address for the organizer; ignoring reply.")
+ return
+
+ # Forward this email to organizer
+ toAddr = organizer[7:]
+ fromAddr = attendee[7:]
+
+ settings = config.Scheduling["iMIP"]["Sending"]
+ if settings["UseSSL"]:
+ contextFactory = ssl.ClientContextFactory()
+ else:
+ contextFactory = None
+
+ deferred = defer.Deferred()
+ del msg["From"]
+ msg["From"] = fromAddr
+ del msg["Reply-To"]
+ msg["Reply-To"] = fromAddr
+ del msg["To"]
+ msg["To"] = toAddr
+ factory = ESMTPSenderFactory(
+ settings["Username"], settings["Password"],
+ fromAddr, toAddr, StringIO(str(msg)), deferred,
+ contextFactory=contextFactory,
+ requireAuthentication=False,
+ requireTransportSecurity=settings["UseSSL"],
+ )
+
+ reactor.connectTCP(settings["Server"], settings["Port"], factory)
+ return deferred
+
+
+ # Process the imip attachment; inject to calendar server
+
self.log_debug(calBody)
calendar = ical.Component.fromString(calBody)
event = calendar.mainComponent()
- # process mail messages from POP or IMAP, inject to calendar server
- result = self.db.lookupByToken(token)
- if result is None:
- # This isn't a token we recognize
- self.log_error("Mail gateway found a token (%s) but didn't recognize it in message %s" % (token, msg['Message-ID']))
- return
-
- organizer, attendee, icaluid = result
- organizer = str(organizer)
- attendee = str(attendee)
- icaluid = str(icaluid)
calendar.removeAllButOneAttendee(attendee)
organizerProperty = calendar.getOrganizerProperty()
if organizerProperty is None:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100610/2267c631/attachment.html>
More information about the calendarserver-changes
mailing list