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:
ashmrtn 2024-01-16 16:51:11 -08:00 committed by GitHub
parent 6e50d5216e
commit b8b1299514
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 71 additions and 86 deletions

View File

@ -196,7 +196,6 @@ func populateCollections(
cl = counter.Local() cl = counter.Local()
itemConfig = api.CallConfig{ itemConfig = api.CallConfig{
CanMakeDeltaQueries: !ctrlOpts.ToggleFeatures.DisableDelta, CanMakeDeltaQueries: !ctrlOpts.ToggleFeatures.DisableDelta,
UseImmutableIDs: ctrlOpts.ToggleFeatures.ExchangeImmutableIDs,
} }
cID = ptr.Val(c.GetId()) cID = ptr.Val(c.GetId())
dp = dps[cID] dp = dps[cID]

View File

@ -57,7 +57,6 @@ func (ig mockItemGetter) GetItem(
context.Context, context.Context,
string, string,
string, string,
bool,
*fault.Bus, *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error) { ) (serialization.Parsable, *details.ExchangeInfo, error) {
return models.NewMessage(), &details.ExchangeInfo{}, nil return models.NewMessage(), &details.ExchangeInfo{}, nil

View File

@ -76,7 +76,6 @@ func getItemAndInfo(
ctx, ctx,
userID, userID,
id, id,
useImmutableIDs,
fault.New(true)) // temporary way to force a failFast error fault.New(true)) // temporary way to force a failFast error
if err != nil { if err != nil {
return nil, nil, clues.WrapWC(ctx, err, "fetching item"). return nil, nil, clues.WrapWC(ctx, err, "fetching item").

View File

@ -217,7 +217,7 @@ func (suite *CollectionUnitSuite) TestGetItemWithRetries() {
defer flush() defer flush()
// itemer is mocked, so only the errors are configured atm. // 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) test.expectErr(t, err)
}) })
} }
@ -424,11 +424,10 @@ func (mlg *mockLazyItemGetterSerializer) GetItem(
ctx context.Context, ctx context.Context,
user string, user string,
itemID string, itemID string,
immutableIDs bool,
errs *fault.Bus, errs *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error) { ) (serialization.Parsable, *details.ExchangeInfo, error) {
mlg.callIDs = append(mlg.callIDs, itemID) 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) { func (mlg *mockLazyItemGetterSerializer) check(t *testing.T, expectIDs []string) {

View File

@ -108,8 +108,7 @@ func (cfc *contactContainerCache) Populate(
containers, err := cfc.enumer.EnumerateContainers( containers, err := cfc.enumer.EnumerateContainers(
ctx, ctx,
cfc.userID, cfc.userID,
baseID, baseID)
false)
ctx = clues.Add(ctx, "num_enumerated_containers", len(containers)) ctx = clues.Add(ctx, "num_enumerated_containers", len(containers))
if err != nil { if err != nil {

View File

@ -30,7 +30,6 @@ type containersEnumerator[T any] interface {
EnumerateContainers( EnumerateContainers(
ctx context.Context, ctx context.Context,
userID, baseDirID string, userID, baseDirID string,
immutableIDs bool,
) ([]T, error) ) ([]T, error)
} }

View File

@ -82,8 +82,7 @@ func (ecc *eventContainerCache) Populate(
containers, err := ecc.enumer.EnumerateContainers( containers, err := ecc.enumer.EnumerateContainers(
ctx, ctx,
ecc.userID, ecc.userID,
"", "")
false)
ctx = clues.Add(ctx, "num_enumerated_containers", len(containers)) ctx = clues.Add(ctx, "num_enumerated_containers", len(containers))
if err != nil { if err != nil {

View File

@ -211,7 +211,6 @@ type attachmentGetDeletePoster interface {
attachmentPoster attachmentPoster
GetAttachments( GetAttachments(
ctx context.Context, ctx context.Context,
immutableIDs bool,
userID string, userID string,
itemID string, itemID string,
) ([]models.Attachmentable, error) ) ([]models.Attachmentable, error)
@ -238,7 +237,7 @@ func updateAttachments(
) error { ) error {
el := errs.Local() el := errs.Local()
attachments, err := agdp.GetAttachments(ctx, false, userID, eventID) attachments, err := agdp.GetAttachments(ctx, userID, eventID)
if err != nil { if err != nil {
return clues.Wrap(err, "getting attachments") return clues.Wrap(err, "getting attachments")
} }

View File

@ -75,7 +75,6 @@ func (m *eventRestoreMock) DeleteAttachment(
func (m *eventRestoreMock) GetAttachments( func (m *eventRestoreMock) GetAttachments(
_ context.Context, _ context.Context,
_ bool,
_, _ string, _, _ string,
) ([]models.Attachmentable, error) { ) ([]models.Attachmentable, error) {
return []models.Attachmentable{}, nil return []models.Attachmentable{}, nil

View File

@ -40,7 +40,6 @@ type itemGetterSerializer interface {
GetItem( GetItem(
ctx context.Context, ctx context.Context,
user, itemID string, user, itemID string,
immutableIDs bool,
errs *fault.Bus, errs *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error) ) (serialization.Parsable, *details.ExchangeInfo, error)
Serialize( Serialize(

View File

@ -112,8 +112,7 @@ func (mc *mailContainerCache) Populate(
containers, err := mc.enumer.EnumerateContainers( containers, err := mc.enumer.EnumerateContainers(
ctx, ctx,
mc.userID, mc.userID,
"", "")
false)
ctx = clues.Add(ctx, "num_enumerated_containers", len(containers)) ctx = clues.Add(ctx, "num_enumerated_containers", len(containers))
if err != nil { if err != nil {

View File

@ -21,7 +21,6 @@ type ItemGetSerialize struct {
func (m *ItemGetSerialize) GetItem( func (m *ItemGetSerialize) GetItem(
context.Context, context.Context,
string, string, string, string,
bool,
*fault.Bus, *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error) { ) (serialization.Parsable, *details.ExchangeInfo, error) {
m.GetCount++ m.GetCount++

View File

@ -435,7 +435,7 @@ func (suite *RestoreIntgSuite) TestRestoreAndBackupEvent_recurringInstancesWithA
evts := ec.GetValue() evts := ec.GetValue()
assert.Len(t, evts, 1, "count of events") 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)) require.NoError(t, err, clues.ToCore(err))
assert.NotNil(t, info, "event item info") assert.NotNil(t, info, "event item info")

View File

@ -387,7 +387,6 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
err error err error
aar pagers.AddedAndRemoved aar pagers.AddedAndRemoved
cc = api.CallConfig{ cc = api.CallConfig{
UseImmutableIDs: toggles.ExchangeImmutableIDs,
CanMakeDeltaQueries: true, CanMakeDeltaQueries: true,
} }
) )

View File

@ -171,7 +171,6 @@ type CallConfig struct {
Expand []string Expand []string
Select []string Select []string
CanMakeDeltaQueries bool CanMakeDeltaQueries bool
UseImmutableIDs bool
// LimitResults limits the returned results to the given number. If 0, returns // LimitResults limits the returned results to the given number. If 0, returns
// all results. // all results.
LimitResults int LimitResults int

View File

@ -185,11 +185,10 @@ func (c Contacts) PatchFolder(
func (c Contacts) GetItem( func (c Contacts) GetItem(
ctx context.Context, ctx context.Context,
userID, itemID string, userID, itemID string,
immutableIDs bool,
_ *fault.Bus, // no attachments to iterate over, so this goes unused _ *fault.Bus, // no attachments to iterate over, so this goes unused
) (serialization.Parsable, *details.ExchangeInfo, error) { ) (serialization.Parsable, *details.ExchangeInfo, error) {
options := &users.ItemContactsContactItemRequestBuilderGetRequestConfiguration{ options := &users.ItemContactsContactItemRequestBuilderGetRequestConfiguration{
Headers: newPreferHeaders(preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
} }
cont, err := c.Stable. cont, err := c.Stable.

View File

@ -27,11 +27,12 @@ type contactsFoldersPageCtrl struct {
func (c Contacts) NewContactFoldersPager( func (c Contacts) NewContactFoldersPager(
userID, baseContainerID string, userID, baseContainerID string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.NonDeltaHandler[models.ContactFolderable] { ) pagers.NonDeltaHandler[models.ContactFolderable] {
options := &users.ItemContactFoldersItemChildFoldersRequestBuilderGetRequestConfiguration{ options := &users.ItemContactFoldersItemChildFoldersRequestBuilderGetRequestConfiguration{
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(
preferPageSize(maxNonDeltaPageSize),
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
QueryParameters: &users.ItemContactFoldersItemChildFoldersRequestBuilderGetQueryParameters{}, QueryParameters: &users.ItemContactFoldersItemChildFoldersRequestBuilderGetQueryParameters{},
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
} }
@ -70,9 +71,11 @@ func (p *contactsFoldersPageCtrl) ValidModTimes() bool {
func (c Contacts) EnumerateContainers( func (c Contacts) EnumerateContainers(
ctx context.Context, ctx context.Context,
userID, baseContainerID string, userID, baseContainerID string,
immutableIDs bool,
) ([]models.ContactFolderable, error) { ) ([]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() return containers, graph.Stack(ctx, err).OrNil()
} }
@ -90,11 +93,12 @@ type contactsPageCtrl struct {
func (c Contacts) NewContactsPager( func (c Contacts) NewContactsPager(
userID, containerID string, userID, containerID string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.NonDeltaHandler[models.Contactable] { ) pagers.NonDeltaHandler[models.Contactable] {
options := &users.ItemContactFoldersItemContactsRequestBuilderGetRequestConfiguration{ options := &users.ItemContactFoldersItemContactsRequestBuilderGetRequestConfiguration{
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(
preferPageSize(maxNonDeltaPageSize),
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
QueryParameters: &users.ItemContactFoldersItemContactsRequestBuilderGetQueryParameters{}, QueryParameters: &users.ItemContactFoldersItemContactsRequestBuilderGetQueryParameters{},
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
} }
@ -134,7 +138,7 @@ func (c Contacts) GetItemsInContainerByCollisionKey(
userID, containerID string, userID, containerID string,
) (map[string]string, error) { ) (map[string]string, error) {
ctx = clues.Add(ctx, "container_id", containerID) 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) items, err := pagers.BatchEnumerateItems(ctx, pager)
if err != nil { if err != nil {
@ -155,7 +159,7 @@ func (c Contacts) GetItemIDsInContainer(
userID, containerID string, userID, containerID string,
) (map[string]struct{}, error) { ) (map[string]struct{}, error) {
ctx = clues.Add(ctx, "container_id", containerID) 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) items, err := pagers.BatchEnumerateItems(ctx, pager)
if err != nil { if err != nil {
@ -204,13 +208,14 @@ func getContactDeltaBuilder(
func (c Contacts) NewContactsDeltaPager( func (c Contacts) NewContactsDeltaPager(
ctx context.Context, ctx context.Context,
userID, containerID, prevDeltaLink string, userID, containerID, prevDeltaLink string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.DeltaHandler[models.Contactable] { ) pagers.DeltaHandler[models.Contactable] {
options := &users.ItemContactFoldersItemContactsDeltaRequestBuilderGetRequestConfiguration{ options := &users.ItemContactFoldersItemContactsDeltaRequestBuilderGetRequestConfiguration{
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
QueryParameters: &users.ItemContactFoldersItemContactsDeltaRequestBuilderGetQueryParameters{}, 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 { if len(selectProps) > 0 {
@ -261,12 +266,10 @@ func (c Contacts) GetAddedAndRemovedItemIDs(
userID, userID,
containerID, containerID,
prevDeltaLink, prevDeltaLink,
config.UseImmutableIDs,
idAnd(lastModifiedDateTime)...) idAnd(lastModifiedDateTime)...)
pager := c.NewContactsPager( pager := c.NewContactsPager(
userID, userID,
containerID, containerID,
config.UseImmutableIDs,
idAnd(lastModifiedDateTime)...) idAnd(lastModifiedDateTime)...)
return pagers.GetAddedAndRemovedItemIDs[models.Contactable]( return pagers.GetAddedAndRemovedItemIDs[models.Contactable](

View File

@ -197,14 +197,13 @@ const (
func (c Events) GetItem( func (c Events) GetItem(
ctx context.Context, ctx context.Context,
userID, itemID string, userID, itemID string,
immutableIDs bool,
errs *fault.Bus, errs *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error) { ) (serialization.Parsable, *details.ExchangeInfo, error) {
var ( var (
err error err error
event models.Eventable event models.Eventable
config = &users.ItemEventsEventItemRequestBuilderGetRequestConfiguration{ 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") 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 { if err != nil {
return nil, nil, clues.Wrap(err, "fixup exception occurrences") return nil, nil, clues.Wrap(err, "fixup exception occurrences")
} }
var attachments []models.Attachmentable var attachments []models.Attachmentable
if ptr.Val(event.GetHasAttachments()) || HasAttachments(event.GetBody()) { 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 { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -250,7 +249,6 @@ func fixupExceptionOccurrences(
ctx context.Context, ctx context.Context,
client Events, client Events,
event models.Eventable, event models.Eventable,
immutableIDs bool,
userID string, userID string,
) error { ) error {
// Fetch attachments for exceptions // Fetch attachments for exceptions
@ -282,7 +280,7 @@ func fixupExceptionOccurrences(
var attachments []models.Attachmentable var attachments []models.Attachmentable
if ptr.Val(event.GetHasAttachments()) || HasAttachments(event.GetBody()) { 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 { if err != nil {
return clues.Wrap(err, "getting event instance attachments"). return clues.Wrap(err, "getting event instance attachments").
With("event_instance_id", ptr.Val(evt.GetId())) 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( func (c Events) GetAttachments(
ctx context.Context, ctx context.Context,
immutableIDs bool,
userID, itemID string, userID, itemID string,
) ([]models.Attachmentable, error) { ) ([]models.Attachmentable, error) {
config := &users.ItemEventsItemAttachmentsRequestBuilderGetRequestConfiguration{ config := &users.ItemEventsItemAttachmentsRequestBuilderGetRequestConfiguration{
QueryParameters: &users.ItemEventsItemAttachmentsRequestBuilderGetQueryParameters{ QueryParameters: &users.ItemEventsItemAttachmentsRequestBuilderGetQueryParameters{
Expand: []string{"microsoft.graph.itemattachment/item"}, 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. attached, err := c.LargeItem.

View File

@ -30,11 +30,12 @@ type eventsCalendarsPageCtrl struct {
func (c Events) NewEventCalendarsPager( func (c Events) NewEventCalendarsPager(
userID string, userID string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.NonDeltaHandler[models.Calendarable] { ) pagers.NonDeltaHandler[models.Calendarable] {
options := &users.ItemCalendarsRequestBuilderGetRequestConfiguration{ options := &users.ItemCalendarsRequestBuilderGetRequestConfiguration{
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(
preferPageSize(maxNonDeltaPageSize),
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
QueryParameters: &users.ItemCalendarsRequestBuilderGetQueryParameters{}, QueryParameters: &users.ItemCalendarsRequestBuilderGetQueryParameters{},
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
} }
@ -71,9 +72,8 @@ func (p *eventsCalendarsPageCtrl) ValidModTimes() bool {
func (c Events) EnumerateContainers( func (c Events) EnumerateContainers(
ctx context.Context, ctx context.Context,
userID, _ string, // baseContainerID not needed here userID, _ string, // baseContainerID not needed here
immutableIDs bool,
) ([]models.Calendarable, error) { ) ([]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() return containers, graph.Stack(ctx, err).OrNil()
} }
@ -91,11 +91,12 @@ type eventsPageCtrl struct {
func (c Events) NewEventsPager( func (c Events) NewEventsPager(
userID, containerID string, userID, containerID string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.NonDeltaHandler[models.Eventable] { ) pagers.NonDeltaHandler[models.Eventable] {
options := &users.ItemCalendarsItemEventsRequestBuilderGetRequestConfiguration{ options := &users.ItemCalendarsItemEventsRequestBuilderGetRequestConfiguration{
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(
preferPageSize(maxNonDeltaPageSize),
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
QueryParameters: &users.ItemCalendarsItemEventsRequestBuilderGetQueryParameters{}, QueryParameters: &users.ItemCalendarsItemEventsRequestBuilderGetQueryParameters{},
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
} }
@ -135,7 +136,7 @@ func (c Events) GetItemsInContainerByCollisionKey(
userID, containerID string, userID, containerID string,
) (map[string]string, error) { ) (map[string]string, error) {
ctx = clues.Add(ctx, "container_id", containerID) 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) items, err := pagers.BatchEnumerateItems(ctx, pager)
if err != nil { if err != nil {
@ -156,7 +157,7 @@ func (c Events) GetItemIDsInContainer(
userID, containerID string, userID, containerID string,
) (map[string]struct{}, error) { ) (map[string]struct{}, error) {
ctx = clues.Add(ctx, "container_id", containerID) 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) items, err := pagers.BatchEnumerateItems(ctx, pager)
if err != nil { if err != nil {
@ -198,13 +199,14 @@ func getEventDeltaBuilder(
func (c Events) NewEventsDeltaPager( func (c Events) NewEventsDeltaPager(
ctx context.Context, ctx context.Context,
userID, containerID, prevDeltaLink string, userID, containerID, prevDeltaLink string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.DeltaHandler[models.Eventable] { ) pagers.DeltaHandler[models.Eventable] {
options := &users.ItemCalendarsItemEventsDeltaRequestBuilderGetRequestConfiguration{ options := &users.ItemCalendarsItemEventsDeltaRequestBuilderGetRequestConfiguration{
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
QueryParameters: &users.ItemCalendarsItemEventsDeltaRequestBuilderGetQueryParameters{}, 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 { if len(selectProps) > 0 {
@ -256,12 +258,10 @@ func (c Events) GetAddedAndRemovedItemIDs(
userID, userID,
containerID, containerID,
prevDeltaLink, prevDeltaLink,
config.UseImmutableIDs,
idAnd()...) idAnd()...)
pager := c.NewEventsPager( pager := c.NewEventsPager(
userID, userID,
containerID, containerID,
config.UseImmutableIDs,
idAnd(lastModifiedDateTime)...) idAnd(lastModifiedDateTime)...)
return pagers.GetAddedAndRemovedItemIDs[models.Eventable]( return pagers.GetAddedAndRemovedItemIDs[models.Eventable](

View File

@ -304,8 +304,7 @@ func (suite *EventsAPIIntgSuite) TestEvents_canFindNonStandardFolder() {
containers, err := ac.EnumerateContainers( containers, err := ac.EnumerateContainers(
ctx, ctx,
suite.its.user.id, suite.its.user.id,
DefaultCalendar, DefaultCalendar)
false)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
for _, c := range containers { for _, c := range containers {

View File

@ -17,7 +17,6 @@ type GetItemer[INFO any] interface {
GetItem( GetItem(
ctx context.Context, ctx context.Context,
user, itemID string, user, itemID string,
immutableIDs bool,
errs *fault.Bus, errs *fault.Bus,
) (serialization.Parsable, *INFO, error) ) (serialization.Parsable, *INFO, error)
} }

View File

@ -254,7 +254,6 @@ func (c Mail) GetContainerChildren(
func (c Mail) GetItem( func (c Mail) GetItem(
ctx context.Context, ctx context.Context,
userID, mailID string, userID, mailID string,
immutableIDs bool,
errs *fault.Bus, errs *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error) { ) (serialization.Parsable, *details.ExchangeInfo, error) {
var ( var (
@ -262,7 +261,7 @@ func (c Mail) GetItem(
size int64 size int64
mailBody models.ItemBodyable mailBody models.ItemBodyable
config = &users.ItemMessagesMessageItemRequestBuilderGetRequestConfiguration{ 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 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 { if err != nil {
// A failure can be caused by having a lot of attachments. // A failure can be caused by having a lot of attachments.
// If that happens, we can progres with a two-step approach of: // 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. // 2. fetching each attachment individually.
logger.CtxErr(ctx, err).Info("falling back to fetching attachments by id") 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 { if err != nil {
return nil, nil, clues.Stack(err) return nil, nil, clues.Stack(err)
} }
@ -314,7 +317,6 @@ func (c Mail) GetItem(
func (c Mail) getAttachments( func (c Mail) getAttachments(
ctx context.Context, ctx context.Context,
userID, mailID string, userID, mailID string,
immutableIDs bool,
) ([]models.Attachmentable, int64, error) { ) ([]models.Attachmentable, int64, error) {
var ( var (
result = []models.Attachmentable{} result = []models.Attachmentable{}
@ -323,7 +325,9 @@ func (c Mail) getAttachments(
QueryParameters: &users.ItemMessagesItemAttachmentsRequestBuilderGetQueryParameters{ QueryParameters: &users.ItemMessagesItemAttachmentsRequestBuilderGetQueryParameters{
Expand: []string{"microsoft.graph.itemattachment/item"}, 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( func (c Mail) getAttachmentsIterated(
ctx context.Context, ctx context.Context,
userID, mailID string, userID, mailID string,
immutableIDs bool,
errs *fault.Bus, errs *fault.Bus,
) ([]models.Attachmentable, int64, error) { ) ([]models.Attachmentable, int64, error) {
var ( var (
@ -364,7 +367,9 @@ func (c Mail) getAttachmentsIterated(
QueryParameters: &users.ItemMessagesItemAttachmentsRequestBuilderGetQueryParameters{ QueryParameters: &users.ItemMessagesItemAttachmentsRequestBuilderGetQueryParameters{
Select: idAnd(), 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, userID,
mailID, mailID,
aID, aID,
immutableIDs,
isItemAttachment, isItemAttachment,
errs) errs)
if err != nil { if err != nil {
@ -416,14 +420,14 @@ func (c Mail) getAttachmentsIterated(
func (c Mail) getAttachmentByID( func (c Mail) getAttachmentByID(
ctx context.Context, ctx context.Context,
userID, mailID, attachmentID string, userID, mailID, attachmentID string,
immutableIDs, isItemAttachment bool, isItemAttachment bool,
errs *fault.Bus, errs *fault.Bus,
) (models.Attachmentable, error) { ) (models.Attachmentable, error) {
cfg := &users.ItemMessagesItemAttachmentsAttachmentItemRequestBuilderGetRequestConfiguration{ cfg := &users.ItemMessagesItemAttachmentsAttachmentItemRequestBuilderGetRequestConfiguration{
QueryParameters: &users.ItemMessagesItemAttachmentsAttachmentItemRequestBuilderGetQueryParameters{ QueryParameters: &users.ItemMessagesItemAttachmentsAttachmentItemRequestBuilderGetQueryParameters{
Expand: []string{"microsoft.graph.itemattachment/item"}, Expand: []string{"microsoft.graph.itemattachment/item"},
}, },
Headers: newPreferHeaders(preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
} }
attachment, err := c.Stable. attachment, err := c.Stable.

View File

@ -28,11 +28,12 @@ type mailFoldersPageCtrl struct {
func (c Mail) NewMailFoldersPager( func (c Mail) NewMailFoldersPager(
userID string, userID string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.NonDeltaHandler[models.MailFolderable] { ) pagers.NonDeltaHandler[models.MailFolderable] {
options := &users.ItemMailFoldersRequestBuilderGetRequestConfiguration{ options := &users.ItemMailFoldersRequestBuilderGetRequestConfiguration{
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(
preferPageSize(maxNonDeltaPageSize),
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
QueryParameters: &users.ItemMailFoldersRequestBuilderGetQueryParameters{}, QueryParameters: &users.ItemMailFoldersRequestBuilderGetQueryParameters{},
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
} }
@ -67,9 +68,8 @@ func (p *mailFoldersPageCtrl) ValidModTimes() bool {
func (c Mail) EnumerateContainers( func (c Mail) EnumerateContainers(
ctx context.Context, ctx context.Context,
userID, _ string, // baseContainerID not needed here userID, _ string, // baseContainerID not needed here
immutableIDs bool,
) ([]models.MailFolderable, error) { ) ([]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() return containers, graph.Stack(ctx, err).OrNil()
} }
@ -87,11 +87,12 @@ type mailsPageCtrl struct {
func (c Mail) NewMailPager( func (c Mail) NewMailPager(
userID, containerID string, userID, containerID string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.NonDeltaHandler[models.Messageable] { ) pagers.NonDeltaHandler[models.Messageable] {
options := &users.ItemMailFoldersItemMessagesRequestBuilderGetRequestConfiguration{ options := &users.ItemMailFoldersItemMessagesRequestBuilderGetRequestConfiguration{
Headers: newPreferHeaders(preferPageSize(maxNonDeltaPageSize), preferImmutableIDs(immutableIDs)), Headers: newPreferHeaders(
preferPageSize(maxNonDeltaPageSize),
preferImmutableIDs(c.options.ToggleFeatures.ExchangeImmutableIDs)),
QueryParameters: &users.ItemMailFoldersItemMessagesRequestBuilderGetQueryParameters{}, QueryParameters: &users.ItemMailFoldersItemMessagesRequestBuilderGetQueryParameters{},
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
} }
@ -131,7 +132,7 @@ func (c Mail) GetItemsInContainerByCollisionKey(
userID, containerID string, userID, containerID string,
) (map[string]string, error) { ) (map[string]string, error) {
ctx = clues.Add(ctx, "container_id", containerID) 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) items, err := pagers.BatchEnumerateItems(ctx, pager)
if err != nil { if err != nil {
@ -152,7 +153,7 @@ func (c Mail) GetItemsInContainer(
userID, containerID string, userID, containerID string,
) ([]models.Messageable, error) { ) ([]models.Messageable, error) {
ctx = clues.Add(ctx, "container_id", containerID) ctx = clues.Add(ctx, "container_id", containerID)
pager := c.NewMailPager(userID, containerID, false) pager := c.NewMailPager(userID, containerID)
items, err := pagers.BatchEnumerateItems(ctx, pager) items, err := pagers.BatchEnumerateItems(ctx, pager)
if err != nil { if err != nil {
@ -167,7 +168,7 @@ func (c Mail) GetItemIDsInContainer(
userID, containerID string, userID, containerID string,
) (map[string]struct{}, error) { ) (map[string]struct{}, error) {
ctx = clues.Add(ctx, "container_id", containerID) 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) items, err := pagers.BatchEnumerateItems(ctx, pager)
if err != nil { if err != nil {
@ -216,13 +217,14 @@ func getMailDeltaBuilder(
func (c Mail) NewMailDeltaPager( func (c Mail) NewMailDeltaPager(
ctx context.Context, ctx context.Context,
userID, containerID, prevDeltaLink string, userID, containerID, prevDeltaLink string,
immutableIDs bool,
selectProps ...string, selectProps ...string,
) pagers.DeltaHandler[models.Messageable] { ) pagers.DeltaHandler[models.Messageable] {
options := &users.ItemMailFoldersItemMessagesDeltaRequestBuilderGetRequestConfiguration{ options := &users.ItemMailFoldersItemMessagesDeltaRequestBuilderGetRequestConfiguration{
// do NOT set Top. It limits the total items received. // do NOT set Top. It limits the total items received.
QueryParameters: &users.ItemMailFoldersItemMessagesDeltaRequestBuilderGetQueryParameters{}, 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 { if len(selectProps) > 0 {
@ -273,12 +275,10 @@ func (c Mail) GetAddedAndRemovedItemIDs(
userID, userID,
containerID, containerID,
prevDeltaLink, prevDeltaLink,
config.UseImmutableIDs,
idAnd(lastModifiedDateTime)...) idAnd(lastModifiedDateTime)...)
pager := c.NewMailPager( pager := c.NewMailPager(
userID, userID,
containerID, containerID,
config.UseImmutableIDs,
idAnd(lastModifiedDateTime)...) idAnd(lastModifiedDateTime)...)
return pagers.GetAddedAndRemovedItemIDs[models.Messageable]( return pagers.GetAddedAndRemovedItemIDs[models.Messageable](

View File

@ -375,7 +375,6 @@ func (suite *MailAPIIntgSuite) TestMail_attachmentListDownload() {
ctx, ctx,
"user", "user",
mid, mid,
false,
fault.New(true)) fault.New(true))
test.expect(t, err) test.expect(t, err)
@ -561,7 +560,6 @@ func (suite *MailAPIIntgSuite) TestMail_PostAndGetAttachments() {
ctx, ctx,
userID, userID,
ptr.Val(m.GetId()), ptr.Val(m.GetId()),
false,
fault.New(true)) fault.New(true))
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
@ -723,7 +721,6 @@ func sendItemWithBodyAndGetSerialized(
ctx, ctx,
userID, userID,
ptr.Val(item.GetId()), ptr.Val(item.GetId()),
false,
fault.New(true)) fault.New(true))
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
@ -755,7 +752,6 @@ func sendSerializedItemAndGetSerialized(
ctx, ctx,
userID, userID,
ptr.Val(item.GetId()), ptr.Val(item.GetId()),
false,
fault.New(true)) fault.New(true))
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))