Skip to content

Commit

Permalink
The libregraph public link type representation added to the PROPFIND …
Browse files Browse the repository at this point in the history
…response
  • Loading branch information
2403905 committed Jun 11, 2024
1 parent 40abb34 commit fde0fec
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/ocdav-link-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: The public link type added

The libregraph public link type representation added to the PROPFIND response.

https://github.com/cs3org/reva/pull/4722
6 changes: 6 additions & 0 deletions internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,12 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
} else {
appendToNotFound(prop.NotFound("oc:public-link-permission"))
}
case "public-link-type": // only on a share root node
if ls != nil && md.PermissionSet != nil {
appendToOK(prop.Escaped("oc:public-link-type", role.OCSPermissionsToPublicLinkType(md.Type)))
} else {
appendToNotFound(prop.NotFound("oc:public-link-type"))
}
case "public-link-item-type": // only on a share root node
if ls != nil {
if md.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER {
Expand Down
23 changes: 23 additions & 0 deletions pkg/conversions/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,29 @@ func (r *Role) WebDAVPermissions(isDir, isShared, isMountpoint, isPublic bool) s
return b.String()
}

// OCSPermissionsToPublicLinkType converts the public link OCSPermission to the sharingLinkType representation
//
// VIEW SharingLinkType = "view"
// UPLOAD SharingLinkType = "upload"
// EDIT SharingLinkType = "edit"
// CREATE_ONLY SharingLinkType = "createOnly"
func (r *Role) OCSPermissionsToPublicLinkType(rt provider.ResourceType) string {
p := r.OCSPermissions()
switch {
case p == PermissionRead:
return "view"
case p == PermissionRead|PermissionWrite && rt == provider.ResourceType_RESOURCE_TYPE_FILE:
return "edit"
case p == PermissionRead|PermissionCreate && rt == provider.ResourceType_RESOURCE_TYPE_CONTAINER:
return "upload"
case p == PermissionRead|PermissionWrite|PermissionCreate|PermissionDelete && rt == provider.ResourceType_RESOURCE_TYPE_CONTAINER:
return "edit"
case p == PermissionCreate && rt == provider.ResourceType_RESOURCE_TYPE_CONTAINER:
return "createOnly"
}
return ""
}

// RoleFromName creates a role from the name
func RoleFromName(name string) *Role {
switch name {
Expand Down

0 comments on commit fde0fec

Please sign in to comment.