Reputation: 395
My objective is to confirm that a message deleted by user has indeed landed in "Deleted Items" folder.
I have a subscription that notifies me for changeType = deleted. With this subscription I get a notification like this -
{
u '@odata.type': u '#microsoft.graph.message',
u '@removed': {
u 'reason': u 'deleted'
},
u 'id': u 'AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AQ4KiMeupd0KGRfRTWvssWQAAZpGrnAAA'
}
I then take this message id, and query the server to get the message. I hoped that the parent folder id in the message will tell me if the message was moved to "Deleted Items" folder
https://graph.microsoft.com/v1.0/me/messages/AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AQ4KiMeupd0KGRfRTWvssWQAAZpGrnAAA
This API succeeds and I get a response back with message object. However the parentFolderId value is invalid - i.e. it does not match with any existing folder ids that I get from https://graph.microsoft.com/v1.0/me/mailFolders
Has anyone faced such issue? On getting a notification for deletion, how can I confirm that the message has indeed landed in the "Deleted Items"
Appreciate all the help.
Thanks.
Upvotes: 0
Views: 718
Reputation: 17702
Have you tried getting the folder using that ID to verify it is invalid?
I just did some testing here, and the result is going to depend on how the user deleted the item.
If they just pressed "Delete" (or used the delete button in the UI, etc.), it would be moved to Deleted Items. In this case, you get a deleted
notification, and the parentFolderId
coincides with Deleted Items.
If they pressed SHIFT+DELETE, the client asks to confirm if you want to "permanently delete" the item. If they're set up with deleted items retention (which is on by default), then it isn't really permanently deleted. It's copied to a special folder so that the user can restore it within the configured undo period (30 days is the default I believe). In this case, the parentFolderId
coincides with this special folder. Using Graph Explorer, I see this when I do a GET /me/mailfolders/{id}
:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('deeb074f-40b0-4a1f-a471-7baab44c0026')/mailFolders/$entity",
"id": "AQMkAGUyN2I4N2RlLTEzMTAtNDBmYy1hODdlLTY2ADU0MDgxNjBhMGYALgAAAzYn1Af8O8xErekG37ysDqcBAK48gWNswSROgdxWdCKszmoAAAIBHQAAAA==",
"displayName": "Deletions",
"parentFolderId": "AQMkAGUyN2I4N2RlLTEzMTAtNDBmYy1hODdlLTY2ADU0MDgxNjBhMGYALgAAAzYn1Af8O8xErekG37ysDqcBAK48gWNswSROgdxWdCKszmoAAAIBGwAAAA==",
"childFolderCount": 0,
"unreadItemCount": 1,
"totalItemCount": 1
}
Upvotes: 2