From a6bc2f219666659c7bfb25651fe1f8ba06521a72 Mon Sep 17 00:00:00 2001 From: hiteshrepo Date: Fri, 19 Jan 2024 21:33:38 +0530 Subject: [PATCH] checks nil for events attiributes before setting --- src/go.mod | 2 +- src/go.sum | 4 ++-- .../m365/collection/exchange/transform.go | 23 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/go.mod b/src/go.mod index 3b6247c6f..c9ce92d83 100644 --- a/src/go.mod +++ b/src/go.mod @@ -25,7 +25,7 @@ require ( github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 github.com/jhillyerd/enmime v1.1.0 github.com/kopia/kopia v0.15.0 - github.com/microsoft/kiota-abstractions-go v1.5.4 + github.com/microsoft/kiota-abstractions-go v1.5.5 github.com/microsoft/kiota-authentication-azure-go v1.0.1 github.com/microsoft/kiota-http-go v1.1.1 github.com/microsoft/kiota-serialization-form-go v1.0.0 diff --git a/src/go.sum b/src/go.sum index dce2e5bfd..3fee23a27 100644 --- a/src/go.sum +++ b/src/go.sum @@ -197,8 +197,8 @@ github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvls github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/microsoft/kiota-abstractions-go v1.5.4 h1:ljOnE7BBT94xUIFQwzBZVJj2Udh///7/DCGBBRTvcIs= -github.com/microsoft/kiota-abstractions-go v1.5.4/go.mod h1:PcgbR/QXB3EePCbP1OM4Hhk1R9a033D4K/gC3ltHv2w= +github.com/microsoft/kiota-abstractions-go v1.5.5 h1:ofdQd5b42KzSDJhc11qFeddVd2GIh0FyiGYhUUSLO00= +github.com/microsoft/kiota-abstractions-go v1.5.5/go.mod h1:PcgbR/QXB3EePCbP1OM4Hhk1R9a033D4K/gC3ltHv2w= github.com/microsoft/kiota-authentication-azure-go v1.0.1 h1:F4HH+2QQHSecQg50gVEZaUcxA8/XxCaC2oOMYv2gTIM= github.com/microsoft/kiota-authentication-azure-go v1.0.1/go.mod h1:IbifJeoi+sULI0vjnsWYSmDu5atFo/4FZ6WCoAkPjsc= github.com/microsoft/kiota-http-go v1.1.1 h1:W4Olo7Z/MwNZCfkcvH/5eLhnn7koRBMMRhLEnf5MPKo= diff --git a/src/internal/m365/collection/exchange/transform.go b/src/internal/m365/collection/exchange/transform.go index 5b9514874..e7c4d1a0d 100644 --- a/src/internal/m365/collection/exchange/transform.go +++ b/src/internal/m365/collection/exchange/transform.go @@ -91,18 +91,17 @@ func toEventSimplified(orig models.Eventable) models.Eventable { origBody := orig.GetBody() newContent := insertStringToBody(origBody, attendees) newBody := models.NewItemBody() - newBody.SetContentType(origBody.GetContentType()) - newBody.SetOdataType(origBody.GetOdataType()) + + if origBody.GetContentType() != nil { + newBody.SetContentType(origBody.GetContentType()) + } + + if origBody.GetOdataType() != nil { + newBody.SetOdataType(origBody.GetOdataType()) + } + newBody.SetContent(&newContent) orig.SetBody(newBody) - // Sanitation steps for Events - // See: https://github.com/alcionai/corso/issues/2490 - orig.SetTransactionId(nil) - orig.SetWebLink(nil) - orig.SetICalUId(nil) - orig.SetId(nil) - orig.SetOdataType(nil) - orig.SetChangeKey(nil) // Additional fields that don't have API support but are ignored by the // server. @@ -112,7 +111,9 @@ func toEventSimplified(orig models.Eventable) models.Eventable { delete(additionalData, key) } - orig.SetAdditionalData(additionalData) + if additionalData != nil { + orig.SetAdditionalData(additionalData) + } // Sanitize recurrence timezone. if orig.GetRecurrence() != nil {