Compare commits

...

10 Commits

Author SHA1 Message Date
neha_gupta
93e1519ae7
Merge branch 'main' into nestedAttachment 2023-06-27 13:13:32 +05:30
neha-Gupta1
08e707aa26 resolve lint issues 2023-06-26 16:04:16 +05:30
neha-Gupta1
10f06e6434 update msgraph-sdk-go to v1.8 2023-06-26 12:07:20 +05:30
neha-Gupta1
0c69289b41 merge main 2023-06-19 11:14:21 +05:30
neha-Gupta1
cb621bb359 Merge branch 'main' of https://github.com/alcionai/corso into nestedAttachment 2023-06-06 15:44:37 +05:30
neha-Gupta1
a227d58094 get nested data 2023-06-06 15:43:39 +05:30
neha-Gupta1
3d8f9e40ab move isNil func to common/prt 2023-06-02 11:33:18 +05:30
neha-Gupta1
e739ef5d4f merge main 2023-06-02 11:23:21 +05:30
neha_gupta
1ec8995f7f
Merge branch 'main' into itemAttachment 2023-06-01 15:58:02 +05:30
neha-Gupta1
eb3b9a88c8 pass location to attachment only if value present 2023-06-01 15:55:05 +05:30
7 changed files with 57 additions and 50 deletions

View File

@ -19,7 +19,7 @@ require (
github.com/microsoft/kiota-http-go v1.0.0
github.com/microsoft/kiota-serialization-form-go v1.0.0
github.com/microsoft/kiota-serialization-json-go v1.0.2
github.com/microsoftgraph/msgraph-sdk-go v1.4.0
github.com/microsoftgraph/msgraph-sdk-go v1.8.0
github.com/microsoftgraph/msgraph-sdk-go-core v1.0.0
github.com/pkg/errors v0.9.1
github.com/rudderlabs/analytics-go v3.3.3+incompatible
@ -59,7 +59,7 @@ require (
)
require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect

View File

@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
@ -285,8 +285,8 @@ github.com/microsoft/kiota-serialization-json-go v1.0.2 h1:RXan8v7yWBD88XxVZ2W38
github.com/microsoft/kiota-serialization-json-go v1.0.2/go.mod h1:AUItT9exyxmjZQE8IeFD9ygP77q9GKVb+AQE2V5Ikho=
github.com/microsoft/kiota-serialization-text-go v1.0.0 h1:XOaRhAXy+g8ZVpcq7x7a0jlETWnWrEum0RhmbYrTFnA=
github.com/microsoft/kiota-serialization-text-go v1.0.0/go.mod h1:sM1/C6ecnQ7IquQOGUrUldaO5wj+9+v7G2W3sQ3fy6M=
github.com/microsoftgraph/msgraph-sdk-go v1.4.0 h1:ibNwMDEZ6HikA9BVXu+TljCzCiE+yFsD6wLpJbTc1tc=
github.com/microsoftgraph/msgraph-sdk-go v1.4.0/go.mod h1:JIDL1xENx92B60NjO2ACyqGeKvtYkdl9rirgajIgryw=
github.com/microsoftgraph/msgraph-sdk-go v1.8.0 h1:jiEL5Ae5ANI+7vfbTYLGWkDvvdrsLdGLh+N4/n8cbEQ=
github.com/microsoftgraph/msgraph-sdk-go v1.8.0/go.mod h1:QWcsMal5VYnd1iN0AUnrEe6lsCU0iYZguS0e3Rl77/A=
github.com/microsoftgraph/msgraph-sdk-go-core v1.0.0 h1:7NWTfyXvOjoizW7PmxNp3+8wCKPgpODs/D1cUZ3fkAY=
github.com/microsoftgraph/msgraph-sdk-go-core v1.0.0/go.mod h1:tQb4q3YMIj2dWhhXhQSJ4ELpol931ANKzHSYK5kX1qE=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=

View File

@ -1,6 +1,9 @@
package ptr
import "time"
import (
"reflect"
"time"
)
// ptr package is a common package used for pointer
// access and deserialization.
@ -50,3 +53,17 @@ func OrNow(t *time.Time) time.Time {
func To[T any](t T) *T {
return &t
}
// IsNil check if type provided is nil
func IsNil(i any) bool {
if i == nil {
return true
}
switch reflect.TypeOf(i).Kind() {
case reflect.Ptr, reflect.Map, reflect.Array, reflect.Chan, reflect.Slice:
return reflect.ValueOf(i).IsNil()
}
return false
}

View File

@ -346,18 +346,6 @@ func uploadAttachments(
itemID,
a)
if err != nil {
// FIXME: I don't know why we're swallowing this error case.
// It needs investigation: https://github.com/alcionai/corso/issues/3498
if ptr.Val(a.GetOdataType()) == "#microsoft.graph.itemAttachment" {
name := ptr.Val(a.GetName())
logger.CtxErr(ctx, err).
With("attachment_name", name).
Info("mail upload failed")
continue
}
el.AddRecoverable(ctx, clues.Wrap(err, "uploading mail attachment").WithClues(ctx))
}
}

View File

@ -272,6 +272,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
return ptr.Val(folder.GetId())
},
},
// failure Test start
{ // Restore will upload the Message without uploading the attachment
name: "Test Mail: Item Attachment_NestedEvent",
bytes: exchMock.MessageWithNestedItemAttachmentEvent("Nested Item Attachment"),
@ -285,6 +286,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
return ptr.Val(folder.GetId())
},
},
// test end
{
name: "Test Mail: One Large Attachment",
bytes: exchMock.MessageWithLargeAttachment("Restore Large Attachment"),

View File

@ -217,26 +217,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.
@ -264,7 +264,11 @@ func sanitizeEvent(orig models.Eventable) (models.Eventable, error) {
newEvent.SetImportance(orig.GetImportance())
newEvent.SetIsAllDay(orig.GetIsAllDay())
newEvent.SetIsOnlineMeeting(orig.GetIsOnlineMeeting())
newEvent.SetLocation(orig.GetLocation())
if !ptr.IsNil(orig.GetLocation()) {
newEvent.SetLocation(orig.GetLocation())
}
newEvent.SetLocations(orig.GetLocations())
newEvent.SetSensitivity(orig.GetSensitivity())
newEvent.SetReminderMinutesBeforeStart(orig.GetReminderMinutesBeforeStart())
@ -281,28 +285,24 @@ func sanitizeEvent(orig models.Eventable) (models.Eventable, error) {
newEvent.SetIsDraft(nil)
newEvent.SetAdditionalData(orig.GetAdditionalData())
// 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
}
func sanitizeMessage(orig models.Messageable) (models.Messageable, error) {
message := toMessage(orig)
attachments, err := sanitizeAttachments(message.GetAttachments())
// 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)
if err != nil {
return nil, err
}
message.SetAttachments(attachments)
// The following fields are set to nil to
// not interfere with M365 guard checks.
message.SetHasAttachments(nil)

View File

@ -334,7 +334,7 @@ func errData(err odataerrors.ODataErrorable) (string, []any, string) {
msgConcat += ptr.Val(d.GetMessage())
}
inner := mainErr.GetInnererror()
inner := mainErr.GetInnerError()
if inner != nil {
data = appendIf(data, "odataerror_inner_cli_req_id", inner.GetClientRequestId())
data = appendIf(data, "odataerror_inner_req_id", inner.GetRequestId())