Skip to content

Commit fde0fec

Browse files
committed
The libregraph public link type representation added to the PROPFIND response
1 parent 40abb34 commit fde0fec

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: The public link type added
2+
3+
The libregraph public link type representation added to the PROPFIND response.
4+
5+
https://github.com/cs3org/reva/pull/4722

internal/http/services/owncloud/ocdav/propfind/propfind.go

+6
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,12 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
13441344
} else {
13451345
appendToNotFound(prop.NotFound("oc:public-link-permission"))
13461346
}
1347+
case "public-link-type": // only on a share root node
1348+
if ls != nil && md.PermissionSet != nil {
1349+
appendToOK(prop.Escaped("oc:public-link-type", role.OCSPermissionsToPublicLinkType(md.Type)))
1350+
} else {
1351+
appendToNotFound(prop.NotFound("oc:public-link-type"))
1352+
}
13471353
case "public-link-item-type": // only on a share root node
13481354
if ls != nil {
13491355
if md.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER {

pkg/conversions/role.go

+23
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,29 @@ func (r *Role) WebDAVPermissions(isDir, isShared, isMountpoint, isPublic bool) s
149149
return b.String()
150150
}
151151

152+
// OCSPermissionsToPublicLinkType converts the public link OCSPermission to the sharingLinkType representation
153+
//
154+
// VIEW SharingLinkType = "view"
155+
// UPLOAD SharingLinkType = "upload"
156+
// EDIT SharingLinkType = "edit"
157+
// CREATE_ONLY SharingLinkType = "createOnly"
158+
func (r *Role) OCSPermissionsToPublicLinkType(rt provider.ResourceType) string {
159+
p := r.OCSPermissions()
160+
switch {
161+
case p == PermissionRead:
162+
return "view"
163+
case p == PermissionRead|PermissionWrite && rt == provider.ResourceType_RESOURCE_TYPE_FILE:
164+
return "edit"
165+
case p == PermissionRead|PermissionCreate && rt == provider.ResourceType_RESOURCE_TYPE_CONTAINER:
166+
return "upload"
167+
case p == PermissionRead|PermissionWrite|PermissionCreate|PermissionDelete && rt == provider.ResourceType_RESOURCE_TYPE_CONTAINER:
168+
return "edit"
169+
case p == PermissionCreate && rt == provider.ResourceType_RESOURCE_TYPE_CONTAINER:
170+
return "createOnly"
171+
}
172+
return ""
173+
}
174+
152175
// RoleFromName creates a role from the name
153176
func RoleFromName(name string) *Role {
154177
switch name {

0 commit comments

Comments
 (0)