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

The libregraph public link type representation added to the PROPFIND response #4722

Open
wants to merge 1 commit into
base: edge
Choose a base branch
from
Open
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
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't think we should converting this based on the OCS permissions here. OCS is going to go a away at some point (and r.OCSPermissions() will hopefully go with it. IMO we should do the conversion based on the CS3ResourcePermissions.

In ocis (https://github.com/owncloud/ocis/blob/fc2318a5ef419c559a46fad41fbc22f6211f50ec/services/graph/pkg/linktype/linktype.go#L33) we already have function for converting ResourcePermissions to libregraph link types. Maybe we should move that into reva to make it reusable in graph and reva?

BTW, libregraph also defines a blocksDownload type. Do need that here as well?

Copy link
Author

@2403905 2403905 Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an obvious solution but it will lead to coping more code. Since LinkType is similar to UnifiedRoleDefinition and UnifiedRoleDefinition was moved from reva to graph, it seems to me there is no point in bringing back LinkType to reva. https://github.com/cs3org/reva/pull/4268/files

The blocksDownload is not used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhafer We could try to move the Link permission sets to the reva/pkg/convertions and keep the LinkType in a graph. Then we can use those sets for the permission conversations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@micbar Could we separate the LinkType and move the permission sets provider.ResourcePermissions from the graph to the reva/pkg/conversions that allows converting based on the OCS permissions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In would suggest the opposite. Move the ocdav service to ocis.

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
Loading