cyrusimap / cyrus-imapd

Cyrus IMAP is an email, contacts and calendar server
http://cyrusimap.org
Other
544 stars 149 forks source link

Sending VTODO without start per email #2555

Open dilyanpalauzov opened 6 years ago

dilyanpalauzov commented 6 years ago

When cyrus sends VTODO without DTSTART/DTEND/DURATION per email to the attendees, the email includes as text and html "When: 00 0000 00:00 UTC".

dilyanpalauzov commented 6 years ago
diff --git a/imap/http_caldav_sched.c b/imap/http_caldav_sched.c
--- a/imap/http_caldav_sched.c
+++ b/imap/http_caldav_sched.c
@@ -263,7 +263,7 @@ static int imip_send_sendmail(icalcomponent *ical,
     struct address_t *recipients = NULL, *originator = NULL, *recip;
     struct icaltimetype start, end;
     char *cp, when[2*RFC822_DATETIME_MAX+4], datestr[RFC822_DATETIME_MAX+1];
-    char boundary[100], *mimebody, *ical_str;
+    char boundary[100], *mimebody, *ical_str, has_dtstart;
     size_t outlen;
     struct buf plainbuf = BUF_INITIALIZER, tmpbuf = BUF_INITIALIZER;
     FILE *sm;
@@ -347,6 +347,7 @@ static int imip_send_sendmail(icalcomponent *ical,
     }
     else status = NULL;

+    has_dtstart = icalcomponent_get_first_property(icalcomponent_get_inner(comp), ICAL_DTSTART_PROPERTY) != 0;
     start = icaltime_convert_to_zone(icalcomponent_get_dtstart(comp), utc_zone);
     end = icaltime_convert_to_zone(icalcomponent_get_dtend(comp), utc_zone);

@@ -445,7 +446,8 @@ static int imip_send_sendmail(icalcomponent *ical,
         buf_replace_all(&tmpbuf, "\n", "\r\n" TEXT_INDENT);
         buf_printf(&plainbuf, "Location   : %s\r\n", buf_cstring(&tmpbuf));
     }
-    buf_printf(&plainbuf, "When       : %s\r\n", when);
+    if (has_dtstart)
+        buf_printf(&plainbuf, "When       : %s\r\n", when);
     if (meth == ICAL_METHOD_REPLY) {
         if (originator->partstat)
             buf_printf(&plainbuf, "RSVP       : %s\r\n", originator->partstat);
@@ -509,7 +511,8 @@ static int imip_send_sendmail(icalcomponent *ical,
         HTMLencode(&tmpbuf, location);
         fprintf(sm, HTML_ROW, "Location", buf_cstring(&tmpbuf));
     }
-    fprintf(sm, HTML_ROW, "When", when);
+    if (has_dtstart)
+        fprintf(sm, HTML_ROW, "When", when);
     if (meth == ICAL_METHOD_REPLY) {
         if (originator->partstat)
             fprintf(sm, HTML_ROW, "RSVP", originator->partstat);