Caldav: outbox handling, notify all attendees if current user is organizer,

else notify only organizer

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@364 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-02-16 23:42:07 +00:00
parent 5245ece50a
commit a21cfb1b8a
1 changed files with 23 additions and 9 deletions

View File

@ -1397,7 +1397,8 @@ public class ExchangeSession {
} }
protected String getRecipients(String icsBody) throws IOException { protected String getRecipients(String icsBody) throws IOException {
StringBuilder recipients = new StringBuilder(); HashSet<String> recipients = new HashSet<String>();
String organizer = null;
BufferedReader reader = null; BufferedReader reader = null;
try { try {
reader = new ICSBufferedReader(new StringReader(icsBody)); reader = new ICSBufferedReader(new StringReader(icsBody));
@ -1411,17 +1412,16 @@ public class ExchangeSession {
if (semiColon >= 0) { if (semiColon >= 0) {
key = key.substring(0, semiColon); key = key.substring(0, semiColon);
} }
if ("ATTENDEE".equals(key)) { if ("ORGANIZER".equals(key) || "ATTENDEE".equals(key)) {
int colonIndex = value.indexOf(':'); int colonIndex = value.indexOf(':');
if (colonIndex >= 0) { if (colonIndex >= 0) {
value = value.substring(colonIndex + 1); value = value.substring(colonIndex + 1);
} }
if ("ORGANIZER".equals(key)) {
organizer = value;
// exclude current user from recipients // exclude current user from recipients
if (!email.equalsIgnoreCase(value)) { } else if (!email.equalsIgnoreCase(value)) {
if (recipients.length() > 0) { recipients.add(value);
recipients.append(", ");
}
recipients.append(value);
} }
} }
} }
@ -1431,7 +1431,21 @@ public class ExchangeSession {
reader.close(); reader.close();
} }
} }
return recipients.toString(); StringBuilder result = new StringBuilder();
if (email.equalsIgnoreCase(organizer)) {
// current user is organizer => notify all
for (String recipient : recipients) {
if (result.length() > 0) {
result.append(", ");
}
result.append(recipient);
}
} else {
// notify only organizer
result.append(organizer);
}
return result.toString();
} }
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 {