parent
dac8c03139
commit
402b3aae06
@ -35,8 +35,8 @@ const (
|
|||||||
// It implements the DataCollection interface
|
// It implements the DataCollection interface
|
||||||
type Collection struct {
|
type Collection struct {
|
||||||
// M365 user
|
// M365 user
|
||||||
User string // M365 user
|
user string // M365 user
|
||||||
Data chan data.Stream
|
data chan data.Stream
|
||||||
|
|
||||||
// FullPath is the slice representation of the action context passed down through the hierarchy.
|
// 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. {<tenant ID>, <user ID>, "emails"})
|
//The original request can be gleaned from the slice. (e.g. {<tenant ID>, <user ID>, "emails"})
|
||||||
@ -46,22 +46,22 @@ type Collection struct {
|
|||||||
// NewExchangeDataCollection creates an ExchangeDataCollection with fullPath is annotated
|
// NewExchangeDataCollection creates an ExchangeDataCollection with fullPath is annotated
|
||||||
func NewCollection(aUser string, pathRepresentation []string) Collection {
|
func NewCollection(aUser string, pathRepresentation []string) Collection {
|
||||||
collection := Collection{
|
collection := Collection{
|
||||||
User: aUser,
|
user: aUser,
|
||||||
Data: make(chan data.Stream, collectionChannelBufferSize),
|
data: make(chan data.Stream, collectionChannelBufferSize),
|
||||||
fullPath: pathRepresentation,
|
fullPath: pathRepresentation,
|
||||||
}
|
}
|
||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eoc *Collection) PopulateCollection(newData *Stream) {
|
func (eoc *Collection) PopulateCollection(newData *Stream) {
|
||||||
eoc.Data <- newData
|
eoc.data <- newData
|
||||||
}
|
}
|
||||||
|
|
||||||
// FinishPopulation is used to indicate data population of the collection is complete
|
// 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 should be an internal method once we move the message retrieval logic into `ExchangeDataCollection`
|
||||||
func (eoc *Collection) FinishPopulation() {
|
func (eoc *Collection) FinishPopulation() {
|
||||||
if eoc.Data != nil {
|
if eoc.data != nil {
|
||||||
close(eoc.Data)
|
close(eoc.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,16 +90,16 @@ func PopulateFromTaskList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
response, err := service.Client().UsersById(edc.User).MessagesById(task).Get()
|
response, err := service.Client().UsersById(edc.user).MessagesById(task).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
details := support.ConnectorStackErrorTrace(err)
|
details := support.ConnectorStackErrorTrace(err)
|
||||||
errs = support.WrapAndAppend(edc.User, errors.Wrapf(err, "unable to retrieve %s, %s", task, details), errs)
|
errs = support.WrapAndAppend(edc.user, errors.Wrapf(err, "unable to retrieve %s, %s", task, details), errs)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = messageToDataCollection(service.Client(), ctx, objectWriter, edc.Data, response, edc.User)
|
err = messageToDataCollection(service.Client(), ctx, objectWriter, edc.data, response, edc.user)
|
||||||
success++
|
success++
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = support.WrapAndAppendf(edc.User, err, errs)
|
errs = support.WrapAndAppendf(edc.user, err, errs)
|
||||||
success--
|
success--
|
||||||
}
|
}
|
||||||
if errs != nil && service.ErrPolicy() {
|
if errs != nil && service.ErrPolicy() {
|
||||||
@ -170,7 +170,7 @@ func messageToDataCollection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (eoc *Collection) Items() <-chan data.Stream {
|
func (eoc *Collection) Items() <-chan data.Stream {
|
||||||
return eoc.Data
|
return eoc.data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (edc *Collection) FullPath() []string {
|
func (edc *Collection) FullPath() []string {
|
||||||
|
|||||||
@ -57,7 +57,7 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeData_FullPath() {
|
|||||||
func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_NewExchangeDataCollection() {
|
func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_NewExchangeDataCollection() {
|
||||||
name := "User"
|
name := "User"
|
||||||
edc := NewCollection(name, []string{"Directory", "File", "task"})
|
edc := NewCollection(name, []string{"Directory", "File", "task"})
|
||||||
suite.Equal(name, edc.User)
|
suite.Equal(name, edc.user)
|
||||||
suite.True(contains(edc.FullPath(), "Directory"))
|
suite.True(contains(edc.FullPath(), "Directory"))
|
||||||
suite.True(contains(edc.FullPath(), "File"))
|
suite.True(contains(edc.FullPath(), "File"))
|
||||||
suite.True(contains(edc.FullPath(), "task"))
|
suite.True(contains(edc.FullPath(), "task"))
|
||||||
@ -71,7 +71,7 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_PopulateCol
|
|||||||
for i := 0; i < expected; i++ {
|
for i := 0; i < expected; i++ {
|
||||||
edc.PopulateCollection(&Stream{id: inputStrings[i*2], message: []byte(inputStrings[i*2+1])})
|
edc.PopulateCollection(&Stream{id: inputStrings[i*2], message: []byte(inputStrings[i*2+1])})
|
||||||
}
|
}
|
||||||
suite.Equal(expected, len(edc.Data))
|
suite.Equal(expected, len(edc.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_Items() {
|
func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_Items() {
|
||||||
@ -80,10 +80,10 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_Items() {
|
|||||||
expected := len(inputStrings) / 2 // We are using pairs
|
expected := len(inputStrings) / 2 // We are using pairs
|
||||||
edc := NewCollection("Fletcher", []string{"sugar", "horses", "painted red"})
|
edc := NewCollection("Fletcher", []string{"sugar", "horses", "painted red"})
|
||||||
for i := 0; i < expected; i++ {
|
for i := 0; i < expected; i++ {
|
||||||
edc.Data <- &Stream{id: inputStrings[i*2], message: []byte(inputStrings[i*2+1])}
|
edc.data <- &Stream{id: inputStrings[i*2], message: []byte(inputStrings[i*2+1])}
|
||||||
}
|
}
|
||||||
close(edc.Data)
|
close(edc.data)
|
||||||
suite.Equal(expected, len(edc.Data))
|
suite.Equal(expected, len(edc.data))
|
||||||
streams := edc.Items()
|
streams := edc.Items()
|
||||||
suite.Equal(expected, len(streams))
|
suite.Equal(expected, len(streams))
|
||||||
count := 0
|
count := 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user