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

Add support for SyncFolderItems and partial support for GetItem #7

Merged
merged 7 commits into from
May 9, 2024

Conversation

leftmostcat
Copy link
Collaborator

The Item type only currently has support for Messages, so GetItem requests for non-Message items will fail during deserialization.

This is still missing a fair bit of documentation.

The Item type only currently has support for Messages, so GetItem
requests for non-Message items will fail during deserialization.
@babolivier babolivier self-requested a review May 7, 2024 15:49
Comment on lines +614 to +653
/// An identifier for the attachment.
attachment_id: AttachmentId,

/// The name of the attachment.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/name-attachmenttype>
name: String,

/// The MIME type of the attachment's content.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/contenttype>
content_type: String,

/// An arbitrary identifier for the attachment.
///
/// This field is not set by Exchange and is intended for use by
/// external applications.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/contentid>
content_id: Option<String>,

/// A URI representing the location of the attachment's content.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/contentlocation>
content_location: Option<String>,

/// The size of the attachment's content in bytes.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/size>
size: Option<usize>,

/// The most recent modification time for the attachment.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/lastmodifiedtime>
last_modified_time: Option<DateTime>,

/// Whether the attachment appears inline in the item body.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/isinline>
is_inline: Option<bool>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here and several other places, we should really be using a common struct and serde(flatten), but I tried a version of that here and couldn't make serde happy.

is_inline: Option<bool>,
// XXX: With this field in place, parsing will fail if there is no
// `AttachmentItem` in the response.
// See https://github.com/tafia/quick-xml/issues/683
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put up a PR to address this issue, but it's bumping up against another issue. Talking with a maintainer in hopes of sorting it all out.

@leftmostcat
Copy link
Collaborator Author

A few issues/questions for discussion/future work:

quick-xml bug

This affects deserialization of elements which contain elements with a namespace prefix and also elements drawn from an xs:choice (which we try to represent as enums). Discussing the best path to a fix with the maintainer.

Common structs with flattening

#8

Logging versus error handling

Right now, we have a warn log and a debug log. Ultimately, it's not clear whether we should be logging here at all, and it might be beneficial to bubble up the serde_path_to_error error for consumers.

File organization

Right now, there are files for each operation/response pair, which I think is reasonable. Less reasonable is how the rest of the types shake out. Most of them aren't operation-specific in any documented fashion, so relying on operation organization for these isn't reasonable. But having them all lumped into a single file isn't great either. Microsoft groups types by sub-schema, which is pretty specific to how their protocols are structured, but maybe it makes sense.

Documentation

I mentioned this PR is missing a lot, then added a bunch more, and it's still missing a lot. There are a lot of fields here to document, and it's a lot of work, but it's also valuable to have this in generated docs. How much is enough? Do we just need to bear down and write it out? How will that play out if we want to generate a schema from WSDL/XSD?

Copy link
Member

@babolivier babolivier left a comment

Choose a reason for hiding this comment

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

On error handling, I think it would be beneficial to bubble up the serde_path_to_error to consumer. If we have already concluded that the original error is of little or no value (which we have), then the consumer is unlikely to find said value in it.

On file organisation, I do agree that we should avoid common.rs becoming too large. I'm not sure what would be a good structure, but if Microsoft already has one then I think it would make sense to mimic it. It's fine if it's specific to their protocol, since that's what we're implementing here.

src/types/common.rs Show resolved Hide resolved
src/types/common.rs Show resolved Hide resolved
src/types/common.rs Show resolved Hide resolved
src/types/common.rs Show resolved Hide resolved
src/types/common.rs Show resolved Hide resolved
src/types/get_item.rs Show resolved Hide resolved
src/types/soap.rs Outdated Show resolved Hide resolved
src/types/sync_folder_items.rs Show resolved Hide resolved
src/types/soap.rs Outdated Show resolved Hide resolved
src/types/soap.rs Outdated Show resolved Hide resolved
@leftmostcat leftmostcat requested a review from babolivier May 8, 2024 19:40
Copy link
Member

@babolivier babolivier left a comment

Choose a reason for hiding this comment

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

Looks good to me. I've got one nitpicky-ish comment that I'd like addressed before merging (so we don't lose context after this PR lands); once this is addressed feel free to merge.

Edit: Linking the comment in question because apparently GitHub didn't link it with my review: #7 (comment)

@leftmostcat leftmostcat merged commit d55eab6 into main May 9, 2024
2 checks passed
@leftmostcat leftmostcat deleted the add-item-fetching branch May 9, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants