Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Folder namespaces and CreateFolderResponse structure #36

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions src/types/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,18 +804,32 @@ pub struct ItemId {

/// The representation of a folder in an EWS operation.
#[derive(Clone, Debug, Deserialize, XmlSerialize)]
#[xml_struct(variant_ns_prefix = "t")]
pub enum Folder {
/// A calendar folder in a mailbox.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/calendarfolder>
#[serde(rename_all = "PascalCase")]
CalendarFolder {
#[xml_struct(ns_prefix = "t")]
folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
parent_folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
folder_class: Option<String>,

#[xml_struct(ns_prefix = "t")]
display_name: Option<String>,

#[xml_struct(ns_prefix = "t")]
total_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
child_folder_count: Option<u32>,
Comment on lines +826 to 830
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefixing total_count and child_folder_count (as well as unread_count for Folder) is a bit weird since they're explicitly read-only and we should never actually be sending them, but I think it's better to do so, as we might get a specific "these fields are read-only" error instead of the generic 500 we get when we don't specify namespaces correctly.


#[xml_struct(ns_prefix = "t")]
extended_property: Option<Vec<ExtendedProperty>>,
},

Expand All @@ -824,12 +838,25 @@ pub enum Folder {
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/contactsfolder>
#[serde(rename_all = "PascalCase")]
ContactsFolder {
#[xml_struct(ns_prefix = "t")]
folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
parent_folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
folder_class: Option<String>,

#[xml_struct(ns_prefix = "t")]
display_name: Option<String>,

#[xml_struct(ns_prefix = "t")]
total_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
child_folder_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
extended_property: Option<Vec<ExtendedProperty>>,
},

Expand All @@ -838,13 +865,28 @@ pub enum Folder {
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/folder>
#[serde(rename_all = "PascalCase")]
Folder {
#[xml_struct(ns_prefix = "t")]
folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
parent_folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
folder_class: Option<String>,

#[xml_struct(ns_prefix = "t")]
display_name: Option<String>,

#[xml_struct(ns_prefix = "t")]
total_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
child_folder_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
extended_property: Option<Vec<ExtendedProperty>>,

#[xml_struct(ns_prefix = "t")]
unread_count: Option<u32>,
},

Expand All @@ -853,12 +895,25 @@ pub enum Folder {
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/searchfolder>
#[serde(rename_all = "PascalCase")]
SearchFolder {
#[xml_struct(ns_prefix = "t")]
folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
parent_folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
folder_class: Option<String>,

#[xml_struct(ns_prefix = "t")]
display_name: Option<String>,

#[xml_struct(ns_prefix = "t")]
total_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
child_folder_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
extended_property: Option<Vec<ExtendedProperty>>,
},

Expand All @@ -867,12 +922,25 @@ pub enum Folder {
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/tasksfolder>
#[serde(rename_all = "PascalCase")]
TasksFolder {
#[xml_struct(ns_prefix = "t")]
folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
parent_folder_id: Option<FolderId>,

#[xml_struct(ns_prefix = "t")]
folder_class: Option<String>,

#[xml_struct(ns_prefix = "t")]
display_name: Option<String>,

#[xml_struct(ns_prefix = "t")]
total_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
child_folder_count: Option<u32>,

#[xml_struct(ns_prefix = "t")]
extended_property: Option<Vec<ExtendedProperty>>,
},
}
Expand All @@ -884,6 +952,15 @@ pub struct Items {
pub inner: Vec<RealItem>,
}

/// A collection of information on Exchange folders.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/folders-ex15websvcsotherref>
#[derive(Clone, Debug, Deserialize)]
pub struct Folders {
#[serde(rename = "$value", default)]
pub inner: Vec<Folder>,
}

/// An item which may appear as the result of a request to read or modify an
/// Exchange item.
///
Expand Down
6 changes: 3 additions & 3 deletions src/types/create_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use serde::Deserialize;
use xml_struct::XmlSerialize;

use crate::{
types::sealed::EnvelopeBodyContents, BaseFolderId, Folder, Operation, OperationResponse,
ResponseClass, ResponseCode, MESSAGES_NS_URI,
types::sealed::EnvelopeBodyContents, BaseFolderId, Folder, Folders, Operation,
OperationResponse, ResponseClass, ResponseCode, MESSAGES_NS_URI,
};

/// A request to create a new folder.
Expand Down Expand Up @@ -65,5 +65,5 @@ pub struct CreateFolderResponseMessage {

pub message_text: Option<String>,

pub folders: Vec<Folder>,
pub folders: Folders,
}
11 changes: 1 addition & 10 deletions src/types/get_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::Deserialize;
use xml_struct::XmlSerialize;

use crate::{
types::sealed::EnvelopeBodyContents, BaseFolderId, Folder, FolderShape, Operation,
types::sealed::EnvelopeBodyContents, BaseFolderId, FolderShape, Folders, Operation,
OperationResponse, ResponseClass, ResponseCode, MESSAGES_NS_URI,
};

Expand Down Expand Up @@ -78,12 +78,3 @@ pub struct GetFolderResponseMessage {
/// A collection of the retrieved folders.
pub folders: Folders,
}

/// A collection of information on Exchange folders.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/folders-ex15websvcsotherref>
#[derive(Clone, Debug, Deserialize)]
pub struct Folders {
#[serde(rename = "$value")]
pub inner: Vec<Folder>,
}
Loading