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

add privatelink webdav property #3239

Merged
merged 1 commit into from
Sep 15, 2022
Merged
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/add-privatelink-dav.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add privatelink to PROPFIND response

We made it possible to request a privatelink WebDAV property.

https://github.com/cs3org/reva/pull/3239
13 changes: 8 additions & 5 deletions internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ func (p *Handler) HandleSpacesPropfind(w http.ResponseWriter, r *http.Request, s
}

p.propfindResponse(ctx, w, r, "", pf, sendTusHeaders, resourceInfos, sublog)

}

func (p *Handler) propfindResponse(ctx context.Context, w http.ResponseWriter, r *http.Request, namespace string, pf XML, sendTusHeaders bool, resourceInfos []*provider.ResourceInfo, log zerolog.Logger) {
Expand Down Expand Up @@ -985,7 +984,6 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
prop.Escaped("oc:fileid", id),
prop.Escaped("oc:spaceid", md.Id.SpaceId),
)

}

// we need to add the shareid if possible - the only way to extract it here is to parse it from the path
Expand Down Expand Up @@ -1303,6 +1301,14 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
} else {
propstatNotFound.Prop = append(propstatNotFound.Prop, prop.NotFound("oc:"+pf.Prop[i].Local))
}
case "privatelink":
privateURL, err := url.Parse(publicURL)
if err == nil {
privateURL.Path = path.Join(privateURL.Path, "f", storagespace.FormatResourceID(*md.Id))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:privatelink", privateURL.String()))
} else {
propstatNotFound.Prop = append(propstatNotFound.Prop, prop.NotFound("oc:privatelink"))
}
case "signature-auth":
if isPublic {
// We only want to add the attribute to the root of the propfind.
Expand All @@ -1327,9 +1333,6 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
if ref, err := storagespace.ParseReference(strings.TrimPrefix(md.Path, "/")); err == nil && ref.GetResourceId().GetSpaceId() == utils.ShareStorageSpaceID {
propstatOK.Prop = append(propstatOK.Prop, prop.Raw("oc:shareid", ref.GetResourceId().GetOpaqueId()))
}
case "privatelink": // phoenix only
// <oc:privatelink>https://phoenix.owncloud.com/f/9</oc:privatelink>
fallthrough
case "dDC": // desktop
fallthrough
case "data-fingerprint": // desktop
Expand Down