Caldav: do not send notifications if no valid recipients found
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@386 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
52d5f6473a
commit
4554b9f685
|
@ -1485,6 +1485,7 @@ public class ExchangeSession {
|
||||||
|
|
||||||
protected EventResult internalCreateOrUpdateEvent(String messageUrl, String contentClass, String icsBody, String etag, String noneMatch) throws IOException {
|
protected EventResult internalCreateOrUpdateEvent(String messageUrl, String contentClass, String icsBody, String etag, String noneMatch) throws IOException {
|
||||||
String uid = UUID.randomUUID().toString();
|
String uid = UUID.randomUUID().toString();
|
||||||
|
int status = 0;
|
||||||
PutMethod putmethod = new PutMethod(messageUrl);
|
PutMethod putmethod = new PutMethod(messageUrl);
|
||||||
putmethod.setRequestHeader("Translate", "f");
|
putmethod.setRequestHeader("Translate", "f");
|
||||||
putmethod.setRequestHeader("Overwrite", "f");
|
putmethod.setRequestHeader("Overwrite", "f");
|
||||||
|
@ -1502,10 +1503,11 @@ public class ExchangeSession {
|
||||||
if ("urn:content-classes:calendarmessage".equals(contentClass)) {
|
if ("urn:content-classes:calendarmessage".equals(contentClass)) {
|
||||||
// need to parse attendees to build recipients
|
// need to parse attendees to build recipients
|
||||||
String recipients = getRecipients(icsBody);
|
String recipients = getRecipients(icsBody);
|
||||||
if (recipients.length() == 0) {
|
|
||||||
throw new IOException("Invalid notification: no recipient found");
|
|
||||||
}
|
|
||||||
body.append("To: ").append(recipients).append("\r\n");
|
body.append("To: ").append(recipients).append("\r\n");
|
||||||
|
// do not send notification if no recipients found
|
||||||
|
if (recipients.length() == 0) {
|
||||||
|
status = HttpStatus.SC_NO_CONTENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
body.append("MIME-Version: 1.0\r\n" +
|
body.append("MIME-Version: 1.0\r\n" +
|
||||||
"Content-Type: multipart/alternative;\r\n" +
|
"Content-Type: multipart/alternative;\r\n" +
|
||||||
|
@ -1522,15 +1524,15 @@ public class ExchangeSession {
|
||||||
body.append(new String(fixICS(icsBody, false).getBytes("UTF-8"), "ISO-8859-1"));
|
body.append(new String(fixICS(icsBody, false).getBytes("UTF-8"), "ISO-8859-1"));
|
||||||
body.append("------=_NextPart_").append(uid).append("--\r\n");
|
body.append("------=_NextPart_").append(uid).append("--\r\n");
|
||||||
putmethod.setRequestBody(body.toString());
|
putmethod.setRequestBody(body.toString());
|
||||||
int status;
|
|
||||||
try {
|
try {
|
||||||
|
if (status == 0) {
|
||||||
status = wdr.retrieveSessionInstance().executeMethod(putmethod);
|
status = wdr.retrieveSessionInstance().executeMethod(putmethod);
|
||||||
|
|
||||||
if (status == HttpURLConnection.HTTP_OK) {
|
if (status == HttpURLConnection.HTTP_OK) {
|
||||||
LOGGER.warn("Overwritten event " + messageUrl);
|
LOGGER.warn("Overwritten event " + messageUrl);
|
||||||
} else if (status != HttpURLConnection.HTTP_CREATED) {
|
} else if (status != HttpURLConnection.HTTP_CREATED) {
|
||||||
LOGGER.warn("Unable to create or update message " + status + " " + putmethod.getStatusLine());
|
LOGGER.warn("Unable to create or update message " + status + " " + putmethod.getStatusLine());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
putmethod.releaseConnection();
|
putmethod.releaseConnection();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue