Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix update grants for the ocm share #5096

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-ocm-update-grants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix update grants for the OCM share

Fix update grants for the OCM share

https://github.com/cs3org/reva/pull/5096
https://github.com/owncloud/ocis/issues/11022
33 changes: 33 additions & 0 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,39 @@ func (s *svc) UpdateOCMShare(ctx context.Context, req *ocm.UpdateOCMShareRequest
return nil, errors.Wrap(err, "gateway: error calling UpdateOCMShare")
}

gRes, err := c.GetOCMShare(ctx, &ocm.GetOCMShareRequest{
Ref: req.Ref,
})
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling GetOCMShare")
}
if gRes.GetStatus().GetCode() != rpc.Code_CODE_OK {
return &ocm.UpdateOCMShareResponse{
Status: gRes.GetStatus(),
}, nil
}

creator, ok := ctxpkg.ContextGetUser(ctx)
if !ok {
return nil, errors.New("gateway: user not found in context")
}

grant := &provider.Grant{
Grantee: gRes.GetShare().GetGrantee(),
Permissions: gRes.GetShare().GetAccessMethods()[0].GetWebdavOptions().GetPermissions(),
Expiration: gRes.GetShare().GetExpiration(),
Creator: creator.GetId(),
}
updateGrantStatus, err := s.updateGrant(ctx, gRes.GetShare().GetResourceId(), grant, nil)
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling updateGrant")
}
if updateGrantStatus.GetCode() != rpc.Code_CODE_OK {
return &ocm.UpdateOCMShareResponse{
Status: updateGrantStatus,
}, nil
}

return res, nil
}

Expand Down
Loading