GC: Backup: ItemAttachment Complete (#2358)

## Description
Bug fix: Ensures that `item.Attachment` content is completely backed up.

- Exchange 
Changes affect the behavior of Mail and Events. Downloads can be potentially bigger if the user have these types of attachments.

- `item.Attachments` are specific to Outlook objects such as `Events` or `Messages` are included as an attachment rather than inline.  

<!-- Insert PR description-->

## Does this PR need a docs update or release note?

- [x]  Yes, it's included

## Type of change
- [x] 🐛 Bugfix


## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* related to  #2353<issue>

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
This commit is contained in:
Danny 2023-02-01 16:07:14 -05:00 committed by GitHub
parent 24c918e99c
commit 93e8b67d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -108,7 +108,14 @@ func (c Events) GetItem(
return nil, nil, err
}
var errs *multierror.Error
var (
errs *multierror.Error
options = &users.ItemEventsItemAttachmentsRequestBuilderGetRequestConfiguration{
QueryParameters: &users.ItemEventsItemAttachmentsRequestBuilderGetQueryParameters{
Expand: []string{"microsoft.graph.itemattachment/item"},
},
}
)
if *event.GetHasAttachments() || HasAttachments(event.GetBody()) {
for count := 0; count < numberOfRetries; count++ {
@ -117,7 +124,7 @@ func (c Events) GetItem(
UsersById(user).
EventsById(itemID).
Attachments().
Get(ctx, nil)
Get(ctx, options)
if err == nil {
event.SetAttachments(attached.GetValue())
break

View File

@ -130,13 +130,18 @@ func (c Mail) GetItem(
var errs *multierror.Error
if *mail.GetHasAttachments() || HasAttachments(mail.GetBody()) {
options := &users.ItemMessagesItemAttachmentsRequestBuilderGetRequestConfiguration{
QueryParameters: &users.ItemMessagesItemAttachmentsRequestBuilderGetQueryParameters{
Expand: []string{"microsoft.graph.itemattachment/item"},
},
}
for count := 0; count < numberOfRetries; count++ {
attached, err := c.largeItem.
Client().
UsersById(user).
MessagesById(itemID).
Attachments().
Get(ctx, nil)
Get(ctx, options)
if err == nil {
mail.SetAttachments(attached.GetValue())
break