Skip to content

Commit 4a3a433

Browse files
authored
Merge pull request #5096 from 2403905/fix-ocm-update-grants
fix update grants for the ocm share
2 parents 5caf980 + 0d853da commit 4a3a433

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Bugfix: Fix update grants for the OCM share
2+
3+
Fix update grants for the OCM share
4+
5+
https://github.com/cs3org/reva/pull/5096
6+
https://github.com/owncloud/ocis/issues/11022

internal/grpc/services/gateway/ocmshareprovider.go

+33
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,39 @@ func (s *svc) UpdateOCMShare(ctx context.Context, req *ocm.UpdateOCMShareRequest
192192
return nil, errors.Wrap(err, "gateway: error calling UpdateOCMShare")
193193
}
194194

195+
gRes, err := c.GetOCMShare(ctx, &ocm.GetOCMShareRequest{
196+
Ref: req.Ref,
197+
})
198+
if err != nil {
199+
return nil, errors.Wrap(err, "gateway: error calling GetOCMShare")
200+
}
201+
if gRes.GetStatus().GetCode() != rpc.Code_CODE_OK {
202+
return &ocm.UpdateOCMShareResponse{
203+
Status: gRes.GetStatus(),
204+
}, nil
205+
}
206+
207+
creator, ok := ctxpkg.ContextGetUser(ctx)
208+
if !ok {
209+
return nil, errors.New("gateway: user not found in context")
210+
}
211+
212+
grant := &provider.Grant{
213+
Grantee: gRes.GetShare().GetGrantee(),
214+
Permissions: gRes.GetShare().GetAccessMethods()[0].GetWebdavOptions().GetPermissions(),
215+
Expiration: gRes.GetShare().GetExpiration(),
216+
Creator: creator.GetId(),
217+
}
218+
updateGrantStatus, err := s.updateGrant(ctx, gRes.GetShare().GetResourceId(), grant, nil)
219+
if err != nil {
220+
return nil, errors.Wrap(err, "gateway: error calling updateGrant")
221+
}
222+
if updateGrantStatus.GetCode() != rpc.Code_CODE_OK {
223+
return &ocm.UpdateOCMShareResponse{
224+
Status: updateGrantStatus,
225+
}, nil
226+
}
227+
195228
return res, nil
196229
}
197230

0 commit comments

Comments
 (0)