Skip to content

Commit

Permalink
Merge pull request #7908 from owncloud/edit-public-links
Browse files Browse the repository at this point in the history
Edit public links and setPassword
  • Loading branch information
micbar authored Dec 12, 2023
2 parents 13ea049 + 615cc20 commit 8eead1e
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 13 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/add-edit-public-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add edit public share to sharing NG

We added the ability to edit public shares to the sharing NG endpoints.

https://github.com/owncloud/ocis/pull/7908/
https://github.com/owncloud/ocis/issues/6993
2 changes: 1 addition & 1 deletion services/graph/pkg/errorcode/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func FromCS3Status(status *cs3rpc.Status, inerr error, ignore ...cs3rpc.Code) *E
case code == cs3rpc.Code_CODE_ALREADY_EXISTS:
err.errorCode = NameAlreadyExists
case code == cs3rpc.Code_CODE_FAILED_PRECONDITION:
err.errorCode = PreconditionFailed
err.errorCode = InvalidRequest
case code == cs3rpc.Code_CODE_OUT_OF_RANGE:
err.errorCode = InvalidRange
case code == cs3rpc.Code_CODE_UNIMPLEMENTED:
Expand Down
2 changes: 1 addition & 1 deletion services/graph/pkg/errorcode/cs3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestFromCS3Status(t *testing.T) {
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_UNAUTHENTICATED, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.Unauthenticated, "msg"))},
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_INVALID_ARGUMENT, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.InvalidRequest, "msg"))},
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_ALREADY_EXISTS, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.NameAlreadyExists, "msg"))},
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_FAILED_PRECONDITION, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.PreconditionFailed, "msg"))},
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_FAILED_PRECONDITION, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.InvalidRequest, "msg"))},
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_UNIMPLEMENTED, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.NotSupported, "msg"))},
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_INVALID, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.GeneralException, "msg"))},
{&cs3rpc.Status{Code: cs3rpc.Code_CODE_CANCELLED, Message: "msg"}, nil, nil, conversions.ToPointer(errorcode.New(errorcode.GeneralException, "msg"))},
Expand Down
2 changes: 2 additions & 0 deletions services/graph/pkg/errorcode/errorcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func (e Error) Render(w http.ResponseWriter, r *http.Request) {
status = http.StatusMethodNotAllowed
case ItemIsLocked:
status = http.StatusLocked
case PreconditionFailed:
status = http.StatusPreconditionFailed
default:
status = http.StatusInternalServerError
}
Expand Down
3 changes: 3 additions & 0 deletions services/graph/pkg/linktype/linktype.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func (l *LinkType) GetPermissions() *provider.ResourcePermissions {
// SharingLinkTypeFromCS3Permissions creates a libregraph link type
// It returns a list of libregraph actions when the conversion is not possible
func SharingLinkTypeFromCS3Permissions(permissions *linkv1beta1.PublicSharePermissions) (*libregraph.SharingLinkType, []string) {
if permissions == nil {
return nil, nil
}
linkTypes := GetAvailableLinkTypes()
for _, linkType := range linkTypes {
if grants.PermissionsEqual(linkType.GetPermissions(), permissions.GetPermissions()) {
Expand Down
11 changes: 9 additions & 2 deletions services/graph/pkg/service/v0/driveitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,18 @@ func (g Graph) UpdatePermission(w http.ResponseWriter, r *http.Request) {
return
}

// We don't implement updating link permissions yet
// This is a public link
if _, ok := oldPermission.GetLinkOk(); ok {
errorcode.NotSupported.Render(w, r, http.StatusNotImplemented, "not implemented")
updatedPermission, err := g.updatePublicLinkPermission(ctx, permissionID, &itemID, permission)
if err != nil {
errorcode.RenderError(w, r, err)
return
}
render.Status(r, http.StatusOK)
render.JSON(w, r, &updatedPermission)
return
}

// This is a user share
updatedPermission, err := g.updateUserShare(ctx, permissionID, oldPermission, permission)
if err != nil {
Expand Down
Loading

0 comments on commit 8eead1e

Please sign in to comment.