fix has drive and has mailbox conditions (#3473)
#### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🐛 Bugfix #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
15ef7d5e9b
commit
cf849e9c5d
@ -3,7 +3,6 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
@ -261,29 +260,29 @@ func (c Users) GetInfo(ctx context.Context, userID string) (*UserInfo, error) {
|
|||||||
|
|
||||||
mfs, err := c.GetMailFolders(ctx, userID, options)
|
mfs, err := c.GetMailFolders(ctx, userID, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.CtxErr(ctx, err).Error("getting user's mail folders")
|
||||||
|
|
||||||
if graph.IsErrUserNotFound(err) {
|
if graph.IsErrUserNotFound(err) {
|
||||||
logger.CtxErr(ctx, err).Error("user not found")
|
return nil, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||||
return nil, graph.Stack(ctx, clues.Stack(graph.ErrResourceOwnerNotFound, err))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !graph.IsErrExchangeMailFolderNotFound(err) ||
|
if !graph.IsErrExchangeMailFolderNotFound(err) {
|
||||||
clues.HasLabel(err, graph.LabelStatus(http.StatusNotFound)) {
|
return nil, clues.Stack(err)
|
||||||
logger.CtxErr(ctx, err).Error("getting user's mail folder")
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Ctx(ctx).Info("resource owner does not have a mailbox enabled")
|
|
||||||
delete(userInfo.ServicesEnabled, path.ExchangeService)
|
delete(userInfo.ServicesEnabled, path.ExchangeService)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := c.GetDrives(ctx, userID); err != nil {
|
if _, err := c.GetDrives(ctx, userID); err != nil {
|
||||||
if !clues.HasLabel(err, graph.LabelsMysiteNotFound) {
|
logger.CtxErr(ctx, err).Error("getting user's drives")
|
||||||
logger.CtxErr(ctx, err).Error("getting user's drives")
|
|
||||||
|
|
||||||
return nil, graph.Wrap(ctx, err, "getting user's drives")
|
if graph.IsErrUserNotFound(err) {
|
||||||
|
return nil, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Ctx(ctx).Info("resource owner does not have a drive")
|
if !clues.HasLabel(err, graph.LabelsMysiteNotFound) {
|
||||||
|
return nil, clues.Stack(err)
|
||||||
|
}
|
||||||
|
|
||||||
delete(userInfo.ServicesEnabled, path.OneDriveService)
|
delete(userInfo.ServicesEnabled, path.OneDriveService)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package m365
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
@ -91,16 +90,17 @@ func UserHasMailbox(ctx context.Context, acct account.Account, userID string) (b
|
|||||||
|
|
||||||
_, err = uapi.GetMailFolders(ctx, userID, options)
|
_, err = uapi.GetMailFolders(ctx, userID, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// we consider this a non-error case, since it
|
||||||
|
// answers the question the caller is asking.
|
||||||
|
if graph.IsErrExchangeMailFolderNotFound(err) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
if graph.IsErrUserNotFound(err) {
|
if graph.IsErrUserNotFound(err) {
|
||||||
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !graph.IsErrExchangeMailFolderNotFound(err) ||
|
return false, clues.Stack(err)
|
||||||
clues.HasLabel(err, graph.LabelStatus(http.StatusNotFound)) {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return false, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
@ -116,17 +116,17 @@ func UserHasDrives(ctx context.Context, acct account.Account, userID string) (bo
|
|||||||
|
|
||||||
_, err = uapi.GetDrives(ctx, userID)
|
_, err = uapi.GetDrives(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// we consider this a non-error case, since it
|
||||||
|
// answers the question the caller is asking.
|
||||||
|
if clues.HasLabel(err, graph.LabelsMysiteNotFound) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
if graph.IsErrUserNotFound(err) {
|
if graph.IsErrUserNotFound(err) {
|
||||||
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !graph.IsErrExchangeMailFolderNotFound(err) ||
|
return false, clues.Stack(err)
|
||||||
clues.HasLabel(err, graph.LabelStatus(http.StatusNotFound)) ||
|
|
||||||
clues.HasLabel(err, graph.LabelsMysiteNotFound) {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return false, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user