get nested data
This commit is contained in:
parent
3d8f9e40ab
commit
a227d58094
@ -228,22 +228,24 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
// return ptr.Val(folder.GetId())
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: "Test Mail: Hydrated Item Attachment Mail One Attach",
|
||||
// bytes: exchMock.MessageWithNestedItemAttachmentMail(t,
|
||||
// exchMock.MessageWithDirectAttachment("Item Attachment Included"),
|
||||
// "Mail Item Attachment",
|
||||
// ),
|
||||
// category: path.EmailCategory,
|
||||
// destination: func(t *testing.T, ctx context.Context) string {
|
||||
// folderName := tester.DefaultTestRestoreDestination("mailnestattch").ContainerName
|
||||
// folder, err := handlers[path.EmailCategory].
|
||||
// CreateContainer(ctx, userID, folderName, "")
|
||||
// require.NoError(t, err, clues.ToCore(err))
|
||||
// vales here////
|
||||
{
|
||||
name: "Test Mail: Hydrated Item Attachment Mail One Attach",
|
||||
bytes: exchMock.MessageWithNestedItemAttachmentMail(t,
|
||||
exchMock.MessageWithDirectAttachment("Item Attachment Included"),
|
||||
"Mail Item Attachment",
|
||||
),
|
||||
category: path.EmailCategory,
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := tester.DefaultTestRestoreDestination("mailnestattch").ContainerName
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, folderName, "")
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// return ptr.Val(folder.GetId())
|
||||
// },
|
||||
// },
|
||||
return ptr.Val(folder.GetId())
|
||||
},
|
||||
},
|
||||
// end here
|
||||
{
|
||||
name: "Test Mail: Item Attachment_Contact",
|
||||
bytes: exchMock.MessageWithNestedItemAttachmentContact(t,
|
||||
@ -260,19 +262,19 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
return ptr.Val(folder.GetId())
|
||||
},
|
||||
},
|
||||
{ // Restore will upload the Message without uploading the attachment
|
||||
name: "Test Mail: Item Attachment_NestedEvent",
|
||||
bytes: exchMock.MessageWithNestedItemAttachmentEvent("Nested Item Attachment"),
|
||||
category: path.EmailCategory,
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := tester.DefaultTestRestoreDestination("nestedattch").ContainerName
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, folderName, "")
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
// { // Restore will upload the Message without uploading the attachment
|
||||
// name: "Test Mail: Item Attachment_NestedEvent",
|
||||
// bytes: exchMock.MessageWithNestedItemAttachmentEvent("Nested Item Attachment"),
|
||||
// category: path.EmailCategory,
|
||||
// destination: func(t *testing.T, ctx context.Context) string {
|
||||
// folderName := tester.DefaultTestRestoreDestination("nestedattch").ContainerName
|
||||
// folder, err := handlers[path.EmailCategory].
|
||||
// CreateContainer(ctx, userID, folderName, "")
|
||||
// require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
},
|
||||
},
|
||||
// return ptr.Val(folder.GetId())
|
||||
// },
|
||||
// },
|
||||
{
|
||||
name: "Test Mail: One Large Attachment",
|
||||
bytes: exchMock.MessageWithLargeAttachment("Restore Large Attachment"),
|
||||
|
||||
@ -210,26 +210,26 @@ func toItemAttachment(orig models.Attachmentable) (models.Attachmentable, error)
|
||||
}
|
||||
|
||||
// TODO #2428 (dadam39): re-apply nested attachments for itemAttachments
|
||||
// func sanitizeAttachments(attached []models.Attachmentable) ([]models.Attachmentable, error) {
|
||||
// attachments := make([]models.Attachmentable, len(attached))
|
||||
func sanitizeAttachments(attached []models.Attachmentable) ([]models.Attachmentable, error) {
|
||||
attachments := make([]models.Attachmentable, len(attached))
|
||||
|
||||
// for _, ax := range attached {
|
||||
// if ptr.Val(ax.GetOdataType()) == itemAttachment {
|
||||
// newAttachment, err := ToItemAttachment(ax)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
for _, ax := range attached {
|
||||
if ptr.Val(ax.GetOdataType()) == itemAttachment {
|
||||
newAttachment, err := toItemAttachment(ax)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// attachments = append(attachments, newAttachment)
|
||||
attachments = append(attachments, newAttachment)
|
||||
|
||||
// continue
|
||||
// }
|
||||
continue
|
||||
}
|
||||
|
||||
// attachments = append(attachments, ax)
|
||||
// }
|
||||
attachments = append(attachments, ax)
|
||||
}
|
||||
|
||||
// return attachments, nil
|
||||
// }
|
||||
return attachments, nil
|
||||
}
|
||||
|
||||
// sanitizeContact removes fields which prevent a Contact from
|
||||
// being uploaded as an attachment.
|
||||
@ -280,11 +280,11 @@ func sanitizeEvent(orig models.Eventable) (models.Eventable, error) {
|
||||
|
||||
// TODO #2428 (dadam39): re-apply nested attachments for itemAttachments
|
||||
// Upstream: https://github.com/microsoft/kiota-serialization-json-go/issues/61
|
||||
// attachments, err := sanitizeAttachments(message.GetAttachments())
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
newEvent.SetAttachments(nil)
|
||||
attachments, err := sanitizeAttachments(orig.GetAttachments())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newEvent.SetAttachments(attachments)
|
||||
|
||||
return newEvent, nil
|
||||
}
|
||||
@ -294,11 +294,11 @@ func sanitizeMessage(orig models.Messageable) (models.Messageable, error) {
|
||||
|
||||
// TODO #2428 (dadam39): re-apply nested attachments for itemAttachments
|
||||
// Upstream: https://github.com/microsoft/kiota-serialization-json-go/issues/61
|
||||
// attachments, err := sanitizeAttachments(message.GetAttachments())
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
message.SetAttachments(nil)
|
||||
attachments, err := sanitizeAttachments(message.GetAttachments())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
message.SetAttachments(attachments)
|
||||
|
||||
// The following fields are set to nil to
|
||||
// not interfere with M365 guard checks.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user