Remove (old) unused code for fetching messages (#1168)
## Description Just code cleanup ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) * #1156 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
0a91a3e097
commit
28c3bbcf7a
@ -28,88 +28,6 @@ type GraphIterateFunc func(
|
||||
resolver graph.ContainerResolver,
|
||||
) func(any) bool
|
||||
|
||||
// IterateSelectAllDescendablesForCollection utility function for
|
||||
// Iterating through MessagesCollectionResponse or ContactsCollectionResponse,
|
||||
// objects belonging to any folder are
|
||||
// placed into a Collection based on the parent folder
|
||||
func IterateSelectAllDescendablesForCollections(
|
||||
ctx context.Context,
|
||||
qp graph.QueryParams,
|
||||
errUpdater func(string, error),
|
||||
collections map[string]*Collection,
|
||||
statusUpdater support.StatusUpdater,
|
||||
resolver graph.ContainerResolver,
|
||||
) func(any) bool {
|
||||
var (
|
||||
isCategorySet bool
|
||||
collectionType optionIdentifier
|
||||
category path.CategoryType
|
||||
dirPath path.Path
|
||||
err error
|
||||
)
|
||||
|
||||
return func(pageItem any) bool {
|
||||
// Defines the type of collection being created within the function
|
||||
if !isCategorySet {
|
||||
if qp.Scope.IncludesCategory(selectors.ExchangeMail) {
|
||||
collectionType = messages
|
||||
category = path.EmailCategory
|
||||
}
|
||||
|
||||
if qp.Scope.IncludesCategory(selectors.ExchangeContact) {
|
||||
collectionType = contacts
|
||||
category = path.ContactsCategory
|
||||
}
|
||||
|
||||
isCategorySet = true
|
||||
}
|
||||
|
||||
entry, ok := pageItem.(graph.Descendable)
|
||||
if !ok {
|
||||
errUpdater(qp.User, errors.New("Descendable conversion failure"))
|
||||
return true
|
||||
}
|
||||
|
||||
// Saving to messages to list. Indexed by folder
|
||||
directory := *entry.GetParentFolderId()
|
||||
|
||||
if _, ok = collections[directory]; !ok {
|
||||
dirPath, err = getCollectionPath(
|
||||
ctx,
|
||||
qp,
|
||||
resolver,
|
||||
directory,
|
||||
category,
|
||||
)
|
||||
if err != nil {
|
||||
errUpdater(
|
||||
"failure during IterateSelectAllDescendablesForCollections",
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
service, err := createService(qp.Credentials, qp.FailFast)
|
||||
if err != nil {
|
||||
errUpdater(qp.User, err)
|
||||
return true
|
||||
}
|
||||
|
||||
edc := NewCollection(
|
||||
qp.User,
|
||||
dirPath,
|
||||
collectionType,
|
||||
service,
|
||||
statusUpdater,
|
||||
)
|
||||
collections[directory] = &edc
|
||||
}
|
||||
|
||||
collections[directory].AddJob(*entry.GetId())
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// IterateSelectAllEventsForCollections
|
||||
// utility function for iterating through events
|
||||
// and storing events in collections based on
|
||||
@ -233,99 +151,6 @@ func CollectionsFromResolver(
|
||||
return nil
|
||||
}
|
||||
|
||||
// IterateAndFilterDescendablesForCollections is a filtering GraphIterateFunc
|
||||
// that places exchange objectsids belonging to specific directories
|
||||
// into a Collection. Messages outside of those directories are omitted.
|
||||
func IterateAndFilterDescendablesForCollections(
|
||||
ctx context.Context,
|
||||
qp graph.QueryParams,
|
||||
errUpdater func(string, error),
|
||||
collections map[string]*Collection,
|
||||
statusUpdater support.StatusUpdater,
|
||||
resolver graph.ContainerResolver,
|
||||
) func(any) bool {
|
||||
var (
|
||||
isFilterSet bool
|
||||
cache map[string]string
|
||||
)
|
||||
|
||||
return func(descendItem any) bool {
|
||||
if !isFilterSet {
|
||||
if resolver != nil {
|
||||
err := CollectionsFromResolver(
|
||||
ctx,
|
||||
qp,
|
||||
resolver,
|
||||
statusUpdater,
|
||||
collections,
|
||||
)
|
||||
if err != nil {
|
||||
errUpdater(qp.User, err)
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
err := CollectFolders(
|
||||
ctx,
|
||||
qp,
|
||||
collections,
|
||||
statusUpdater,
|
||||
resolver,
|
||||
)
|
||||
if err != nil {
|
||||
errUpdater(qp.User, err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Caches folder directories
|
||||
cache = make(map[string]string, 0)
|
||||
isFilterSet = true
|
||||
}
|
||||
|
||||
message, ok := descendItem.(graph.Descendable)
|
||||
if !ok {
|
||||
errUpdater(qp.User, errors.New("casting messageItem to Descendable"))
|
||||
return true
|
||||
}
|
||||
// Saving only messages for the created directories
|
||||
folderID := *message.GetParentFolderId()
|
||||
|
||||
directory, ok := cache[folderID]
|
||||
if !ok {
|
||||
result := translateIDToDirectory(ctx, qp, resolver, folderID)
|
||||
if result == "" {
|
||||
errUpdater(qp.User,
|
||||
errors.New("getCollectionPath experienced error during translateID"))
|
||||
}
|
||||
|
||||
cache[folderID] = result
|
||||
directory = result
|
||||
}
|
||||
|
||||
if _, ok = collections[directory]; !ok {
|
||||
return true
|
||||
}
|
||||
|
||||
collections[directory].AddJob(*message.GetId())
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func translateIDToDirectory(
|
||||
ctx context.Context,
|
||||
qp graph.QueryParams,
|
||||
resolver graph.ContainerResolver,
|
||||
directoryID string,
|
||||
) string {
|
||||
fullPath, err := getCollectionPath(ctx, qp, resolver, directoryID, path.EmailCategory)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fullPath.Folder()
|
||||
}
|
||||
|
||||
func getCategoryAndValidation(es selectors.ExchangeScope) (
|
||||
optionIdentifier,
|
||||
path.CategoryType,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user