Skip to content

Fix folder type restriction#156

Merged
idolum merged 1 commit into
otris:masterfrom
SebastianBecker2:folder-type-fix
Nov 21, 2019
Merged

Fix folder type restriction#156
idolum merged 1 commit into
otris:masterfrom
SebastianBecker2:folder-type-fix

Conversation

@SebastianBecker2

Copy link
Copy Markdown
Contributor

When parsing SyncFolderHierarchy response the child element had to be
"Folder". Which is not the case for non mail folders like calendar
folders or contact folders. Now it accepts any kind of child element,
expecting it to have a folder_id inside.

One of our customers had a calendar folder in his inbox. Not sure how.
Neither Outlook nor OWA allows the creation of a non-mail folder in
inbox.
Though I did manage to reproduce it using Microsofts EwsEditor.

When parsing SyncFolderHierarchy response the child element had to be
"Folder". Which is not the case for non mail folders like calendar
folders or contact folders. Now it accepts any kind of child element,
expecting it to have a folder_id inside.
@idolum idolum self-assigned this Oct 29, 2019
@idolum idolum requested review from idolum and removed request for idolum October 29, 2019 15:21
@idolum

idolum commented Oct 29, 2019

Copy link
Copy Markdown
Member

@SebastianBecker2 You mean a CalendarFolder? This seems to be allowed here:

https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/create-foldersync

As well as ContactsFolder, SearchFolder and TasksFolder. Would be better to check for all of these five different types instead of accepting every element.

@SebastianBecker2

Copy link
Copy Markdown
Contributor Author

That would definitely be possible.
But since we treat them all the same... I just tried to make it work asap.

Do you have a good idea on how to do it?
Get the first nodes name and check it against the list of possible names?

@SebastianBecker2

Copy link
Copy Markdown
Contributor Author

As a side note: The reason I was so surprised that the users inbox had a CalendarFolder was that it isn't possible to do this in Outlook. Or at least I couldn't find a way to do this.
To test it, I had to create one with Microsofts EwsEditor.

@idolum

idolum commented Nov 5, 2019

Copy link
Copy Markdown
Member

What about something like this? (Just an outline. Haven't tested it yet):

    //! Utility function for finding the first node of
    //! a list of names.
    //! \param elem XML node the node should retrieved from
    //! \param node_names Names of requested nodes
    //! \returns Pointer to found XML node
    inline rapidxml::xml_node<>* find_first_node_of_ns(
        const rapidxml::xml_node<>& elem,
        const Ch* namespace,
        const std::vector<std::string>& node_names)
    {
        using namespace rapidxml;

        xml_node<>* result;

        for (auto name : node_names)
        {
            result = elem.first_node_ns(namespace, name);
            if (result)
            {
                return result;
            }
        }

        return result;
    }

Then it is possible to retrieve several node types:

std::vector<std::string> elem_list = { "Folder",
    "ContactsFolder", "SearchFolder", "TaskFolder" };
const auto folder_elem = item_elem.find_first_node_of_ns(
                    internal::uri<>::microsoft::types(), elem_list);
check(folder_elem,
   "Expected <Folder>, <ContactsFolder>, <SearchFolder> or <TaskFolder> element");

@idolum

idolum commented Nov 21, 2019

Copy link
Copy Markdown
Member

Tests were fine. Checking will be improved in #161

@idolum idolum merged commit c828730 into otris:master Nov 21, 2019
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