Compare commits

...

4 Commits

Author SHA1 Message Date
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
4 changed files with 54 additions and 44 deletions

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

@ -211,38 +211,39 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
return ptr.Val(folder.GetId())
},
},
{
name: "Test Mail: Hydrated Item Attachment Mail",
bytes: exchMock.MessageWithNestedItemAttachmentMail(t,
exchMock.MessageBytes("Basic Item Attachment"),
"Mail Item Attachment",
),
category: path.EmailCategory,
destination: func(t *testing.T, ctx context.Context) string {
folderName := tester.DefaultTestRestoreDestination("mailbasicattch").ContainerName
folder, err := handlers[path.EmailCategory].
CreateContainer(ctx, userID, folderName, "")
require.NoError(t, err, clues.ToCore(err))
// TODO: Neha complete as part of https://github.com/alcionai/corso/issues/2428
// {
// name: "Test Mail: Hydrated Item Attachment Mail",
// bytes: exchMock.MessageWithNestedItemAttachmentMail(t,
// exchMock.MessageBytes("Basic Item Attachment"),
// "Mail Item Attachment",
// ),
// category: path.EmailCategory,
// destination: func(t *testing.T, ctx context.Context) string {
// folderName := tester.DefaultTestRestoreDestination("mailbasicattch").ContainerName
// folder, err := handlers[path.EmailCategory].
// CreateContainer(ctx, userID, folderName, "")
// require.NoError(t, err, clues.ToCore(err))
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))
// 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))
return ptr.Val(folder.GetId())
},
},
// return ptr.Val(folder.GetId())
// },
// },
{
name: "Test Mail: Item Attachment_Contact",
bytes: exchMock.MessageWithNestedItemAttachmentContact(t,

View File

@ -334,18 +334,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(clues.Wrap(err, "uploading mail attachment").WithClues(ctx))
}
}

View File

@ -257,7 +257,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())