## Description Add size to all objects. Not adding them to the output of details view. ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * https://github.com/alcionai/corso/issues/1366 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
83 lines
1.9 KiB
Go
83 lines
1.9 KiB
Go
package exchange
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
|
|
"github.com/alcionai/corso/src/internal/common"
|
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
|
)
|
|
|
|
// EventInfo searchable metadata for stored event objects.
|
|
func EventInfo(evt models.Eventable, size int64) *details.ExchangeInfo {
|
|
var (
|
|
organizer, subject string
|
|
recurs bool
|
|
start = time.Time{}
|
|
end = time.Time{}
|
|
created = time.Time{}
|
|
modified = time.Time{}
|
|
)
|
|
|
|
if evt.GetOrganizer() != nil &&
|
|
evt.GetOrganizer().GetEmailAddress() != nil &&
|
|
evt.GetOrganizer().GetEmailAddress().GetAddress() != nil {
|
|
organizer = *evt.GetOrganizer().
|
|
GetEmailAddress().
|
|
GetAddress()
|
|
}
|
|
|
|
if evt.GetSubject() != nil {
|
|
subject = *evt.GetSubject()
|
|
}
|
|
|
|
if evt.GetRecurrence() != nil {
|
|
recurs = true
|
|
}
|
|
|
|
if evt.GetStart() != nil &&
|
|
evt.GetStart().GetDateTime() != nil {
|
|
// timeString has 'Z' literal added to ensure the stored
|
|
// DateTime is not: time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)
|
|
startTime := *evt.GetStart().GetDateTime() + "Z"
|
|
|
|
output, err := common.ParseTime(startTime)
|
|
if err == nil {
|
|
start = output
|
|
}
|
|
}
|
|
|
|
if evt.GetEnd() != nil &&
|
|
evt.GetEnd().GetDateTime() != nil {
|
|
// timeString has 'Z' literal added to ensure the stored
|
|
// DateTime is not: time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)
|
|
endTime := *evt.GetEnd().GetDateTime() + "Z"
|
|
|
|
output, err := common.ParseTime(endTime)
|
|
if err == nil {
|
|
end = output
|
|
}
|
|
}
|
|
|
|
if evt.GetCreatedDateTime() != nil {
|
|
created = *evt.GetCreatedDateTime()
|
|
}
|
|
|
|
if evt.GetLastModifiedDateTime() != nil {
|
|
modified = *evt.GetLastModifiedDateTime()
|
|
}
|
|
|
|
return &details.ExchangeInfo{
|
|
ItemType: details.ExchangeEvent,
|
|
Organizer: organizer,
|
|
Subject: subject,
|
|
EventStart: start,
|
|
EventEnd: end,
|
|
EventRecurs: recurs,
|
|
Created: created,
|
|
Modified: modified,
|
|
Size: size,
|
|
}
|
|
}
|