Create helper function for getting data from map (#1694)
## Description Helper function only deals with string values in the map. Returns empty string if the requested item was not present. Will also be useful for retrieving delta tokens in future patches. ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) * #1685 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
6165bb55fb
commit
858aa13f2a
@ -20,6 +20,25 @@ import (
|
|||||||
|
|
||||||
const nextLinkKey = "@odata.nextLink"
|
const nextLinkKey = "@odata.nextLink"
|
||||||
|
|
||||||
|
// getAdditionalDataString gets a string value from the AdditionalData map. If
|
||||||
|
// the value is not in the map returns an empty string.
|
||||||
|
func getAdditionalDataString(
|
||||||
|
key string,
|
||||||
|
data map[string]any,
|
||||||
|
) string {
|
||||||
|
iface := data[key]
|
||||||
|
if iface == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
value, ok := iface.(*string)
|
||||||
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return *value
|
||||||
|
}
|
||||||
|
|
||||||
// FilterContainersAndFillCollections is a utility function
|
// FilterContainersAndFillCollections is a utility function
|
||||||
// that places the M365 object ids belonging to specific directories
|
// that places the M365 object ids belonging to specific directories
|
||||||
// into a Collection. Messages outside of those directories are omitted.
|
// into a Collection. Messages outside of those directories are omitted.
|
||||||
@ -252,17 +271,14 @@ func FetchContactIDsFromDirectory(ctx context.Context, gs graph.Service, user, d
|
|||||||
ids = append(ids, *item.GetId())
|
ids = append(ids, *item.GetId())
|
||||||
}
|
}
|
||||||
|
|
||||||
nextLinkIface := resp.GetAdditionalData()[nextLinkKey]
|
addtlData := resp.GetAdditionalData()
|
||||||
if nextLinkIface == nil {
|
|
||||||
|
nextLink := getAdditionalDataString(nextLinkKey, addtlData)
|
||||||
|
if len(nextLink) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
nextLink := nextLinkIface.(*string)
|
builder = cdelta.NewDeltaRequestBuilder(nextLink, gs.Adapter())
|
||||||
if len(*nextLink) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
builder = cdelta.NewDeltaRequestBuilder(*nextLink, gs.Adapter())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids, errs.ErrorOrNil()
|
return ids, errs.ErrorOrNil()
|
||||||
@ -312,17 +328,14 @@ func FetchMessageIDsFromDirectory(
|
|||||||
ids = append(ids, *item.GetId())
|
ids = append(ids, *item.GetId())
|
||||||
}
|
}
|
||||||
|
|
||||||
nextLinkIface := resp.GetAdditionalData()[nextLinkKey]
|
addtlData := resp.GetAdditionalData()
|
||||||
if nextLinkIface == nil {
|
|
||||||
|
nextLink := getAdditionalDataString(nextLinkKey, addtlData)
|
||||||
|
if len(nextLink) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
nextLink := nextLinkIface.(*string)
|
builder = mdelta.NewDeltaRequestBuilder(nextLink, gs.Adapter())
|
||||||
if len(*nextLink) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
builder = mdelta.NewDeltaRequestBuilder(*nextLink, gs.Adapter())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids, errs.ErrorOrNil()
|
return ids, errs.ErrorOrNil()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user