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

feat: add image and photo to propfind #4684

Merged
merged 1 commit into from
May 16, 2024
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-photo-and-image-props.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add photo and image props

Add `oc:photo` and `oc:image` props to PROPFIND responses for propall requests or when they are explicitly requested.

https://github.com/cs3org/reva/pull/4684
31 changes: 30 additions & 1 deletion internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ var (
"latitude",
"longitude",
}
imageKeys = []string{
"width",
"height",
}
photoKeys = []string{
"cameraMake",
"cameraModel",
"exposureDenominator",
"exposureNumerator",
"fNumber",
"focalLength",
"iso",
"orientation",
"takenDateTime",
}
)

type countingReader struct {
Expand Down Expand Up @@ -853,6 +868,10 @@ func metadataKeys(pf XML) ([]string, []string) {
metadataKeys = append(metadataKeys, metadataKeysWithPrefix("libre.graph.audio", audioKeys)...)
case "http://owncloud.org/ns/location":
metadataKeys = append(metadataKeys, metadataKeysWithPrefix("libre.graph.location", locationKeys)...)
case "http://owncloud.org/ns/image":
metadataKeys = append(metadataKeys, metadataKeysWithPrefix("libre.graph.image", imageKeys)...)
case "http://owncloud.org/ns/photo":
metadataKeys = append(metadataKeys, metadataKeysWithPrefix("libre.graph.photo", photoKeys)...)
default:
metadataKeys = append(metadataKeys, key)
}
Expand Down Expand Up @@ -910,7 +929,7 @@ func requiresExplicitFetching(n *xml.Name) bool {
}
case net.NsOwncloud:
switch n.Local {
case "favorite", "share-types", "checksums", "size", "tags", "audio", "location":
case "favorite", "share-types", "checksums", "size", "tags", "audio", "location", "image", "photo":
return true
default:
return false
Expand Down Expand Up @@ -1253,6 +1272,8 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
propstatOK.Prop = append(propstatOK.Prop, prop.Raw("oc:tags", k["tags"]))
appendMetadataProp(k, "oc", "audio", "libre.graph.audio", audioKeys)
appendMetadataProp(k, "oc", "location", "libre.graph.location", locationKeys)
appendMetadataProp(k, "oc", "image", "libre.graph.image", imageKeys)
appendMetadataProp(k, "oc", "photo", "libre.graph.photo", photoKeys)
}

// ls do not report any properties as missing by default
Expand Down Expand Up @@ -1534,6 +1555,14 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
if k := md.GetArbitraryMetadata().GetMetadata(); k != nil {
appendMetadataProp(k, "oc", "location", "libre.graph.location", locationKeys)
}
case "image":
if k := md.GetArbitraryMetadata().GetMetadata(); k != nil {
appendMetadataProp(k, "oc", "image", "libre.graph.image", imageKeys)
}
case "photo":
if k := md.GetArbitraryMetadata().GetMetadata(); k != nil {
appendMetadataProp(k, "oc", "photo", "libre.graph.photo", photoKeys)
}
case "name":
appendToOK(prop.Escaped("oc:name", md.Name))
case "shareid":
Expand Down
Loading