From c99550984e5eb3644e9308de281e62ebcfa27fa1 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 12 Jul 2024 12:00:18 +0200 Subject: [PATCH] change providerv1beta1.Reference to pointer Signed-off-by: Christian Richter --- .../pkg/connector/contentconnector.go | 6 +++--- .../pkg/connector/contentconnector_test.go | 4 ++-- .../pkg/connector/fileconnector.go | 18 +++++++++--------- .../pkg/connector/fileconnector_test.go | 2 +- .../pkg/middleware/wopicontext.go | 2 +- .../pkg/service/grpc/v0/service.go | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/services/collaboration/pkg/connector/contentconnector.go b/services/collaboration/pkg/connector/contentconnector.go index 5de55c7963..f450ef5c47 100644 --- a/services/collaboration/pkg/connector/contentconnector.go +++ b/services/collaboration/pkg/connector/contentconnector.go @@ -71,7 +71,7 @@ func (c *ContentConnector) GetFile(ctx context.Context, writer io.Writer) error // Initiate download request req := &providerv1beta1.InitiateFileDownloadRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, } if wopiContext.ViewMode == appproviderv1beta1.ViewMode_VIEW_MODE_VIEW_ONLY && wopiContext.ViewOnlyToken != "" { @@ -206,7 +206,7 @@ func (c *ContentConnector) PutFile(ctx context.Context, stream io.Reader, stream // We need a stat call on the target file in order to get both the lock // (if any) and the current size of the file statRes, err := c.gwc.Stat(ctx, &providerv1beta1.StatRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, }) if err != nil { logger.Error().Err(err).Msg("PutFile: stat failed") @@ -254,7 +254,7 @@ func (c *ContentConnector) PutFile(ctx context.Context, stream io.Reader, stream req := &providerv1beta1.InitiateFileUploadRequest{ Opaque: opaque, - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, LockId: lockID, Options: &providerv1beta1.InitiateFileUploadRequest_IfMatch{ IfMatch: statRes.GetInfo().GetEtag(), diff --git a/services/collaboration/pkg/connector/contentconnector_test.go b/services/collaboration/pkg/connector/contentconnector_test.go index 581bb3b78d..aaf9fecf7d 100644 --- a/services/collaboration/pkg/connector/contentconnector_test.go +++ b/services/collaboration/pkg/connector/contentconnector_test.go @@ -44,7 +44,7 @@ var _ = Describe("ContentConnector", func() { wopiCtx = middleware.WopiContext{ AccessToken: "abcdef123456", - FileReference: providerv1beta1.Reference{ + FileReference: &providerv1beta1.Reference{ ResourceId: &providerv1beta1.ResourceId{ StorageId: "abc", OpaqueId: "12345", @@ -178,7 +178,7 @@ var _ = Describe("ContentConnector", func() { wopiCtx = middleware.WopiContext{ AccessToken: "abcdef123456", ViewOnlyToken: "view.only.123456", - FileReference: providerv1beta1.Reference{ + FileReference: &providerv1beta1.Reference{ ResourceId: &providerv1beta1.ResourceId{ StorageId: "abc", OpaqueId: "12345", diff --git a/services/collaboration/pkg/connector/fileconnector.go b/services/collaboration/pkg/connector/fileconnector.go index 720757f5cf..59689286c9 100644 --- a/services/collaboration/pkg/connector/fileconnector.go +++ b/services/collaboration/pkg/connector/fileconnector.go @@ -89,7 +89,7 @@ func (f *FileConnector) GetLock(ctx context.Context) (string, error) { logger := zerolog.Ctx(ctx) req := &providerv1beta1.GetLockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, } resp, err := f.gwc.GetLock(ctx, req) @@ -158,7 +158,7 @@ func (f *FileConnector) Lock(ctx context.Context, lockID, oldLockID string) (str if oldLockID == "" { // If the oldLockID is empty, this is a "LOCK" request req := &providerv1beta1.SetLockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, Lock: &providerv1beta1.Lock{ LockId: lockID, AppName: f.cfg.App.LockName + "." + f.cfg.App.Name, @@ -179,7 +179,7 @@ func (f *FileConnector) Lock(ctx context.Context, lockID, oldLockID string) (str // If the oldLockID isn't empty, this is a "UnlockAndRelock" request. We'll // do a "RefreshLock" in reva and provide the old lock req := &providerv1beta1.RefreshLockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, Lock: &providerv1beta1.Lock{ LockId: lockID, AppName: f.cfg.App.LockName + "." + f.cfg.App.Name, @@ -211,7 +211,7 @@ func (f *FileConnector) Lock(ctx context.Context, lockID, oldLockID string) (str // In both cases, we need to get the current lock to return it in a // 409 response if needed req := &providerv1beta1.GetLockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, } resp, err := f.gwc.GetLock(ctx, req) @@ -292,7 +292,7 @@ func (f *FileConnector) RefreshLock(ctx context.Context, lockID string) (string, } req := &providerv1beta1.RefreshLockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, Lock: &providerv1beta1.Lock{ LockId: lockID, AppName: f.cfg.App.LockName + "." + f.cfg.App.Name, @@ -330,7 +330,7 @@ func (f *FileConnector) RefreshLock(ctx context.Context, lockID string) (string, // Either the file is unlocked or there is no lock // We need to return 409 with the current lock req := &providerv1beta1.GetLockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, } resp, err := f.gwc.GetLock(ctx, req) @@ -400,7 +400,7 @@ func (f *FileConnector) UnLock(ctx context.Context, lockID string) (string, erro } req := &providerv1beta1.UnlockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, Lock: &providerv1beta1.Lock{ LockId: lockID, AppName: f.cfg.App.LockName + "." + f.cfg.App.Name, @@ -424,7 +424,7 @@ func (f *FileConnector) UnLock(ctx context.Context, lockID string) (string, erro case rpcv1beta1.Code_CODE_LOCKED: // We need to return 409 with the current lock req := &providerv1beta1.GetLockRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, } resp, err := f.gwc.GetLock(ctx, req) @@ -485,7 +485,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (fileinfo.FileInfo, e logger := zerolog.Ctx(ctx) statRes, err := f.gwc.Stat(ctx, &providerv1beta1.StatRequest{ - Ref: &wopiContext.FileReference, + Ref: wopiContext.FileReference, }) if err != nil { logger.Error().Err(err).Msg("CheckFileInfo: stat failed") diff --git a/services/collaboration/pkg/connector/fileconnector_test.go b/services/collaboration/pkg/connector/fileconnector_test.go index 7669e8a570..75cead43bf 100644 --- a/services/collaboration/pkg/connector/fileconnector_test.go +++ b/services/collaboration/pkg/connector/fileconnector_test.go @@ -39,7 +39,7 @@ var _ = Describe("FileConnector", func() { wopiCtx = middleware.WopiContext{ AccessToken: "abcdef123456", - FileReference: providerv1beta1.Reference{ + FileReference: &providerv1beta1.Reference{ ResourceId: &providerv1beta1.ResourceId{ StorageId: "abc", OpaqueId: "12345", diff --git a/services/collaboration/pkg/middleware/wopicontext.go b/services/collaboration/pkg/middleware/wopicontext.go index dfba554058..e9998c0d75 100644 --- a/services/collaboration/pkg/middleware/wopicontext.go +++ b/services/collaboration/pkg/middleware/wopicontext.go @@ -25,7 +25,7 @@ const ( type WopiContext struct { AccessToken string ViewOnlyToken string - FileReference providerv1beta1.Reference + FileReference *providerv1beta1.Reference User *userv1beta1.User ViewMode appproviderv1beta1.ViewMode EditAppUrl string diff --git a/services/collaboration/pkg/service/grpc/v0/service.go b/services/collaboration/pkg/service/grpc/v0/service.go index d0e6361447..4dfa90a280 100644 --- a/services/collaboration/pkg/service/grpc/v0/service.go +++ b/services/collaboration/pkg/service/grpc/v0/service.go @@ -214,7 +214,7 @@ func (s *Service) OpenInApp( wopiContext := middleware.WopiContext{ AccessToken: cryptedReqAccessToken, ViewOnlyToken: utils.ReadPlainFromOpaque(req.GetOpaque(), "viewOnlyToken"), - FileReference: providerFileRef, + FileReference: &providerFileRef, User: user, ViewMode: req.GetViewMode(), EditAppUrl: editAppURL,