Cleanup immutable ID config passing (#5013)
This value was present in the control.Options in the struct and passed as a parameter. This PR removes the parameter so it's clear the control.Options one is used --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #5012 #### Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
6e50d5216e
commit
b8b1299514
@ -196,7 +196,6 @@ func populateCollections(
|
||||
cl = counter.Local()
|
||||
itemConfig = api.CallConfig{
|
||||
CanMakeDeltaQueries: !ctrlOpts.ToggleFeatures.DisableDelta,
|
||||
UseImmutableIDs: ctrlOpts.ToggleFeatures.ExchangeImmutableIDs,
|
||||
}
|
||||
cID = ptr.Val(c.GetId())
|
||||
dp = dps[cID]
|
||||
|
||||
@ -57,7 +57,6 @@ func (ig mockItemGetter) GetItem(
|
||||
context.Context,
|
||||
string,
|
||||
string,
|
||||
bool,
|
||||
*fault.Bus,
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error) {
|
||||
return models.NewMessage(), &details.ExchangeInfo{}, nil
|
||||
|
||||
@ -76,7 +76,6 @@ func getItemAndInfo(
|
||||
ctx,
|
||||
userID,
|
||||
id,
|
||||
useImmutableIDs,
|
||||
fault.New(true)) // temporary way to force a failFast error
|
||||
if err != nil {
|
||||
return nil, nil, clues.WrapWC(ctx, err, "fetching item").
|
||||
|
||||
@ -217,7 +217,7 @@ func (suite *CollectionUnitSuite) TestGetItemWithRetries() {
|
||||
defer flush()
|
||||
|
||||
// itemer is mocked, so only the errors are configured atm.
|
||||
_, _, err := test.items.GetItem(ctx, "userID", "itemID", false, fault.New(true))
|
||||
_, _, err := test.items.GetItem(ctx, "userID", "itemID", fault.New(true))
|
||||
test.expectErr(t, err)
|
||||
})
|
||||
}
|
||||
@ -424,11 +424,10 @@ func (mlg *mockLazyItemGetterSerializer) GetItem(
|
||||
ctx context.Context,
|
||||
user string,
|
||||
itemID string,
|
||||
immutableIDs bool,
|
||||
errs *fault.Bus,
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error) {
|
||||
mlg.callIDs = append(mlg.callIDs, itemID)
|
||||
return mlg.ItemGetSerialize.GetItem(ctx, user, itemID, immutableIDs, errs)
|
||||
return mlg.ItemGetSerialize.GetItem(ctx, user, itemID, errs)
|
||||
}
|
||||
|
||||
func (mlg *mockLazyItemGetterSerializer) check(t *testing.T, expectIDs []string) {
|
||||
|
||||
@ -108,8 +108,7 @@ func (cfc *contactContainerCache) Populate(
|
||||
containers, err := cfc.enumer.EnumerateContainers(
|
||||
ctx,
|
||||
cfc.userID,
|
||||
baseID,
|
||||
false)
|
||||
baseID)
|
||||
ctx = clues.Add(ctx, "num_enumerated_containers", len(containers))
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -30,7 +30,6 @@ type containersEnumerator[T any] interface {
|
||||
EnumerateContainers(
|
||||
ctx context.Context,
|
||||
userID, baseDirID string,
|
||||
immutableIDs bool,
|
||||
) ([]T, error)
|
||||
}
|
||||
|
||||
|
||||
@ -82,8 +82,7 @@ func (ecc *eventContainerCache) Populate(
|
||||
containers, err := ecc.enumer.EnumerateContainers(
|
||||
ctx,
|
||||
ecc.userID,
|
||||
"",
|
||||
false)
|
||||
"")
|
||||
ctx = clues.Add(ctx, "num_enumerated_containers", len(containers))
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -211,7 +211,6 @@ type attachmentGetDeletePoster interface {
|
||||
attachmentPoster
|
||||
GetAttachments(
|
||||
ctx context.Context,
|
||||
immutableIDs bool,
|
||||
userID string,
|
||||
itemID string,
|
||||
) ([]models.Attachmentable, error)
|
||||
@ -238,7 +237,7 @@ func updateAttachments(
|
||||
) error {
|
||||
el := errs.Local()
|
||||
|
||||
attachments, err := agdp.GetAttachments(ctx, false, userID, eventID)
|
||||
attachments, err := agdp.GetAttachments(ctx, userID, eventID)
|
||||
if err != nil {
|
||||
return clues.Wrap(err, "getting attachments")
|
||||
}
|
||||
|
||||
@ -75,7 +75,6 @@ func (m *eventRestoreMock) DeleteAttachment(
|
||||
|
||||
func (m *eventRestoreMock) GetAttachments(
|
||||
_ context.Context,
|
||||
_ bool,
|
||||
_, _ string,
|
||||
) ([]models.Attachmentable, error) {
|
||||
return []models.Attachmentable{}, nil
|
||||
|
||||
@ -40,7 +40,6 @@ type itemGetterSerializer interface {
|
||||
GetItem(
|
||||
ctx context.Context,
|
||||
user, itemID string,
|
||||
immutableIDs bool,
|
||||
errs *fault.Bus,
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error)
|
||||
Serialize(
|
||||
|
||||
@ -112,8 +112,7 @@ func (mc *mailContainerCache) Populate(
|
||||
containers, err := mc.enumer.EnumerateContainers(
|
||||
ctx,
|
||||
mc.userID,
|
||||
"",
|
||||
false)
|
||||
"")
|
||||
ctx = clues.Add(ctx, "num_enumerated_containers", len(containers))
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -21,7 +21,6 @@ type ItemGetSerialize struct {
|
||||
func (m *ItemGetSerialize) GetItem(
|
||||
context.Context,
|
||||
string, string,
|
||||
bool,
|
||||
*fault.Bus,
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error) {
|
||||
m.GetCount++
|
||||
|
||||
@ -435,7 +435,7 @@ func (suite *RestoreIntgSuite) TestRestoreAndBackupEvent_recurringInstancesWithA
|
||||
evts := ec.GetValue()
|
||||
assert.Len(t, evts, 1, "count of events")
|
||||
|
||||
sp, info, err := suite.ac.Events().GetItem(ctx, userID, ptr.Val(evts[0].GetId()), false, fault.New(true))
|
||||
sp, info, err := suite.ac.Events().GetItem(ctx, userID, ptr.Val(evts[0].GetId()), fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
assert.NotNil(t, info, "event item info")
|
||||
|
||||
|
||||
@ -387,7 +387,6 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
|
||||
err error
|
||||
aar pagers.AddedAndRemoved
|
||||
cc = api.CallConfig{
|
||||
UseImmutableIDs: toggles.ExchangeImmutableIDs,
|
||||
CanMakeDeltaQueries: true,
|
||||
}
|
||||
)
|
||||
|
||||
@ -171,7 +171,6 @@ type CallConfig struct {
|
||||
Expand []string
|
||||
Select []string
|
||||
CanMakeDeltaQueries bool
|
||||
UseImmutableIDs bool
|
||||
// LimitResults limits the returned results to the given number. If 0, returns
|
||||
// all results.
|
||||
LimitResults int
|
||||
|
||||
@ -185,11 +185,10 @@ func (c Contacts) PatchFolder(
|
||||
func (c Contacts) GetItem(
|
||||
ctx context.Context,
|
||||
userID, itemID string,
|
||||
immutableIDs bool,
|
||||
_ *fault.Bus, // no attachments to iterate over, so this goes unused
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error) {
|
||||
options := &users.ItemContactsContactItemRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
|
||||
cont, err := c.Stable.
|
||||
|
||||
@ -27,11 +27,12 @@ type contactsFoldersPageCtrl struct {
|
||||
|
||||
func (c Contacts) NewContactFoldersPager(
|
||||
userID, baseContainerID string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.NonDeltaHandler[models.ContactFolderable] {
|
||||
options := &users.ItemContactFoldersItemChildFoldersRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
QueryParameters: &users.ItemContactFoldersItemChildFoldersRequestBuilderGetQueryParameters{},
|
||||
// do NOT set Top. It limits the total items received.
|
||||
}
|
||||
@ -70,9 +71,11 @@ func (p *contactsFoldersPageCtrl) ValidModTimes() bool {
|
||||
func (c Contacts) EnumerateContainers(
|
||||
ctx context.Context,
|
||||
userID, baseContainerID string,
|
||||
immutableIDs bool,
|
||||
) ([]models.ContactFolderable, error) {
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewContactFoldersPager(userID, baseContainerID, immutableIDs))
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewContactFoldersPager(
|
||||
userID,
|
||||
baseContainerID))
|
||||
|
||||
return containers, graph.Stack(ctx, err).OrNil()
|
||||
}
|
||||
|
||||
@ -90,11 +93,12 @@ type contactsPageCtrl struct {
|
||||
|
||||
func (c Contacts) NewContactsPager(
|
||||
userID, containerID string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.NonDeltaHandler[models.Contactable] {
|
||||
options := &users.ItemContactFoldersItemContactsRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
QueryParameters: &users.ItemContactFoldersItemContactsRequestBuilderGetQueryParameters{},
|
||||
// do NOT set Top. It limits the total items received.
|
||||
}
|
||||
@ -134,7 +138,7 @@ func (c Contacts) GetItemsInContainerByCollisionKey(
|
||||
userID, containerID string,
|
||||
) (map[string]string, error) {
|
||||
ctx = clues.Add(ctx, "container_id", containerID)
|
||||
pager := c.NewContactsPager(userID, containerID, false, contactCollisionKeyProps()...)
|
||||
pager := c.NewContactsPager(userID, containerID, contactCollisionKeyProps()...)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
@ -155,7 +159,7 @@ func (c Contacts) GetItemIDsInContainer(
|
||||
userID, containerID string,
|
||||
) (map[string]struct{}, error) {
|
||||
ctx = clues.Add(ctx, "container_id", containerID)
|
||||
pager := c.NewContactsPager(userID, containerID, false, idAnd()...)
|
||||
pager := c.NewContactsPager(userID, containerID, idAnd()...)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
@ -204,13 +208,14 @@ func getContactDeltaBuilder(
|
||||
func (c Contacts) NewContactsDeltaPager(
|
||||
ctx context.Context,
|
||||
userID, containerID, prevDeltaLink string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.DeltaHandler[models.Contactable] {
|
||||
options := &users.ItemContactFoldersItemContactsDeltaRequestBuilderGetRequestConfiguration{
|
||||
// do NOT set Top. It limits the total items received.
|
||||
QueryParameters: &users.ItemContactFoldersItemContactsDeltaRequestBuilderGetQueryParameters{},
|
||||
Headers: newPreferHeaders(preferPageSize(c.options.DeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(c.options.DeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
|
||||
if len(selectProps) > 0 {
|
||||
@ -261,12 +266,10 @@ func (c Contacts) GetAddedAndRemovedItemIDs(
|
||||
userID,
|
||||
containerID,
|
||||
prevDeltaLink,
|
||||
config.UseImmutableIDs,
|
||||
idAnd(lastModifiedDateTime)...)
|
||||
pager := c.NewContactsPager(
|
||||
userID,
|
||||
containerID,
|
||||
config.UseImmutableIDs,
|
||||
idAnd(lastModifiedDateTime)...)
|
||||
|
||||
return pagers.GetAddedAndRemovedItemIDs[models.Contactable](
|
||||
|
||||
@ -197,14 +197,13 @@ const (
|
||||
func (c Events) GetItem(
|
||||
ctx context.Context,
|
||||
userID, itemID string,
|
||||
immutableIDs bool,
|
||||
errs *fault.Bus,
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error) {
|
||||
var (
|
||||
err error
|
||||
event models.Eventable
|
||||
config = &users.ItemEventsEventItemRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
)
|
||||
|
||||
@ -226,14 +225,14 @@ func (c Events) GetItem(
|
||||
return nil, nil, clues.Wrap(err, "verify cancelled occurrences")
|
||||
}
|
||||
|
||||
err = fixupExceptionOccurrences(ctx, c, event, immutableIDs, userID)
|
||||
err = fixupExceptionOccurrences(ctx, c, event, userID)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Wrap(err, "fixup exception occurrences")
|
||||
}
|
||||
|
||||
var attachments []models.Attachmentable
|
||||
if ptr.Val(event.GetHasAttachments()) || HasAttachments(event.GetBody()) {
|
||||
attachments, err = c.GetAttachments(ctx, immutableIDs, userID, itemID)
|
||||
attachments, err = c.GetAttachments(ctx, userID, itemID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -250,7 +249,6 @@ func fixupExceptionOccurrences(
|
||||
ctx context.Context,
|
||||
client Events,
|
||||
event models.Eventable,
|
||||
immutableIDs bool,
|
||||
userID string,
|
||||
) error {
|
||||
// Fetch attachments for exceptions
|
||||
@ -282,7 +280,7 @@ func fixupExceptionOccurrences(
|
||||
|
||||
var attachments []models.Attachmentable
|
||||
if ptr.Val(event.GetHasAttachments()) || HasAttachments(event.GetBody()) {
|
||||
attachments, err = client.GetAttachments(ctx, immutableIDs, userID, ptr.Val(evt.GetId()))
|
||||
attachments, err = client.GetAttachments(ctx, userID, ptr.Val(evt.GetId()))
|
||||
if err != nil {
|
||||
return clues.Wrap(err, "getting event instance attachments").
|
||||
With("event_instance_id", ptr.Val(evt.GetId()))
|
||||
@ -374,14 +372,15 @@ func parseableToMap(att serialization.Parsable) (map[string]any, error) {
|
||||
|
||||
func (c Events) GetAttachments(
|
||||
ctx context.Context,
|
||||
immutableIDs bool,
|
||||
userID, itemID string,
|
||||
) ([]models.Attachmentable, error) {
|
||||
config := &users.ItemEventsItemAttachmentsRequestBuilderGetRequestConfiguration{
|
||||
QueryParameters: &users.ItemEventsItemAttachmentsRequestBuilderGetQueryParameters{
|
||||
Expand: []string{"microsoft.graph.itemattachment/item"},
|
||||
},
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
|
||||
attached, err := c.LargeItem.
|
||||
|
||||
@ -30,11 +30,12 @@ type eventsCalendarsPageCtrl struct {
|
||||
|
||||
func (c Events) NewEventCalendarsPager(
|
||||
userID string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.NonDeltaHandler[models.Calendarable] {
|
||||
options := &users.ItemCalendarsRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
QueryParameters: &users.ItemCalendarsRequestBuilderGetQueryParameters{},
|
||||
// do NOT set Top. It limits the total items received.
|
||||
}
|
||||
@ -71,9 +72,8 @@ func (p *eventsCalendarsPageCtrl) ValidModTimes() bool {
|
||||
func (c Events) EnumerateContainers(
|
||||
ctx context.Context,
|
||||
userID, _ string, // baseContainerID not needed here
|
||||
immutableIDs bool,
|
||||
) ([]models.Calendarable, error) {
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewEventCalendarsPager(userID, immutableIDs))
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewEventCalendarsPager(userID))
|
||||
return containers, graph.Stack(ctx, err).OrNil()
|
||||
}
|
||||
|
||||
@ -91,11 +91,12 @@ type eventsPageCtrl struct {
|
||||
|
||||
func (c Events) NewEventsPager(
|
||||
userID, containerID string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.NonDeltaHandler[models.Eventable] {
|
||||
options := &users.ItemCalendarsItemEventsRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
QueryParameters: &users.ItemCalendarsItemEventsRequestBuilderGetQueryParameters{},
|
||||
// do NOT set Top. It limits the total items received.
|
||||
}
|
||||
@ -135,7 +136,7 @@ func (c Events) GetItemsInContainerByCollisionKey(
|
||||
userID, containerID string,
|
||||
) (map[string]string, error) {
|
||||
ctx = clues.Add(ctx, "container_id", containerID)
|
||||
pager := c.NewEventsPager(userID, containerID, false, eventCollisionKeyProps()...)
|
||||
pager := c.NewEventsPager(userID, containerID, eventCollisionKeyProps()...)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
@ -156,7 +157,7 @@ func (c Events) GetItemIDsInContainer(
|
||||
userID, containerID string,
|
||||
) (map[string]struct{}, error) {
|
||||
ctx = clues.Add(ctx, "container_id", containerID)
|
||||
pager := c.NewEventsPager(userID, containerID, false, idAnd()...)
|
||||
pager := c.NewEventsPager(userID, containerID, idAnd()...)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
@ -198,13 +199,14 @@ func getEventDeltaBuilder(
|
||||
func (c Events) NewEventsDeltaPager(
|
||||
ctx context.Context,
|
||||
userID, containerID, prevDeltaLink string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.DeltaHandler[models.Eventable] {
|
||||
options := &users.ItemCalendarsItemEventsDeltaRequestBuilderGetRequestConfiguration{
|
||||
// do NOT set Top. It limits the total items received.
|
||||
QueryParameters: &users.ItemCalendarsItemEventsDeltaRequestBuilderGetQueryParameters{},
|
||||
Headers: newPreferHeaders(preferPageSize(c.options.DeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(c.options.DeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
|
||||
if len(selectProps) > 0 {
|
||||
@ -256,12 +258,10 @@ func (c Events) GetAddedAndRemovedItemIDs(
|
||||
userID,
|
||||
containerID,
|
||||
prevDeltaLink,
|
||||
config.UseImmutableIDs,
|
||||
idAnd()...)
|
||||
pager := c.NewEventsPager(
|
||||
userID,
|
||||
containerID,
|
||||
config.UseImmutableIDs,
|
||||
idAnd(lastModifiedDateTime)...)
|
||||
|
||||
return pagers.GetAddedAndRemovedItemIDs[models.Eventable](
|
||||
|
||||
@ -304,8 +304,7 @@ func (suite *EventsAPIIntgSuite) TestEvents_canFindNonStandardFolder() {
|
||||
containers, err := ac.EnumerateContainers(
|
||||
ctx,
|
||||
suite.its.user.id,
|
||||
DefaultCalendar,
|
||||
false)
|
||||
DefaultCalendar)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
for _, c := range containers {
|
||||
|
||||
@ -17,7 +17,6 @@ type GetItemer[INFO any] interface {
|
||||
GetItem(
|
||||
ctx context.Context,
|
||||
user, itemID string,
|
||||
immutableIDs bool,
|
||||
errs *fault.Bus,
|
||||
) (serialization.Parsable, *INFO, error)
|
||||
}
|
||||
|
||||
@ -254,7 +254,6 @@ func (c Mail) GetContainerChildren(
|
||||
func (c Mail) GetItem(
|
||||
ctx context.Context,
|
||||
userID, mailID string,
|
||||
immutableIDs bool,
|
||||
errs *fault.Bus,
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error) {
|
||||
var (
|
||||
@ -262,7 +261,7 @@ func (c Mail) GetItem(
|
||||
size int64
|
||||
mailBody models.ItemBodyable
|
||||
config = &users.ItemMessagesMessageItemRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
)
|
||||
|
||||
@ -289,7 +288,7 @@ func (c Mail) GetItem(
|
||||
return mail, MailInfo(mail, size), nil
|
||||
}
|
||||
|
||||
attachments, totalSize, err := c.getAttachments(ctx, userID, mailID, immutableIDs)
|
||||
attachments, totalSize, err := c.getAttachments(ctx, userID, mailID)
|
||||
if err != nil {
|
||||
// A failure can be caused by having a lot of attachments.
|
||||
// If that happens, we can progres with a two-step approach of:
|
||||
@ -297,7 +296,11 @@ func (c Mail) GetItem(
|
||||
// 2. fetching each attachment individually.
|
||||
logger.CtxErr(ctx, err).Info("falling back to fetching attachments by id")
|
||||
|
||||
attachments, totalSize, err = c.getAttachmentsIterated(ctx, userID, mailID, immutableIDs, errs)
|
||||
attachments, totalSize, err = c.getAttachmentsIterated(
|
||||
ctx,
|
||||
userID,
|
||||
mailID,
|
||||
errs)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Stack(err)
|
||||
}
|
||||
@ -314,7 +317,6 @@ func (c Mail) GetItem(
|
||||
func (c Mail) getAttachments(
|
||||
ctx context.Context,
|
||||
userID, mailID string,
|
||||
immutableIDs bool,
|
||||
) ([]models.Attachmentable, int64, error) {
|
||||
var (
|
||||
result = []models.Attachmentable{}
|
||||
@ -323,7 +325,9 @@ func (c Mail) getAttachments(
|
||||
QueryParameters: &users.ItemMessagesItemAttachmentsRequestBuilderGetQueryParameters{
|
||||
Expand: []string{"microsoft.graph.itemattachment/item"},
|
||||
},
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
)
|
||||
|
||||
@ -354,7 +358,6 @@ func (c Mail) getAttachments(
|
||||
func (c Mail) getAttachmentsIterated(
|
||||
ctx context.Context,
|
||||
userID, mailID string,
|
||||
immutableIDs bool,
|
||||
errs *fault.Bus,
|
||||
) ([]models.Attachmentable, int64, error) {
|
||||
var (
|
||||
@ -364,7 +367,9 @@ func (c Mail) getAttachmentsIterated(
|
||||
QueryParameters: &users.ItemMessagesItemAttachmentsRequestBuilderGetQueryParameters{
|
||||
Select: idAnd(),
|
||||
},
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
)
|
||||
|
||||
@ -397,7 +402,6 @@ func (c Mail) getAttachmentsIterated(
|
||||
userID,
|
||||
mailID,
|
||||
aID,
|
||||
immutableIDs,
|
||||
isItemAttachment,
|
||||
errs)
|
||||
if err != nil {
|
||||
@ -416,14 +420,14 @@ func (c Mail) getAttachmentsIterated(
|
||||
func (c Mail) getAttachmentByID(
|
||||
ctx context.Context,
|
||||
userID, mailID, attachmentID string,
|
||||
immutableIDs, isItemAttachment bool,
|
||||
isItemAttachment bool,
|
||||
errs *fault.Bus,
|
||||
) (models.Attachmentable, error) {
|
||||
cfg := &users.ItemMessagesItemAttachmentsAttachmentItemRequestBuilderGetRequestConfiguration{
|
||||
QueryParameters: &users.ItemMessagesItemAttachmentsAttachmentItemRequestBuilderGetQueryParameters{
|
||||
Expand: []string{"microsoft.graph.itemattachment/item"},
|
||||
},
|
||||
Headers: newPreferHeaders(preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
|
||||
attachment, err := c.Stable.
|
||||
|
||||
@ -28,11 +28,12 @@ type mailFoldersPageCtrl struct {
|
||||
|
||||
func (c Mail) NewMailFoldersPager(
|
||||
userID string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.NonDeltaHandler[models.MailFolderable] {
|
||||
options := &users.ItemMailFoldersRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
QueryParameters: &users.ItemMailFoldersRequestBuilderGetQueryParameters{},
|
||||
// do NOT set Top. It limits the total items received.
|
||||
}
|
||||
@ -67,9 +68,8 @@ func (p *mailFoldersPageCtrl) ValidModTimes() bool {
|
||||
func (c Mail) EnumerateContainers(
|
||||
ctx context.Context,
|
||||
userID, _ string, // baseContainerID not needed here
|
||||
immutableIDs bool,
|
||||
) ([]models.MailFolderable, error) {
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewMailFoldersPager(userID, immutableIDs))
|
||||
containers, err := pagers.BatchEnumerateItems(ctx, c.NewMailFoldersPager(userID))
|
||||
return containers, graph.Stack(ctx, err).OrNil()
|
||||
}
|
||||
|
||||
@ -87,11 +87,12 @@ type mailsPageCtrl struct {
|
||||
|
||||
func (c Mail) NewMailPager(
|
||||
userID, containerID string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.NonDeltaHandler[models.Messageable] {
|
||||
options := &users.ItemMailFoldersItemMessagesRequestBuilderGetRequestConfiguration{
|
||||
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(maxNonDeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
QueryParameters: &users.ItemMailFoldersItemMessagesRequestBuilderGetQueryParameters{},
|
||||
// do NOT set Top. It limits the total items received.
|
||||
}
|
||||
@ -131,7 +132,7 @@ func (c Mail) GetItemsInContainerByCollisionKey(
|
||||
userID, containerID string,
|
||||
) (map[string]string, error) {
|
||||
ctx = clues.Add(ctx, "container_id", containerID)
|
||||
pager := c.NewMailPager(userID, containerID, false, mailCollisionKeyProps()...)
|
||||
pager := c.NewMailPager(userID, containerID, mailCollisionKeyProps()...)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
@ -152,7 +153,7 @@ func (c Mail) GetItemsInContainer(
|
||||
userID, containerID string,
|
||||
) ([]models.Messageable, error) {
|
||||
ctx = clues.Add(ctx, "container_id", containerID)
|
||||
pager := c.NewMailPager(userID, containerID, false)
|
||||
pager := c.NewMailPager(userID, containerID)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
@ -167,7 +168,7 @@ func (c Mail) GetItemIDsInContainer(
|
||||
userID, containerID string,
|
||||
) (map[string]struct{}, error) {
|
||||
ctx = clues.Add(ctx, "container_id", containerID)
|
||||
pager := c.NewMailPager(userID, containerID, false, idAnd()...)
|
||||
pager := c.NewMailPager(userID, containerID, idAnd()...)
|
||||
|
||||
items, err := pagers.BatchEnumerateItems(ctx, pager)
|
||||
if err != nil {
|
||||
@ -216,13 +217,14 @@ func getMailDeltaBuilder(
|
||||
func (c Mail) NewMailDeltaPager(
|
||||
ctx context.Context,
|
||||
userID, containerID, prevDeltaLink string,
|
||||
immutableIDs bool,
|
||||
selectProps ...string,
|
||||
) pagers.DeltaHandler[models.Messageable] {
|
||||
options := &users.ItemMailFoldersItemMessagesDeltaRequestBuilderGetRequestConfiguration{
|
||||
// do NOT set Top. It limits the total items received.
|
||||
QueryParameters: &users.ItemMailFoldersItemMessagesDeltaRequestBuilderGetQueryParameters{},
|
||||
Headers: newPreferHeaders(preferPageSize(c.options.DeltaPageSize), preferImmutableIDs(immutableIDs)),
|
||||
Headers: newPreferHeaders(
|
||||
preferPageSize(c.options.DeltaPageSize),
|
||||
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
|
||||
}
|
||||
|
||||
if len(selectProps) > 0 {
|
||||
@ -273,12 +275,10 @@ func (c Mail) GetAddedAndRemovedItemIDs(
|
||||
userID,
|
||||
containerID,
|
||||
prevDeltaLink,
|
||||
config.UseImmutableIDs,
|
||||
idAnd(lastModifiedDateTime)...)
|
||||
pager := c.NewMailPager(
|
||||
userID,
|
||||
containerID,
|
||||
config.UseImmutableIDs,
|
||||
idAnd(lastModifiedDateTime)...)
|
||||
|
||||
return pagers.GetAddedAndRemovedItemIDs[models.Messageable](
|
||||
|
||||
@ -375,7 +375,6 @@ func (suite *MailAPIIntgSuite) TestMail_attachmentListDownload() {
|
||||
ctx,
|
||||
"user",
|
||||
mid,
|
||||
false,
|
||||
fault.New(true))
|
||||
test.expect(t, err)
|
||||
|
||||
@ -561,7 +560,6 @@ func (suite *MailAPIIntgSuite) TestMail_PostAndGetAttachments() {
|
||||
ctx,
|
||||
userID,
|
||||
ptr.Val(m.GetId()),
|
||||
false,
|
||||
fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -723,7 +721,6 @@ func sendItemWithBodyAndGetSerialized(
|
||||
ctx,
|
||||
userID,
|
||||
ptr.Val(item.GetId()),
|
||||
false,
|
||||
fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -755,7 +752,6 @@ func sendSerializedItemAndGetSerialized(
|
||||
ctx,
|
||||
userID,
|
||||
ptr.Val(item.GetId()),
|
||||
false,
|
||||
fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user