diff --git a/src/internal/connector/exchange/exchange_data_collection.go b/src/internal/connector/exchange/exchange_data_collection.go index 0d9f285df..f46f002c3 100644 --- a/src/internal/connector/exchange/exchange_data_collection.go +++ b/src/internal/connector/exchange/exchange_data_collection.go @@ -37,6 +37,9 @@ type Collection struct { // M365 user user string // M365 user data chan data.Stream + // jobs represents items from the inventory of M365 objectIds whose information + // is desired to be sent through the data channel for eventual storage + jobs []string // FullPath is the slice representation of the action context passed down through the hierarchy. //The original request can be gleaned from the slice. (e.g. {, , "emails"}) @@ -48,17 +51,25 @@ func NewCollection(aUser string, pathRepresentation []string) Collection { collection := Collection{ user: aUser, data: make(chan data.Stream, collectionChannelBufferSize), + jobs: make([]string, 0), fullPath: pathRepresentation, } return collection } +// AddJob appends additional objectID to job field job +func (eoc *Collection) AddJob(objID string) { + eoc.jobs = append(eoc.jobs, objID) +} + +// PopulateCollection TODO: remove after async functionilty completed func (eoc *Collection) PopulateCollection(newData *Stream) { eoc.data <- newData } // FinishPopulation is used to indicate data population of the collection is complete // TODO: This should be an internal method once we move the message retrieval logic into `ExchangeDataCollection` +// TODO: This will be removed as the channel will be filled from calls from exchange.Collection func (eoc *Collection) FinishPopulation() { if eoc.data != nil { close(eoc.data) diff --git a/src/internal/connector/exchange/exchange_data_collection_test.go b/src/internal/connector/exchange/exchange_data_collection_test.go index 5d3f90a3c..c606d0dae 100644 --- a/src/internal/connector/exchange/exchange_data_collection_test.go +++ b/src/internal/connector/exchange/exchange_data_collection_test.go @@ -93,3 +93,14 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_Items() { } suite.Equal(count, expected) } + +func (suite *ExchangeDataCollectionSuite) TestExchangeCollection_AddJob() { + eoc := NewCollection("Dexter", []string{"Today", "is", "was", "different"}) + suite.Zero(len(eoc.jobs)) + shopping := []string{"tomotoes", "potatoes", "pasta", "ice tea"} + for _, item := range shopping { + eoc.AddJob(item) + } + suite.Equal(len(shopping), len(eoc.jobs)) + +}