get nested data

This commit is contained in:
neha-Gupta1 2023-06-06 15:43:39 +05:30
parent 3d8f9e40ab
commit a227d58094
2 changed files with 54 additions and 52 deletions

View File

@ -228,22 +228,24 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
// return ptr.Val(folder.GetId()) // return ptr.Val(folder.GetId())
// }, // },
// }, // },
// { // vales here////
// name: "Test Mail: Hydrated Item Attachment Mail One Attach", {
// bytes: exchMock.MessageWithNestedItemAttachmentMail(t, name: "Test Mail: Hydrated Item Attachment Mail One Attach",
// exchMock.MessageWithDirectAttachment("Item Attachment Included"), bytes: exchMock.MessageWithNestedItemAttachmentMail(t,
// "Mail Item Attachment", exchMock.MessageWithDirectAttachment("Item Attachment Included"),
// ), "Mail Item Attachment",
// category: path.EmailCategory, ),
// destination: func(t *testing.T, ctx context.Context) string { category: path.EmailCategory,
// folderName := tester.DefaultTestRestoreDestination("mailnestattch").ContainerName destination: func(t *testing.T, ctx context.Context) string {
// folder, err := handlers[path.EmailCategory]. folderName := tester.DefaultTestRestoreDestination("mailnestattch").ContainerName
// CreateContainer(ctx, userID, folderName, "") folder, err := handlers[path.EmailCategory].
// require.NoError(t, err, clues.ToCore(err)) 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", name: "Test Mail: Item Attachment_Contact",
bytes: exchMock.MessageWithNestedItemAttachmentContact(t, bytes: exchMock.MessageWithNestedItemAttachmentContact(t,
@ -260,19 +262,19 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
return ptr.Val(folder.GetId()) return ptr.Val(folder.GetId())
}, },
}, },
{ // Restore will upload the Message without uploading the attachment // { // Restore will upload the Message without uploading the attachment
name: "Test Mail: Item Attachment_NestedEvent", // name: "Test Mail: Item Attachment_NestedEvent",
bytes: exchMock.MessageWithNestedItemAttachmentEvent("Nested Item Attachment"), // bytes: exchMock.MessageWithNestedItemAttachmentEvent("Nested Item Attachment"),
category: path.EmailCategory, // category: path.EmailCategory,
destination: func(t *testing.T, ctx context.Context) string { // destination: func(t *testing.T, ctx context.Context) string {
folderName := tester.DefaultTestRestoreDestination("nestedattch").ContainerName // folderName := tester.DefaultTestRestoreDestination("nestedattch").ContainerName
folder, err := handlers[path.EmailCategory]. // folder, err := handlers[path.EmailCategory].
CreateContainer(ctx, userID, folderName, "") // CreateContainer(ctx, userID, folderName, "")
require.NoError(t, err, clues.ToCore(err)) // require.NoError(t, err, clues.ToCore(err))
return ptr.Val(folder.GetId()) // return ptr.Val(folder.GetId())
}, // },
}, // },
{ {
name: "Test Mail: One Large Attachment", name: "Test Mail: One Large Attachment",
bytes: exchMock.MessageWithLargeAttachment("Restore Large Attachment"), bytes: exchMock.MessageWithLargeAttachment("Restore Large Attachment"),

View File

@ -210,26 +210,26 @@ func toItemAttachment(orig models.Attachmentable) (models.Attachmentable, error)
} }
// TODO #2428 (dadam39): re-apply nested attachments for itemAttachments // TODO #2428 (dadam39): re-apply nested attachments for itemAttachments
// func sanitizeAttachments(attached []models.Attachmentable) ([]models.Attachmentable, error) { func sanitizeAttachments(attached []models.Attachmentable) ([]models.Attachmentable, error) {
// attachments := make([]models.Attachmentable, len(attached)) attachments := make([]models.Attachmentable, len(attached))
// for _, ax := range attached { for _, ax := range attached {
// if ptr.Val(ax.GetOdataType()) == itemAttachment { if ptr.Val(ax.GetOdataType()) == itemAttachment {
// newAttachment, err := ToItemAttachment(ax) newAttachment, err := toItemAttachment(ax)
// if err != nil { if err != nil {
// return nil, err 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 // sanitizeContact removes fields which prevent a Contact from
// being uploaded as an attachment. // 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 // TODO #2428 (dadam39): re-apply nested attachments for itemAttachments
// Upstream: https://github.com/microsoft/kiota-serialization-json-go/issues/61 // Upstream: https://github.com/microsoft/kiota-serialization-json-go/issues/61
// attachments, err := sanitizeAttachments(message.GetAttachments()) attachments, err := sanitizeAttachments(orig.GetAttachments())
// if err != nil { if err != nil {
// return nil, err return nil, err
// } }
newEvent.SetAttachments(nil) newEvent.SetAttachments(attachments)
return newEvent, nil return newEvent, nil
} }
@ -294,11 +294,11 @@ func sanitizeMessage(orig models.Messageable) (models.Messageable, error) {
// TODO #2428 (dadam39): re-apply nested attachments for itemAttachments // TODO #2428 (dadam39): re-apply nested attachments for itemAttachments
// Upstream: https://github.com/microsoft/kiota-serialization-json-go/issues/61 // Upstream: https://github.com/microsoft/kiota-serialization-json-go/issues/61
// attachments, err := sanitizeAttachments(message.GetAttachments()) attachments, err := sanitizeAttachments(message.GetAttachments())
// if err != nil { if err != nil {
// return nil, err return nil, err
// } }
message.SetAttachments(nil) message.SetAttachments(attachments)
// The following fields are set to nil to // The following fields are set to nil to
// not interfere with M365 guard checks. // not interfere with M365 guard checks.