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 (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"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)
|
||||
if err != nil {
|
||||
logger.CtxErr(ctx, err).Error("getting user's mail folders")
|
||||
|
||||
if graph.IsErrUserNotFound(err) {
|
||||
logger.CtxErr(ctx, err).Error("user not found")
|
||||
return nil, graph.Stack(ctx, clues.Stack(graph.ErrResourceOwnerNotFound, err))
|
||||
return nil, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||
}
|
||||
|
||||
if !graph.IsErrExchangeMailFolderNotFound(err) ||
|
||||
clues.HasLabel(err, graph.LabelStatus(http.StatusNotFound)) {
|
||||
logger.CtxErr(ctx, err).Error("getting user's mail folder")
|
||||
return nil, err
|
||||
if !graph.IsErrExchangeMailFolderNotFound(err) {
|
||||
return nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
logger.Ctx(ctx).Info("resource owner does not have a mailbox enabled")
|
||||
delete(userInfo.ServicesEnabled, path.ExchangeService)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package m365
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"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)
|
||||
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) {
|
||||
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||
}
|
||||
|
||||
if !graph.IsErrExchangeMailFolderNotFound(err) ||
|
||||
clues.HasLabel(err, graph.LabelStatus(http.StatusNotFound)) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return false, nil
|
||||
return false, clues.Stack(err)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
@ -116,17 +116,17 @@ func UserHasDrives(ctx context.Context, acct account.Account, userID string) (bo
|
||||
|
||||
_, err = uapi.GetDrives(ctx, userID)
|
||||
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) {
|
||||
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||
}
|
||||
|
||||
if !graph.IsErrExchangeMailFolderNotFound(err) ||
|
||||
clues.HasLabel(err, graph.LabelStatus(http.StatusNotFound)) ||
|
||||
clues.HasLabel(err, graph.LabelsMysiteNotFound) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return false, nil
|
||||
return false, clues.Stack(err)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user