Merge branch 'backup-page-flow' into backup-page-flow-2
This commit is contained in:
commit
b192f9866c
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -42,6 +42,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
## increases swap space for msgraph-beta-sdk-go
|
||||||
|
- name: Set Swap Space
|
||||||
|
uses: pierotofy/set-swap-space@master
|
||||||
|
with:
|
||||||
|
swap-size-gb: 12
|
||||||
|
|
||||||
# single setup and sum cache handling here.
|
# single setup and sum cache handling here.
|
||||||
# the results will cascade onto both testing and linting.
|
# the results will cascade onto both testing and linting.
|
||||||
- name: Setup Golang with cache
|
- name: Setup Golang with cache
|
||||||
|
|||||||
@ -13,8 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Beta Libraries are included in package. This can lead to long build times.
|
- msgraph-beta-sdk-go replaces msgraph-sdk-go for new features. This can lead to long build times.
|
||||||
|
- Handle case where user's drive has not been initialized
|
||||||
|
- Inline attachments (e.g. copy/paste ) are discovered and backed up correctly ([#2163](https://github.com/alcionai/corso/issues/2163))
|
||||||
|
|
||||||
## [v0.1.0] (alpha) - 2023-01-13
|
## [v0.1.0] (alpha) - 2023-01-13
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ replace github.com/kopia/kopia => github.com/alcionai/kopia v0.10.8-0.2023011220
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0
|
||||||
github.com/aws/aws-sdk-go v1.44.181
|
github.com/aws/aws-sdk-go v1.44.183
|
||||||
github.com/aws/aws-xray-sdk-go v1.8.0
|
github.com/aws/aws-xray-sdk-go v1.8.0
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/hashicorp/go-multierror v1.1.1
|
github.com/hashicorp/go-multierror v1.1.1
|
||||||
@ -16,7 +16,6 @@ require (
|
|||||||
github.com/microsoft/kiota-http-go v0.13.0
|
github.com/microsoft/kiota-http-go v0.13.0
|
||||||
github.com/microsoft/kiota-serialization-json-go v0.7.2
|
github.com/microsoft/kiota-serialization-json-go v0.7.2
|
||||||
github.com/microsoftgraph/msgraph-beta-sdk-go v0.53.0
|
github.com/microsoftgraph/msgraph-beta-sdk-go v0.53.0
|
||||||
github.com/microsoftgraph/msgraph-sdk-go v0.52.0
|
|
||||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0
|
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/rudderlabs/analytics-go v3.3.3+incompatible
|
github.com/rudderlabs/analytics-go v3.3.3+incompatible
|
||||||
|
|||||||
@ -62,8 +62,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
|
|||||||
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
|
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
|
||||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||||
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||||
github.com/aws/aws-sdk-go v1.44.181 h1:w4OzE8bwIVo62gUTAp/uEFO2HSsUtf1pjXpSs36cluY=
|
github.com/aws/aws-sdk-go v1.44.183 h1:mUk45JZTIMMg9m8GmrbvACCsIOKtKezXRxp06uI5Ahk=
|
||||||
github.com/aws/aws-sdk-go v1.44.181/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
github.com/aws/aws-sdk-go v1.44.183/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
||||||
github.com/aws/aws-xray-sdk-go v1.8.0 h1:0xncHZ588wB/geLjbM/esoW3FOEThWy2TJyb4VXfLFY=
|
github.com/aws/aws-xray-sdk-go v1.8.0 h1:0xncHZ588wB/geLjbM/esoW3FOEThWy2TJyb4VXfLFY=
|
||||||
github.com/aws/aws-xray-sdk-go v1.8.0/go.mod h1:7LKe47H+j3evfvS1+q0wzpoaGXGrF3mUsfM+thqVO+A=
|
github.com/aws/aws-xray-sdk-go v1.8.0/go.mod h1:7LKe47H+j3evfvS1+q0wzpoaGXGrF3mUsfM+thqVO+A=
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||||
@ -281,8 +281,6 @@ github.com/microsoft/kiota-serialization-text-go v0.6.0 h1:3N2vftYZlwKdog69AN7ha
|
|||||||
github.com/microsoft/kiota-serialization-text-go v0.6.0/go.mod h1:OUA4dNH+f6afiJUs+rQAatJos7QVF5PJkyrqoD89lx4=
|
github.com/microsoft/kiota-serialization-text-go v0.6.0/go.mod h1:OUA4dNH+f6afiJUs+rQAatJos7QVF5PJkyrqoD89lx4=
|
||||||
github.com/microsoftgraph/msgraph-beta-sdk-go v0.53.0 h1:FITWxC0U8u9J82iUnTUgKhFw048OFq6hNiShpIgJx2k=
|
github.com/microsoftgraph/msgraph-beta-sdk-go v0.53.0 h1:FITWxC0U8u9J82iUnTUgKhFw048OFq6hNiShpIgJx2k=
|
||||||
github.com/microsoftgraph/msgraph-beta-sdk-go v0.53.0/go.mod h1:hyea6/iVBicq7jjlU8nzmkFys2ajScSI2q1GX9gjnIQ=
|
github.com/microsoftgraph/msgraph-beta-sdk-go v0.53.0/go.mod h1:hyea6/iVBicq7jjlU8nzmkFys2ajScSI2q1GX9gjnIQ=
|
||||||
github.com/microsoftgraph/msgraph-sdk-go v0.52.0 h1:hcFSvgxsN6xG9xGC/Y8jFasU+99OleAVZJb8rKBuISg=
|
|
||||||
github.com/microsoftgraph/msgraph-sdk-go v0.52.0/go.mod h1:RF7cVKAu0EZUmNxXZZ6orJJml02Cf85d1FFOxJ+nbRg=
|
|
||||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0 h1:cDL3ov/IZ2ZarUJdGGPsdR+46ALdd3CRAiDBIylLCoA=
|
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0 h1:cDL3ov/IZ2ZarUJdGGPsdR+46ALdd3CRAiDBIylLCoA=
|
||||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0/go.mod h1:d0mU3PQAWnN/C4CwPJEZz2QhesrnR5UDnqRu2ODWPkI=
|
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0/go.mod h1:d0mU3PQAWnN/C4CwPJEZz2QhesrnR5UDnqRu2ODWPkI=
|
||||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package discovery
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
|
msuser "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
|
||||||
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
msuser "github.com/microsoftgraph/msgraph-sdk-go/users"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
kioser "github.com/microsoft/kiota-serialization-json-go"
|
kioser "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/users"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
kioser "github.com/microsoft/kiota-serialization-json-go"
|
kioser "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/users"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
@ -58,6 +58,28 @@ func (c Events) DeleteCalendar(
|
|||||||
return c.stable.Client().UsersById(user).CalendarsById(calendarID).Delete(ctx, nil)
|
return c.stable.Client().UsersById(user).CalendarsById(calendarID).Delete(ctx, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Events) GetContainerByID(
|
||||||
|
ctx context.Context,
|
||||||
|
userID, containerID string,
|
||||||
|
) (graph.Container, error) {
|
||||||
|
service, err := c.service()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ofc, err := optionsForCalendarsByID([]string{"name", "owner"})
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "options for event calendar")
|
||||||
|
}
|
||||||
|
|
||||||
|
cal, err := service.Client().UsersById(userID).CalendarsById(containerID).Get(ctx, ofc)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return graph.CalendarDisplayable{Calendarable: cal}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetItem retrieves an Eventable item.
|
// GetItem retrieves an Eventable item.
|
||||||
func (c Events) GetItem(
|
func (c Events) GetItem(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
@ -183,14 +205,9 @@ func (c Events) GetAddedAndRemovedItemIDs(
|
|||||||
errs *multierror.Error
|
errs *multierror.Error
|
||||||
)
|
)
|
||||||
|
|
||||||
options, err := optionsForEventsByCalendarDelta([]string{"id"})
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, DeltaUpdate{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(oldDelta) > 0 {
|
if len(oldDelta) > 0 {
|
||||||
builder := users.NewItemCalendarsItemEventsDeltaRequestBuilder(oldDelta, service.Adapter())
|
builder := users.NewItemCalendarsItemEventsDeltaRequestBuilder(oldDelta, service.Adapter())
|
||||||
pgr := &eventPager{service, builder, options}
|
pgr := &eventPager{service, builder, nil}
|
||||||
|
|
||||||
added, removed, deltaURL, err := getItemsAddedAndRemovedFromContainer(ctx, pgr)
|
added, removed, deltaURL, err := getItemsAddedAndRemovedFromContainer(ctx, pgr)
|
||||||
// note: happy path, not the error condition
|
// note: happy path, not the error condition
|
||||||
@ -217,7 +234,7 @@ func (c Events) GetAddedAndRemovedItemIDs(
|
|||||||
// works as intended (until, at least, we want to _not_ call the beta anymore).
|
// works as intended (until, at least, we want to _not_ call the beta anymore).
|
||||||
rawURL := fmt.Sprintf(eventBetaDeltaURLTemplate, user, calendarID)
|
rawURL := fmt.Sprintf(eventBetaDeltaURLTemplate, user, calendarID)
|
||||||
builder := users.NewItemCalendarsItemEventsDeltaRequestBuilder(rawURL, service.Adapter())
|
builder := users.NewItemCalendarsItemEventsDeltaRequestBuilder(rawURL, service.Adapter())
|
||||||
pgr := &eventPager{service, builder, options}
|
pgr := &eventPager{service, builder, nil}
|
||||||
|
|
||||||
added, removed, deltaURL, err := getItemsAddedAndRemovedFromContainer(ctx, pgr)
|
added, removed, deltaURL, err := getItemsAddedAndRemovedFromContainer(ctx, pgr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -251,7 +268,7 @@ func (c Events) Serialize(
|
|||||||
|
|
||||||
defer writer.Close()
|
defer writer.Close()
|
||||||
|
|
||||||
if *event.GetHasAttachments() {
|
if *event.GetHasAttachments() || support.HasAttachments(event.GetBody()) {
|
||||||
// getting all the attachments might take a couple attempts due to filesize
|
// getting all the attachments might take a couple attempts due to filesize
|
||||||
var retriesErr error
|
var retriesErr error
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
kioser "github.com/microsoft/kiota-serialization-json-go"
|
kioser "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/users"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -257,7 +257,7 @@ func (c Mail) Serialize(
|
|||||||
|
|
||||||
defer writer.Close()
|
defer writer.Close()
|
||||||
|
|
||||||
if *msg.GetHasAttachments() {
|
if *msg.GetHasAttachments() || support.HasAttachments(msg.GetBody()) {
|
||||||
// getting all the attachments might take a couple attempts due to filesize
|
// getting all the attachments might take a couple attempts due to filesize
|
||||||
var retriesErr error
|
var retriesErr error
|
||||||
|
|
||||||
@ -278,7 +278,8 @@ func (c Mail) Serialize(
|
|||||||
|
|
||||||
if retriesErr != nil {
|
if retriesErr != nil {
|
||||||
logger.Ctx(ctx).Debug("exceeded maximum retries")
|
logger.Ctx(ctx).Debug("exceeded maximum retries")
|
||||||
return nil, support.WrapAndAppend(itemID, errors.Wrap(retriesErr, "attachment failed"), nil)
|
return nil, support.WrapAndAppend(itemID,
|
||||||
|
support.ConnectorStackErrorTraceWrap(retriesErr, "attachment Failed"), nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/users"
|
||||||
)
|
)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@ -21,18 +21,6 @@ var (
|
|||||||
"owner": {},
|
"owner": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldsForEvents = map[string]struct{}{
|
|
||||||
"calendar": {},
|
|
||||||
"end": {},
|
|
||||||
"id": {},
|
|
||||||
"isOnlineMeeting": {},
|
|
||||||
"isReminderOn": {},
|
|
||||||
"responseStatus": {},
|
|
||||||
"responseRequested": {},
|
|
||||||
"showAs": {},
|
|
||||||
"subject": {},
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldsForFolders = map[string]struct{}{
|
fieldsForFolders = map[string]struct{}{
|
||||||
"childFolderCount": {},
|
"childFolderCount": {},
|
||||||
"displayName": {},
|
"displayName": {},
|
||||||
@ -112,6 +100,28 @@ func optionsForCalendars(moreOps []string) (
|
|||||||
return options, nil
|
return options, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optionsForCalendarsByID places allowed options for exchange.Calendar object
|
||||||
|
// @param moreOps should reflect elements from fieldsForCalendars
|
||||||
|
// @return is first call in Calendars().GetWithRequestConfigurationAndResponseHandler
|
||||||
|
func optionsForCalendarsByID(moreOps []string) (
|
||||||
|
*users.ItemCalendarsCalendarItemRequestBuilderGetRequestConfiguration,
|
||||||
|
error,
|
||||||
|
) {
|
||||||
|
selecting, err := buildOptions(moreOps, fieldsForCalendars)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// should be a CalendarsRequestBuilderGetRequestConfiguration
|
||||||
|
requestParams := &users.ItemCalendarsCalendarItemRequestBuilderGetQueryParameters{
|
||||||
|
Select: selecting,
|
||||||
|
}
|
||||||
|
options := &users.ItemCalendarsCalendarItemRequestBuilderGetRequestConfiguration{
|
||||||
|
QueryParameters: requestParams,
|
||||||
|
}
|
||||||
|
|
||||||
|
return options, nil
|
||||||
|
}
|
||||||
|
|
||||||
// optionsForContactFolders places allowed options for exchange.ContactFolder object
|
// optionsForContactFolders places allowed options for exchange.ContactFolder object
|
||||||
// @return is first call in ContactFolders().GetWithRequestConfigurationAndResponseHandler
|
// @return is first call in ContactFolders().GetWithRequestConfigurationAndResponseHandler
|
||||||
func optionsForContactFolders(moreOps []string) (
|
func optionsForContactFolders(moreOps []string) (
|
||||||
@ -213,26 +223,6 @@ func optionsForContactFoldersItemDelta(
|
|||||||
return options, nil
|
return options, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// optionsForEvents ensures a valid option inputs for `exchange.Events` when selected from within a Calendar
|
|
||||||
func optionsForEventsByCalendarDelta(
|
|
||||||
moreOps []string,
|
|
||||||
) (*users.ItemCalendarsItemEventsDeltaRequestBuilderGetRequestConfiguration, error) {
|
|
||||||
selecting, err := buildOptions(moreOps, fieldsForEvents)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
requestParameters := &users.ItemCalendarsItemEventsDeltaRequestBuilderGetQueryParameters{
|
|
||||||
Select: selecting,
|
|
||||||
}
|
|
||||||
|
|
||||||
options := &users.ItemCalendarsItemEventsDeltaRequestBuilderGetRequestConfiguration{
|
|
||||||
QueryParameters: requestParameters,
|
|
||||||
}
|
|
||||||
|
|
||||||
return options, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// optionsForContactChildFolders builds a contacts child folders request.
|
// optionsForContactChildFolders builds a contacts child folders request.
|
||||||
func optionsForContactChildFolders(
|
func optionsForContactChildFolders(
|
||||||
moreOps []string,
|
moreOps []string,
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/uploadsession"
|
"github.com/alcionai/corso/src/internal/connector/uploadsession"
|
||||||
|
|||||||
@ -3,8 +3,8 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
msusers "github.com/microsoftgraph/msgraph-sdk-go/users"
|
msusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,9 +15,43 @@ var _ graph.ContainerResolver = &eventCalendarCache{}
|
|||||||
type eventCalendarCache struct {
|
type eventCalendarCache struct {
|
||||||
*containerResolver
|
*containerResolver
|
||||||
enumer containersEnumerator
|
enumer containersEnumerator
|
||||||
|
getter containerGetter
|
||||||
userID string
|
userID string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init ensures that the structure's fields are initialized.
|
||||||
|
// Fields Initialized when cache == nil:
|
||||||
|
// [mc.cache]
|
||||||
|
func (ecc *eventCalendarCache) init(
|
||||||
|
ctx context.Context,
|
||||||
|
) error {
|
||||||
|
if ecc.containerResolver == nil {
|
||||||
|
ecc.containerResolver = newContainerResolver()
|
||||||
|
}
|
||||||
|
|
||||||
|
return ecc.populateEventRoot(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// populateEventRoot manually fetches directories that are not returned during Graph for msgraph-sdk-go v. 40+
|
||||||
|
// DefaultCalendar is the traditional "Calendar".
|
||||||
|
// Action ensures that cache will stop at appropriate level.
|
||||||
|
// @error iff the struct is not properly instantiated
|
||||||
|
func (ecc *eventCalendarCache) populateEventRoot(ctx context.Context) error {
|
||||||
|
container := DefaultCalendar
|
||||||
|
|
||||||
|
f, err := ecc.getter.GetContainerByID(ctx, ecc.userID, container)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "fetching calendar "+support.ConnectorStackErrorTrace(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
temp := graph.NewCacheFolder(f, path.Builder{}.Append(container))
|
||||||
|
if err := ecc.addFolder(temp); err != nil {
|
||||||
|
return errors.Wrap(err, "initializing calendar resolver")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Populate utility function for populating eventCalendarCache.
|
// Populate utility function for populating eventCalendarCache.
|
||||||
// Executes 1 additional Graph Query
|
// Executes 1 additional Graph Query
|
||||||
// @param baseID: ignored. Present to conform to interface
|
// @param baseID: ignored. Present to conform to interface
|
||||||
@ -25,8 +60,8 @@ func (ecc *eventCalendarCache) Populate(
|
|||||||
baseID string,
|
baseID string,
|
||||||
baseContainerPath ...string,
|
baseContainerPath ...string,
|
||||||
) error {
|
) error {
|
||||||
if ecc.containerResolver == nil {
|
if err := ecc.init(ctx); err != nil {
|
||||||
ecc.containerResolver = newContainerResolver()
|
return errors.Wrap(err, "initializing")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := ecc.enumer.EnumerateContainers(ctx, ecc.userID, "", ecc.addFolder)
|
err := ecc.enumer.EnumerateContainers(ctx, ecc.userID, "", ecc.addFolder)
|
||||||
@ -34,6 +69,10 @@ func (ecc *eventCalendarCache) Populate(
|
|||||||
return errors.Wrap(err, "enumerating containers")
|
return errors.Wrap(err, "enumerating containers")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := ecc.populatePaths(ctx); err != nil {
|
||||||
|
return errors.Wrap(err, "establishing calendar paths")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"github.com/alcionai/corso/src/internal/observe"
|
"github.com/alcionai/corso/src/internal/observe"
|
||||||
@ -197,10 +198,6 @@ func (col *Collection) streamItems(ctx context.Context) {
|
|||||||
semaphoreCh := make(chan struct{}, urlPrefetchChannelBufferSize)
|
semaphoreCh := make(chan struct{}, urlPrefetchChannelBufferSize)
|
||||||
defer close(semaphoreCh)
|
defer close(semaphoreCh)
|
||||||
|
|
||||||
errUpdater := func(user string, err error) {
|
|
||||||
errs = support.WrapAndAppend(user, err, errs)
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete all removed items
|
// delete all removed items
|
||||||
for id := range col.removed {
|
for id := range col.removed {
|
||||||
semaphoreCh <- struct{}{}
|
semaphoreCh <- struct{}{}
|
||||||
@ -226,6 +223,14 @@ func (col *Collection) streamItems(ctx context.Context) {
|
|||||||
}(id)
|
}(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updaterMu := sync.Mutex{}
|
||||||
|
errUpdater := func(user string, err error) {
|
||||||
|
updaterMu.Lock()
|
||||||
|
defer updaterMu.Unlock()
|
||||||
|
|
||||||
|
errs = support.WrapAndAppend(user, err, errs)
|
||||||
|
}
|
||||||
|
|
||||||
// add any new items
|
// add any new items
|
||||||
for id := range col.added {
|
for id := range col.added {
|
||||||
if col.ctrl.FailFast && errs != nil {
|
if col.ctrl.FailFast && errs != nil {
|
||||||
@ -258,7 +263,18 @@ func (col *Collection) streamItems(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errUpdater(user, err)
|
// Don't report errors for deleted items as there's no way for us to
|
||||||
|
// back up data that is gone. Chalk them up as a "success" though since
|
||||||
|
// there's really nothing we can do and not reporting it will make the
|
||||||
|
// status code upset cause we won't have the same number of results as
|
||||||
|
// attempted items.
|
||||||
|
if e := graph.IsErrDeletedInFlight(err); e != nil {
|
||||||
|
atomic.AddInt64(&success, 1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
errUpdater(user, support.ConnectorStackErrorTraceWrap(err, "fetching item"))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,7 @@ func (suite *CacheResolverSuite) TestPopulate() {
|
|||||||
return &eventCalendarCache{
|
return &eventCalendarCache{
|
||||||
userID: tester.M365UserID(t),
|
userID: tester.M365UserID(t),
|
||||||
enumer: ac.Events(),
|
enumer: ac.Events(),
|
||||||
|
getter: ac.Events(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,14 +22,25 @@ type mailFolderCache struct {
|
|||||||
userID string
|
userID string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init ensures that the structure's fields are initialized.
|
||||||
|
// Fields Initialized when cache == nil:
|
||||||
|
// [mc.cache]
|
||||||
|
func (mc *mailFolderCache) init(
|
||||||
|
ctx context.Context,
|
||||||
|
) error {
|
||||||
|
if mc.containerResolver == nil {
|
||||||
|
mc.containerResolver = newContainerResolver()
|
||||||
|
}
|
||||||
|
|
||||||
|
return mc.populateMailRoot(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
// populateMailRoot manually fetches directories that are not returned during Graph for msgraph-sdk-go v. 40+
|
// populateMailRoot manually fetches directories that are not returned during Graph for msgraph-sdk-go v. 40+
|
||||||
// rootFolderAlias is the top-level directory for exchange.Mail.
|
// rootFolderAlias is the top-level directory for exchange.Mail.
|
||||||
// DefaultMailFolder is the traditional "Inbox" for exchange.Mail
|
// DefaultMailFolder is the traditional "Inbox" for exchange.Mail
|
||||||
// Action ensures that cache will stop at appropriate level.
|
// Action ensures that cache will stop at appropriate level.
|
||||||
// @error iff the struct is not properly instantiated
|
// @error iff the struct is not properly instantiated
|
||||||
func (mc *mailFolderCache) populateMailRoot(
|
func (mc *mailFolderCache) populateMailRoot(ctx context.Context) error {
|
||||||
ctx context.Context,
|
|
||||||
) error {
|
|
||||||
for _, fldr := range []string{rootFolderAlias, DefaultMailFolder} {
|
for _, fldr := range []string{rootFolderAlias, DefaultMailFolder} {
|
||||||
var directory string
|
var directory string
|
||||||
|
|
||||||
@ -76,16 +87,3 @@ func (mc *mailFolderCache) Populate(
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// init ensures that the structure's fields are initialized.
|
|
||||||
// Fields Initialized when cache == nil:
|
|
||||||
// [mc.cache]
|
|
||||||
func (mc *mailFolderCache) init(
|
|
||||||
ctx context.Context,
|
|
||||||
) error {
|
|
||||||
if mc.containerResolver == nil {
|
|
||||||
mc.containerResolver = newContainerResolver()
|
|
||||||
}
|
|
||||||
|
|
||||||
return mc.populateMailRoot(ctx)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -66,9 +66,11 @@ func PopulateExchangeContainerResolver(
|
|||||||
cacheRoot = DefaultContactFolder
|
cacheRoot = DefaultContactFolder
|
||||||
|
|
||||||
case path.EventsCategory:
|
case path.EventsCategory:
|
||||||
|
ecc := ac.Events()
|
||||||
res = &eventCalendarCache{
|
res = &eventCalendarCache{
|
||||||
userID: qp.ResourceOwner,
|
userID: qp.ResourceOwner,
|
||||||
enumer: ac.Events(),
|
getter: ecc,
|
||||||
|
enumer: ecc,
|
||||||
}
|
}
|
||||||
cacheRoot = DefaultCalendar
|
cacheRoot = DefaultCalendar
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"runtime/trace"
|
"runtime/trace"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
@ -507,9 +507,11 @@ func CreateContainerDestinaion(
|
|||||||
|
|
||||||
case path.EventsCategory:
|
case path.EventsCategory:
|
||||||
if directoryCache == nil {
|
if directoryCache == nil {
|
||||||
|
ace := ac.Events()
|
||||||
ecc := &eventCalendarCache{
|
ecc := &eventCalendarCache{
|
||||||
userID: user,
|
userID: user,
|
||||||
enumer: ac.Events(),
|
getter: ace,
|
||||||
|
enumer: ace,
|
||||||
}
|
}
|
||||||
caches[category] = ecc
|
caches[category] = ecc
|
||||||
newCache = true
|
newCache = true
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package graph
|
package graph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models/odataerrors"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
beta "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
@ -46,28 +45,6 @@ func (s Service) Client() *msgraphsdk.GraphServiceClient {
|
|||||||
return s.client
|
return s.client
|
||||||
}
|
}
|
||||||
|
|
||||||
// BetaService provides access to API Calls that are present solely in the Beta library.
|
|
||||||
// Does not fulfill the interface as the base libraries vary.
|
|
||||||
type BetaService struct {
|
|
||||||
adapter *beta.GraphRequestAdapter
|
|
||||||
client *beta.GraphBaseServiceClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs BetaService) Adapter() *beta.GraphRequestAdapter {
|
|
||||||
return bs.adapter
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs BetaService) Client() *beta.GraphBaseServiceClient {
|
|
||||||
return bs.client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewBetaService(adapter *beta.GraphRequestAdapter) *BetaService {
|
|
||||||
return &BetaService{
|
|
||||||
adapter: adapter,
|
|
||||||
client: beta.NewGraphBaseServiceClient(adapter),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seraialize writes an M365 parsable object into a byte array using the built-in
|
// Seraialize writes an M365 parsable object into a byte array using the built-in
|
||||||
// application/json writer within the adapter.
|
// application/json writer within the adapter.
|
||||||
func (s Service) Serialize(object absser.Parsable) ([]byte, error) {
|
func (s Service) Serialize(object absser.Parsable) ([]byte, error) {
|
||||||
|
|||||||
@ -10,8 +10,7 @@ import (
|
|||||||
az "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
az "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||||
ka "github.com/microsoft/kiota-authentication-azure-go"
|
ka "github.com/microsoft/kiota-authentication-azure-go"
|
||||||
khttp "github.com/microsoft/kiota-http-go"
|
khttp "github.com/microsoft/kiota-http-go"
|
||||||
beta "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
|
||||||
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@ -47,25 +46,6 @@ func CreateAdapter(tenant, client, secret string) (*msgraphsdk.GraphRequestAdapt
|
|||||||
auth, nil, nil, httpClient)
|
auth, nil, nil, httpClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateBetaAdapter uses the provided credentials with the Kiota Azure Libraries.
|
|
||||||
// Used to access msgraph-beta-sdk-go specific functionality
|
|
||||||
func CreateBetaAdapter(tenant, client, secret string) (*beta.GraphRequestAdapter, error) {
|
|
||||||
cred, err := az.NewClientSecretCredential(tenant, client, secret, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "creating beta m365 client credentials")
|
|
||||||
}
|
|
||||||
|
|
||||||
auth, err := ka.NewAzureIdentityAuthenticationProviderWithScopes(
|
|
||||||
cred,
|
|
||||||
[]string{"https://graph.microsoft.com/.default"},
|
|
||||||
)
|
|
||||||
|
|
||||||
httpClient := CreateHTTPClient()
|
|
||||||
|
|
||||||
return beta.NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(
|
|
||||||
auth, nil, nil, httpClient)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateHTTPClient creates the httpClient with middlewares and timeout configured
|
// CreateHTTPClient creates the httpClient with middlewares and timeout configured
|
||||||
func CreateHTTPClient() *http.Client {
|
func CreateHTTPClient() *http.Client {
|
||||||
clientOptions := msgraphsdk.GetDefaultClientOptions()
|
clientOptions := msgraphsdk.GetDefaultClientOptions()
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package graph_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
@ -43,21 +43,6 @@ func (suite *GraphUnitSuite) TestCreateAdapter() {
|
|||||||
assert.NotNil(t, adpt)
|
assert.NotNil(t, adpt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GraphUnitSuite) TestBetaService() {
|
|
||||||
t := suite.T()
|
|
||||||
adpt, err := graph.CreateBetaAdapter(
|
|
||||||
suite.credentials.AzureTenantID,
|
|
||||||
suite.credentials.AzureClientID,
|
|
||||||
suite.credentials.AzureClientSecret,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert.NoError(t, err)
|
|
||||||
require.NotNil(t, adpt)
|
|
||||||
|
|
||||||
serv := graph.NewBetaService(adpt)
|
|
||||||
assert.NotNil(t, serv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (suite *GraphUnitSuite) TestSerializationEndPoint() {
|
func (suite *GraphUnitSuite) TestSerializationEndPoint() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
adpt, err := graph.CreateAdapter(
|
adpt, err := graph.CreateAdapter(
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -335,12 +335,12 @@ func checkContact(
|
|||||||
testEmptyOrEqual(t, expected.GetAssistantName(), got.GetAssistantName(), "AssistantName")
|
testEmptyOrEqual(t, expected.GetAssistantName(), got.GetAssistantName(), "AssistantName")
|
||||||
|
|
||||||
testEmptyOrEqual(t, expected.GetBirthday(), got.GetBirthday(), "Birthday")
|
testEmptyOrEqual(t, expected.GetBirthday(), got.GetBirthday(), "Birthday")
|
||||||
|
// Not present in msgraph-beta-sdk/models
|
||||||
assert.Equal(t, expected.GetBusinessAddress(), got.GetBusinessAddress())
|
// assert.Equal(t, expected.GetBusinessAddress(), got.GetBusinessAddress())
|
||||||
|
// Not present in msgraph-beta-sdk/models
|
||||||
testEmptyOrEqual(t, expected.GetBusinessHomePage(), got.GetBusinessHomePage(), "BusinessHomePage")
|
// testEmptyOrEqual(t, expected.GetBusinessHomePage(), got.GetBusinessHomePage(), "BusinessHomePage")
|
||||||
|
// Not present in msgraph-beta-sdk/models
|
||||||
assert.Equal(t, expected.GetBusinessPhones(), got.GetBusinessPhones())
|
// assert.Equal(t, expected.GetBusinessPhones(), got.GetBusinessPhones())
|
||||||
|
|
||||||
assert.Equal(t, expected.GetCategories(), got.GetCategories())
|
assert.Equal(t, expected.GetCategories(), got.GetCategories())
|
||||||
|
|
||||||
@ -364,9 +364,10 @@ func checkContact(
|
|||||||
|
|
||||||
testEmptyOrEqual(t, expected.GetGivenName(), got.GetGivenName(), "GivenName")
|
testEmptyOrEqual(t, expected.GetGivenName(), got.GetGivenName(), "GivenName")
|
||||||
|
|
||||||
assert.Equal(t, expected.GetHomeAddress(), got.GetHomeAddress())
|
// Not present in msgraph-beta-sdk/models
|
||||||
|
// assert.Equal(t, expected.GetHomeAddress(), got.GetHomeAddress())
|
||||||
assert.Equal(t, expected.GetHomePhones(), got.GetHomePhones())
|
// Not present in msgraph-beta-sdk/models
|
||||||
|
// assert.Equal(t, expected.GetHomePhones(), got.GetHomePhones())
|
||||||
|
|
||||||
// Skip CreatedDateTime as it's tied to this specific instance of the item.
|
// Skip CreatedDateTime as it's tied to this specific instance of the item.
|
||||||
|
|
||||||
@ -382,13 +383,14 @@ func checkContact(
|
|||||||
|
|
||||||
testEmptyOrEqual(t, expected.GetMiddleName(), got.GetMiddleName(), "MiddleName")
|
testEmptyOrEqual(t, expected.GetMiddleName(), got.GetMiddleName(), "MiddleName")
|
||||||
|
|
||||||
testEmptyOrEqual(t, expected.GetMobilePhone(), got.GetMobilePhone(), "MobilePhone")
|
// Not present in msgraph-beta-sdk/models
|
||||||
|
// testEmptyOrEqual(t, expected.GetMobilePhone(), got.GetMobilePhone(), "MobilePhone")
|
||||||
|
|
||||||
testEmptyOrEqual(t, expected.GetNickName(), got.GetNickName(), "NickName")
|
testEmptyOrEqual(t, expected.GetNickName(), got.GetNickName(), "NickName")
|
||||||
|
|
||||||
testEmptyOrEqual(t, expected.GetOfficeLocation(), got.GetOfficeLocation(), "OfficeLocation")
|
testEmptyOrEqual(t, expected.GetOfficeLocation(), got.GetOfficeLocation(), "OfficeLocation")
|
||||||
|
// Not present in msgraph-beta-sdk/models
|
||||||
assert.Equal(t, expected.GetOtherAddress(), got.GetOtherAddress())
|
// assert.Equal(t, expected.GetOtherAddress(), got.GetOtherAddress())
|
||||||
|
|
||||||
// Skip ParentFolderId as it's tied to this specific instance of the item.
|
// Skip ParentFolderId as it's tied to this specific instance of the item.
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kioser "github.com/microsoft/kiota-serialization-json-go"
|
kioser "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kw "github.com/microsoft/kiota-serialization-json-go"
|
kw "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/spatialcurrent/go-lazy/pkg/lazy"
|
"github.com/spatialcurrent/go-lazy/pkg/lazy"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|||||||
@ -6,12 +6,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
msdrive "github.com/microsoftgraph/msgraph-beta-sdk-go/drive"
|
||||||
|
msdrives "github.com/microsoftgraph/msgraph-beta-sdk-go/drives"
|
||||||
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models/odataerrors"
|
||||||
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
|
||||||
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
||||||
msdrive "github.com/microsoftgraph/msgraph-sdk-go/drive"
|
|
||||||
msdrives "github.com/microsoftgraph/msgraph-sdk-go/drives"
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/sites"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -76,7 +76,8 @@ const (
|
|||||||
itemChildrenRawURLFmt = "https://graph.microsoft.com/v1.0/drives/%s/items/%s/children"
|
itemChildrenRawURLFmt = "https://graph.microsoft.com/v1.0/drives/%s/items/%s/children"
|
||||||
itemByPathRawURLFmt = "https://graph.microsoft.com/v1.0/drives/%s/items/%s:/%s"
|
itemByPathRawURLFmt = "https://graph.microsoft.com/v1.0/drives/%s/items/%s:/%s"
|
||||||
itemNotFoundErrorCode = "itemNotFound"
|
itemNotFoundErrorCode = "itemNotFound"
|
||||||
userDoesNotHaveDrive = "BadRequest Unable to retrieve user's mysite URL"
|
userMysiteURLNotFound = "BadRequest Unable to retrieve user's mysite URL"
|
||||||
|
userMysiteNotFound = "ResourceNotFound User's mysite not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enumerates the drives for the specified user
|
// Enumerates the drives for the specified user
|
||||||
@ -134,7 +135,8 @@ func userDrives(ctx context.Context, service graph.Servicer, user string) ([]mod
|
|||||||
r, err = service.Client().UsersById(user).Drives().Get(ctx, nil)
|
r, err = service.Client().UsersById(user).Drives().Get(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
detailedError := support.ConnectorStackErrorTrace(err)
|
detailedError := support.ConnectorStackErrorTrace(err)
|
||||||
if strings.Contains(detailedError, userDoesNotHaveDrive) {
|
if strings.Contains(detailedError, userMysiteURLNotFound) ||
|
||||||
|
strings.Contains(detailedError, userMysiteNotFound) {
|
||||||
logger.Ctx(ctx).Debugf("User %s does not have a drive", user)
|
logger.Ctx(ctx).Debugf("User %s does not have a drive", user)
|
||||||
return make([]models.Driveable, 0), nil // no license
|
return make([]models.Driveable, 0), nil // no license
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
msdrives "github.com/microsoftgraph/msgraph-sdk-go/drives"
|
msdrives "github.com/microsoftgraph/msgraph-beta-sdk-go/drives"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package onedrive
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import (
|
|||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
|
|
||||||
kw "github.com/microsoft/kiota-serialization-json-go"
|
kw "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
@ -50,7 +50,6 @@ type Collection struct {
|
|||||||
// M365 IDs of the items of this collection
|
// M365 IDs of the items of this collection
|
||||||
category DataCategory
|
category DataCategory
|
||||||
service graph.Servicer
|
service graph.Servicer
|
||||||
bService graph.BetaService
|
|
||||||
statusUpdater support.StatusUpdater
|
statusUpdater support.StatusUpdater
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kioser "github.com/microsoft/kiota-serialization-json-go"
|
kioser "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/sites"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|||||||
@ -168,16 +168,9 @@ func collectPages(
|
|||||||
) ([]data.Collection, error) {
|
) ([]data.Collection, error) {
|
||||||
logger.Ctx(ctx).With("site", siteID).Debug("Creating SharePoint Pages collections")
|
logger.Ctx(ctx).With("site", siteID).Debug("Creating SharePoint Pages collections")
|
||||||
|
|
||||||
adpt, err := graph.CreateBetaAdapter(creds.AzureTenantID, creds.AzureClientID, creds.AzureClientSecret)
|
|
||||||
if err != nil {
|
|
||||||
return nil, support.ConnectorStackErrorTraceWrap(err, "fetching beta adapter")
|
|
||||||
}
|
|
||||||
|
|
||||||
service := graph.NewBetaService(adpt)
|
|
||||||
|
|
||||||
spcs := make([]data.Collection, 0)
|
spcs := make([]data.Collection, 0)
|
||||||
|
|
||||||
tuples, err := fetchPages(ctx, *service, siteID)
|
tuples, err := fetchPages(ctx, serv, siteID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
mssite "github.com/microsoftgraph/msgraph-sdk-go/sites"
|
mssite "github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
bmodel "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
)
|
)
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
// sharePointPageInfo propagates metadata from the SharePoint Page data type
|
// sharePointPageInfo propagates metadata from the SharePoint Page data type
|
||||||
// into searchable content.
|
// into searchable content.
|
||||||
// Page Details: https://learn.microsoft.com/en-us/graph/api/resources/sitepage?view=graph-rest-beta
|
// Page Details: https://learn.microsoft.com/en-us/graph/api/resources/sitepage?view=graph-rest-beta
|
||||||
func sharePointPageInfo(page bmodel.SitePageable, size int64) *details.SharePointInfo {
|
func sharePointPageInfo(page models.SitePageable, size int64) *details.SharePointInfo {
|
||||||
var (
|
var (
|
||||||
name, webURL string
|
name, webURL string
|
||||||
created, modified time.Time
|
created, modified time.Time
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
bmodel "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
@ -12,20 +12,20 @@ import (
|
|||||||
func (suite *SharePointInfoSuite) TestSharePointInfo_Pages() {
|
func (suite *SharePointInfoSuite) TestSharePointInfo_Pages() {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pageAndDeets func() (bmodel.SitePageable, *details.SharePointInfo)
|
pageAndDeets func() (models.SitePageable, *details.SharePointInfo)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Empty Page",
|
name: "Empty Page",
|
||||||
pageAndDeets: func() (bmodel.SitePageable, *details.SharePointInfo) {
|
pageAndDeets: func() (models.SitePageable, *details.SharePointInfo) {
|
||||||
deets := &details.SharePointInfo{ItemType: details.SharePointItem}
|
deets := &details.SharePointInfo{ItemType: details.SharePointItem}
|
||||||
return bmodel.NewSitePage(), deets
|
return models.NewSitePage(), deets
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Only Name",
|
name: "Only Name",
|
||||||
pageAndDeets: func() (bmodel.SitePageable, *details.SharePointInfo) {
|
pageAndDeets: func() (models.SitePageable, *details.SharePointInfo) {
|
||||||
title := "Blank Page"
|
title := "Blank Page"
|
||||||
sPage := bmodel.NewSitePage()
|
sPage := models.NewSitePage()
|
||||||
sPage.SetTitle(&title)
|
sPage.SetTitle(&title)
|
||||||
deets := &details.SharePointInfo{
|
deets := &details.SharePointInfo{
|
||||||
ItemType: details.SharePointItem,
|
ItemType: details.SharePointItem,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
mssite "github.com/microsoftgraph/msgraph-sdk-go/sites"
|
mssite "github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"runtime/trace"
|
"runtime/trace"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -3,32 +3,25 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
bmodel "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetSitePages retrieves a collection of Pages related to the give Site.
|
// GetSitePages retrieves a collection of Pages related to the give Site.
|
||||||
// Returns error if error experienced during the call
|
// Returns error if error experienced during the call
|
||||||
func GetSitePage(
|
func GetSitePage(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
creds account.M365Config,
|
serv graph.Servicer,
|
||||||
siteID string,
|
siteID string,
|
||||||
pages []string,
|
pages []string,
|
||||||
) ([]bmodel.SitePageable, error) {
|
) ([]models.SitePageable, error) {
|
||||||
adpt, err := graph.CreateBetaAdapter(creds.AzureTenantID, creds.AzureClientID, creds.AzureClientSecret)
|
col := make([]models.SitePageable, 0)
|
||||||
if err != nil {
|
|
||||||
return nil, support.ConnectorStackErrorTraceWrap(err, "fetching beta adapter")
|
|
||||||
}
|
|
||||||
|
|
||||||
service := graph.NewBetaService(adpt)
|
|
||||||
col := make([]bmodel.SitePageable, 0)
|
|
||||||
|
|
||||||
for _, entry := range pages {
|
for _, entry := range pages {
|
||||||
page, err := service.Client().SitesById(siteID).PagesById(entry).Get(ctx, nil)
|
page, err := serv.Client().SitesById(siteID).PagesById(entry).Get(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, support.ConnectorStackErrorTraceWrap(err, "fetching page: "+entry)
|
return nil, support.ConnectorStackErrorTraceWrap(err, "fetching page: "+entry)
|
||||||
}
|
}
|
||||||
@ -40,7 +33,7 @@ func GetSitePage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetchPages utility function to return the tuple of item
|
// fetchPages utility function to return the tuple of item
|
||||||
func fetchPages(ctx context.Context, bs graph.BetaService, siteID string) ([]listTuple, error) {
|
func fetchPages(ctx context.Context, bs graph.Servicer, siteID string) ([]listTuple, error) {
|
||||||
var (
|
var (
|
||||||
builder = bs.Client().SitesById(siteID).Pages()
|
builder = bs.Client().SitesById(siteID).Pages()
|
||||||
opts = fetchPageOptions()
|
opts = fetchPageOptions()
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
package sharepoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SitePageable adjusted from msgraph-beta-sdk-go for temporary testing
|
|
||||||
type SitePageable interface {
|
|
||||||
models.BaseItemable
|
|
||||||
serialization.Parsable
|
|
||||||
GetContentType() models.ContentTypeInfoable
|
|
||||||
GetPublishingState() models.PublicationFacetable
|
|
||||||
GetShowComments() *bool
|
|
||||||
GetShowRecommendedPages() *bool
|
|
||||||
GetThumbnailWebUrl() *string
|
|
||||||
GetTitle() *string
|
|
||||||
SetContentType(value models.ContentTypeInfoable)
|
|
||||||
SetPublishingState(value models.PublicationFacetable)
|
|
||||||
SetShowComments(value *bool)
|
|
||||||
SetShowRecommendedPages(value *bool)
|
|
||||||
SetThumbnailWebUrl(value *string)
|
|
||||||
SetTitle(value *string)
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ package support
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type attendee struct {
|
type attendee struct {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
multierror "github.com/hashicorp/go-multierror"
|
multierror "github.com/hashicorp/go-multierror"
|
||||||
msgraph_errors "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
msgraph_errors "github.com/microsoftgraph/msgraph-beta-sdk-go/models/odataerrors"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
package support
|
package support
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
js "github.com/microsoft/kiota-serialization-json-go"
|
js "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,3 +73,14 @@ func CreateListFromBytes(bytes []byte) (models.Listable, error) {
|
|||||||
|
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HasAttachments(body models.ItemBodyable) bool {
|
||||||
|
if body.GetContent() == nil || body.GetContentType() == nil ||
|
||||||
|
*body.GetContentType() == models.TEXT_BODYTYPE || len(*body.GetContent()) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
content := *body.GetContent()
|
||||||
|
|
||||||
|
return strings.Contains(content, "src=\"cid:")
|
||||||
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package support
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
@ -159,3 +160,56 @@ func (suite *DataSupportSuite) TestCreateListFromBytes() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *DataSupportSuite) TestHasAttachments() {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
hasAttachment assert.BoolAssertionFunc
|
||||||
|
getBodyable func(t *testing.T) models.ItemBodyable
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Mock w/out attachment",
|
||||||
|
hasAttachment: assert.False,
|
||||||
|
getBodyable: func(t *testing.T) models.ItemBodyable {
|
||||||
|
byteArray := mockconnector.GetMockMessageWithBodyBytes(
|
||||||
|
"Test",
|
||||||
|
"This is testing",
|
||||||
|
"This is testing",
|
||||||
|
)
|
||||||
|
message, err := CreateMessageFromBytes(byteArray)
|
||||||
|
require.NoError(t, err)
|
||||||
|
return message.GetBody()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Mock w/ inline attachment",
|
||||||
|
hasAttachment: assert.True,
|
||||||
|
getBodyable: func(t *testing.T) models.ItemBodyable {
|
||||||
|
byteArray := mockconnector.GetMessageWithOneDriveAttachment("Test legacy")
|
||||||
|
message, err := CreateMessageFromBytes(byteArray)
|
||||||
|
require.NoError(t, err)
|
||||||
|
return message.GetBody()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Edge Case",
|
||||||
|
hasAttachment: assert.True,
|
||||||
|
getBodyable: func(t *testing.T) models.ItemBodyable {
|
||||||
|
//nolint:lll
|
||||||
|
content := "<html><head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\" style=\"display:none\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style></head><body dir=\"ltr\"><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\">Happy New Year,</div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\"><br></div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\">In accordance with TPS report guidelines, there have been questions about how to address our activities SharePoint Cover page. Do you believe this is the best picture? </div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\"><br></div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\"><img class=\"FluidPluginCopy ContentPasted0 w-2070 h-1380\" size=\"5854817\" data-outlook-trace=\"F:1|T:1\" src=\"cid:85f4faa3-9851-40c7-ba0a-e63dce1185f9\" style=\"max-width:100%\"><br></div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\"><br></div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\">Let me know if this meets our culture requirements.</div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\"><br></div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\">Warm Regards,</div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\"><br></div><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\">Dustin</div></body></html>"
|
||||||
|
body := models.NewItemBody()
|
||||||
|
body.SetContent(&content)
|
||||||
|
cat := models.HTML_BODYTYPE
|
||||||
|
body.SetContentType(&cat)
|
||||||
|
return body
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
|
found := HasAttachments(test.getBodyable(t))
|
||||||
|
test.hasAttachment(t, found)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package support
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CloneMessageableFields places data from original data into new message object.
|
// CloneMessageableFields places data from original data into new message object.
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package support
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/users"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|||||||
@ -111,8 +111,7 @@ func readTestConfig() (map[string]string, error) {
|
|||||||
TestCfgUserID,
|
TestCfgUserID,
|
||||||
os.Getenv(EnvCorsoM365TestUserID),
|
os.Getenv(EnvCorsoM365TestUserID),
|
||||||
vpr.GetString(TestCfgUserID),
|
vpr.GetString(TestCfgUserID),
|
||||||
"lynner@8qzvrj.onmicrosoft.com",
|
"conneri@8qzvrj.onmicrosoft.com",
|
||||||
//"lidiah@8qzvrj.onmicrosoft.com",
|
|
||||||
)
|
)
|
||||||
fallbackTo(
|
fallbackTo(
|
||||||
testEnv,
|
testEnv,
|
||||||
@ -120,7 +119,6 @@ func readTestConfig() (map[string]string, error) {
|
|||||||
os.Getenv(EnvCorsoSecondaryM365TestUserID),
|
os.Getenv(EnvCorsoSecondaryM365TestUserID),
|
||||||
vpr.GetString(TestCfgSecondaryUserID),
|
vpr.GetString(TestCfgSecondaryUserID),
|
||||||
"lidiah@8qzvrj.onmicrosoft.com",
|
"lidiah@8qzvrj.onmicrosoft.com",
|
||||||
//"lynner@8qzvrj.onmicrosoft.com",
|
|
||||||
)
|
)
|
||||||
fallbackTo(
|
fallbackTo(
|
||||||
testEnv,
|
testEnv,
|
||||||
@ -134,7 +132,7 @@ func readTestConfig() (map[string]string, error) {
|
|||||||
TestCfgLoadTestOrgUsers,
|
TestCfgLoadTestOrgUsers,
|
||||||
os.Getenv(EnvCorsoM365LoadTestOrgUsers),
|
os.Getenv(EnvCorsoM365LoadTestOrgUsers),
|
||||||
vpr.GetString(TestCfgLoadTestOrgUsers),
|
vpr.GetString(TestCfgLoadTestOrgUsers),
|
||||||
"lidiah@8qzvrj.onmicrosoft.com,lynner@8qzvrj.onmicrosoft.com",
|
"lidiah@8qzvrj.onmicrosoft.com,conneri@8qzvrj.onmicrosoft.com",
|
||||||
)
|
)
|
||||||
fallbackTo(
|
fallbackTo(
|
||||||
testEnv,
|
testEnv,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package m365
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector"
|
"github.com/alcionai/corso/src/internal/connector"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user