From 6f99bba624b541ac4340ba454d81c5f5cf80f6a3 Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Thu, 23 Mar 2023 08:27:21 -0700 Subject: [PATCH] Minor cleanup to mail resolver fetch (#2808) Remove old code that explicitly fetched the Inbox. The issue in Graph SDK that was causing this is no longer present. Retrieval of Inbox is tested by [test](https://github.com/alcionai/corso/blob/41f0b860735eb6b09bd4b7751290cfc40e1bc887/src/internal/connector/exchange/data_collections_test.go#L235) for making collections --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [ ] :computer: CI/Deployment - [x] :broom: Tech Debt/Cleanup #### Issue(s) * #2486 #### Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- .../connector/exchange/mail_folder_cache.go | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/internal/connector/exchange/mail_folder_cache.go b/src/internal/connector/exchange/mail_folder_cache.go index 520a2611a..4bb20c977 100644 --- a/src/internal/connector/exchange/mail_folder_cache.go +++ b/src/internal/connector/exchange/mail_folder_cache.go @@ -38,28 +38,23 @@ func (mc *mailFolderCache) init( // populateMailRoot manually fetches directories that are not returned during Graph for msgraph-sdk-go v. 40+ // rootFolderAlias is the top-level directory for exchange.Mail. -// DefaultMailFolder is the traditional "Inbox" for exchange.Mail // Action ensures that cache will stop at appropriate level. // @error iff the struct is not properly instantiated func (mc *mailFolderCache) populateMailRoot(ctx context.Context) error { - for _, fldr := range []string{rootFolderAlias, DefaultMailFolder} { - var directory string + f, err := mc.getter.GetContainerByID(ctx, mc.userID, rootFolderAlias) + if err != nil { + return clues.Wrap(err, "fetching root folder") + } - f, err := mc.getter.GetContainerByID(ctx, mc.userID, fldr) - if err != nil { - return clues.Wrap(err, "fetching root folder") - } - - if fldr == DefaultMailFolder { - directory = DefaultMailFolder - } - - temp := graph.NewCacheFolder(f, - path.Builder{}.Append(directory), // storage path - path.Builder{}.Append(directory)) // display location - if err := mc.addFolder(temp); err != nil { - return clues.Wrap(err, "adding resolver dir").WithClues(ctx) - } + temp := graph.NewCacheFolder( + f, + // Root folder doesn't store any mail messages so it isn't given any paths. + // Giving it a path/location would cause us to add extra path elements that + // the user doesn't see in the regular UI for Exchange. + path.Builder{}.Append(), // storage path + path.Builder{}.Append()) // display location + if err := mc.addFolder(temp); err != nil { + return clues.Wrap(err, "adding resolver dir").WithClues(ctx) } return nil