mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -05:00
Caldav: fix sendEvent regression, conflict on outbox notifications
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1290 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
5dba7b1cd4
commit
957bc7f189
@ -2368,12 +2368,12 @@ public abstract class ExchangeSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update item
|
||||
* Build Mime body for event or event message.
|
||||
*
|
||||
* @return action result
|
||||
* @return mimeContent as byte array or null
|
||||
* @throws IOException on error
|
||||
*/
|
||||
public ItemResult createOrUpdate() throws IOException {
|
||||
public byte[] createMimeContent() throws IOException {
|
||||
String boundary = UUID.randomUUID().toString();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
MimeOutputStreamWriter writer = new MimeOutputStreamWriter(baos);
|
||||
@ -2397,14 +2397,14 @@ public abstract class ExchangeSession {
|
||||
writer.writeHeader("Cc", participants.optionalAttendees);
|
||||
// do not send notification if no recipients found
|
||||
if (participants.attendees == null && participants.optionalAttendees == null) {
|
||||
status = HttpStatus.SC_NO_CONTENT;
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
// notify only organizer
|
||||
writer.writeHeader("To", participants.organizer);
|
||||
// do not send notification if no recipients found
|
||||
if (participants.organizer == null) {
|
||||
status = HttpStatus.SC_NO_CONTENT;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2470,13 +2470,23 @@ public abstract class ExchangeSession {
|
||||
writer.writeLn();
|
||||
writer.writeLn("------=_NextPart_" + boundary + "--");
|
||||
writer.close();
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update item
|
||||
*
|
||||
* @return action result
|
||||
* @throws IOException on error
|
||||
*/
|
||||
public ItemResult createOrUpdate() throws IOException {
|
||||
byte[] mimeContent = createMimeContent();
|
||||
ItemResult itemResult;
|
||||
if (status == 0) {
|
||||
itemResult = createOrUpdate(baos.toByteArray());
|
||||
if (mimeContent != null) {
|
||||
itemResult = createOrUpdate(mimeContent);
|
||||
} else {
|
||||
itemResult = new ItemResult();
|
||||
itemResult.status = status;
|
||||
itemResult.status = HttpStatus.SC_NO_CONTENT;
|
||||
}
|
||||
|
||||
return itemResult;
|
||||
|
@ -1293,16 +1293,13 @@ public class DavExchangeSession extends ExchangeSession {
|
||||
@Override
|
||||
public int sendEvent(String icsBody) throws IOException {
|
||||
String itemName = UUID.randomUUID().toString() + ".EML";
|
||||
int status = internalCreateOrUpdateEvent(draftsUrl, itemName, "urn:content-classes:calendarmessage", icsBody, null, null).status;
|
||||
if (status != HttpStatus.SC_CREATED) {
|
||||
return status;
|
||||
byte[] mimeContent = (new Event(getFolderPath(DRAFTS), itemName, "urn:content-classes:calendarmessage", icsBody, null, null)).createMimeContent();
|
||||
if (mimeContent == null) {
|
||||
// no recipients, cancel
|
||||
return HttpStatus.SC_NO_CONTENT;
|
||||
} else {
|
||||
MoveMethod method = new MoveMethod(URIUtil.encodePath(draftsUrl + '/' + itemName), URIUtil.encodePath(sendmsgUrl), true);
|
||||
status = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, method);
|
||||
if (status != HttpStatus.SC_OK) {
|
||||
throw DavGatewayHttpClientFacade.buildHttpException(method);
|
||||
}
|
||||
return status;
|
||||
sendMessage(mimeContent);
|
||||
return HttpStatus.SC_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user