-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Well it might be SO-lije question but I decided to try here first.
My colleage added variant of create_item for forwarding messages - it adds Forwardtem into request.
If you interested I can put his code here.
It works fine but I have problems with very specific scenario.
I am turn off wifi on my device, select letter and forward it. Internet is off so command cannot be perfomed so I keep it for future next try. Meanwhile I open another client on another device and move letter which I wanted to forward, into another folder. Then I turn on wifi on first device and try to forward message once more.
Here I have a choice as a coder - to run delayed commands before syncrhonizing with server or after synchronizing. I am run commands first. My create_item with ForwardItem cannot be fulfilled cause letter is moved and item with given ItemId dont exists any more.
Should I run syncronization first, I am still dunno how to find new itemId of forwarded message.
I am using SyncFolderItems for syncroniztion so I can see that message is deleted from old folder and new message is created in another. But how can I be sure that this is the same message ... I cannot. I just can to delete my forward command cause I see that item I wanted to forward not exist any more.
item_id create_item_impl(const message& the_message, const std::string& fw_message)
{
the_message.get_to_recipients();
std::stringstream sstr;
sstr << "<m:CreateItem MessageDisposition=\"SendAndSaveCopy\">";
sstr << "<m:Items>"
<< "<t:ForwardItem>";
sstr << the_message.get_body().to_xml();
sstr << "<t:ToRecipients>";
for (auto& r: the_message.get_to_recipients()) {
sstr << r.to_xml();
}
sstr << "</t:ToRecipients>";
auto cc = the_message.get_cc_recipients();
if (cc.size()) {
sstr << "<t:CcRecipients>";
for (auto& r: cc) {
sstr << r.to_xml();
}
sstr << "</t:CcRecipients>";
}
auto bcc = the_message.get_bcc_recipients();
if (bcc.size()) {
sstr << "<t:BccRecipients>";
for (auto& r: bcc) {
sstr << r.to_xml();
}
sstr << "</t:BccRecipients>";
}
sstr << "<t:ReferenceItemId Id=\""
<< the_message.get_item_id().id()
<< "\" ChangeKey=\""
<< the_message.get_item_id().change_key()
<< "\" />";
sstr << "</t:ForwardItem>"
<< "</m:Items>"
<< "</m:CreateItem>";
auto response = request(sstr.str());
const auto response_message =
internal::create_item_response_message::parse(std::move(response));
if (!response_message.success())
{
throw exchange_error(response_message.result());
}
return item_id();
}