Issue #359: create folder enhancement added. (#375)

Issue #359: create folder feature added.
Feature required to finish task #374
This commit is contained in:
Danny 2022-07-21 09:32:53 -04:00 committed by GitHub
parent 6224a92e7a
commit fe92d7c9db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -98,6 +98,21 @@ func (gc *GraphConnector) createService() (*graphService, error) {
return &connector, err
}
// createMailFolder will create a mail folder iff a folder of the same name does not exit
func createMailFolder(gc graphService, user, folder string) (models.MailFolderable, error) {
requestBody := models.NewMailFolder()
requestBody.SetDisplayName(&folder)
isHidden := false
requestBody.SetIsHidden(&isHidden)
return gc.client.UsersById(user).MailFolders().Post(requestBody)
}
// deleteMailFolder removes the mail folder from the user's M365 Exchange account
func deleteMailFolder(gc graphService, user, folderID string) error {
return gc.client.UsersById(user).MailFoldersById(folderID).Delete()
}
// setTenantUsers queries the M365 to identify the users in the
// workspace. The users field is updated during this method
// iff the return value is true

View File

@ -91,8 +91,20 @@ func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_restoreMessages(
assert.NoError(suite.T(), err)
}
// ---------------------------------------------------------------------------
func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_createDeleteFolder() {
user := "lidiah@8qzvrj.onmicrosoft.com"
folderName := "createdForTest"
aFolder, err := createMailFolder(suite.connector.graphService, user, folderName)
assert.NoError(suite.T(), err, support.ConnectorStackErrorTrace(err))
if aFolder != nil {
err = deleteMailFolder(suite.connector.graphService, user, *aFolder.GetId())
assert.NoError(suite.T(), err)
}
}
// ---------------------------------------------------------------
// Disconnected Test Section
// -------------------------
type DisconnectedGraphConnectorSuite struct {
suite.Suite
}