Add "mail" as part of FullPath for dir structure (#201)
* Add "mail" as part of FullPath for dir structure * Update restore code for new dir structure
This commit is contained in:
parent
8272227895
commit
4f2ab23fbd
@ -19,6 +19,8 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const mailCategory = "mail"
|
||||||
|
|
||||||
// GraphConnector is a struct used to wrap the GraphServiceClient and
|
// GraphConnector is a struct used to wrap the GraphServiceClient and
|
||||||
// GraphRequestAdapter from the msgraph-sdk-go. Additional fields are for
|
// GraphRequestAdapter from the msgraph-sdk-go. Additional fields are for
|
||||||
// bookkeeping and interfacing with other component.
|
// bookkeeping and interfacing with other component.
|
||||||
@ -148,7 +150,7 @@ func optionsForMailFolders(moreOps []string) *msfolder.MailFoldersRequestBuilder
|
|||||||
|
|
||||||
// restoreMessages: Utility function to connect to M365 backstore
|
// restoreMessages: Utility function to connect to M365 backstore
|
||||||
// and upload messages from DataCollection.
|
// and upload messages from DataCollection.
|
||||||
// FullPath: tenantId, userId, FolderId
|
// FullPath: tenantId, userId, <mailCategory>, FolderId
|
||||||
func (gc *GraphConnector) restoreMessages(dc DataCollection) error {
|
func (gc *GraphConnector) restoreMessages(dc DataCollection) error {
|
||||||
var errs error
|
var errs error
|
||||||
// must be user.GetId(), PrimaryName no longer works 6-15-2022
|
// must be user.GetId(), PrimaryName no longer works 6-15-2022
|
||||||
@ -171,7 +173,7 @@ func (gc *GraphConnector) restoreMessages(dc DataCollection) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
clone := support.ToMessage(message)
|
clone := support.ToMessage(message)
|
||||||
address := dc.FullPath()[2]
|
address := dc.FullPath()[3]
|
||||||
valueId := "Integer 0x0E07"
|
valueId := "Integer 0x0E07"
|
||||||
enableValue := "4"
|
enableValue := "4"
|
||||||
sv := models.NewSingleValueLegacyExtendedProperty()
|
sv := models.NewSingleValueLegacyExtendedProperty()
|
||||||
@ -235,7 +237,7 @@ func (gc *GraphConnector) serializeMessages(user string) ([]DataCollection, erro
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
objectWriter := kw.NewJsonSerializationWriter()
|
objectWriter := kw.NewJsonSerializationWriter()
|
||||||
edc := NewExchangeDataCollection(user, []string{gc.tenant, user, aFolder})
|
edc := NewExchangeDataCollection(user, []string{gc.tenant, user, mailCategory, aFolder})
|
||||||
|
|
||||||
callbackFunc := func(messageItem interface{}) bool {
|
callbackFunc := func(messageItem interface{}) bool {
|
||||||
message, ok := messageItem.(models.Messageable)
|
message, ok := messageItem.(models.Messageable)
|
||||||
|
|||||||
@ -85,7 +85,7 @@ func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_restoreMessages(
|
|||||||
suite.T().Skipf("Support file not accessible: %v\n", err)
|
suite.T().Skipf("Support file not accessible: %v\n", err)
|
||||||
}
|
}
|
||||||
ds := ExchangeData{id: "test", message: bytes}
|
ds := ExchangeData{id: "test", message: bytes}
|
||||||
edc := NewExchangeDataCollection("tenant", []string{"tenantId", evs[user], "Inbox"})
|
edc := NewExchangeDataCollection("tenant", []string{"tenantId", evs[user], mailCategory, "Inbox"})
|
||||||
edc.PopulateCollection(ds)
|
edc.PopulateCollection(ds)
|
||||||
edc.FinishPopulation()
|
edc.FinishPopulation()
|
||||||
err = suite.connector.restoreMessages(&edc)
|
err = suite.connector.restoreMessages(&edc)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user