Skip to content

Commit

Permalink
Merge pull request #4684 from kulmann/feat-photo-and-image-props
Browse files Browse the repository at this point in the history
feat: add image and photo to propfind
  • Loading branch information
kulmann authored May 16, 2024
2 parents 7099ed4 + 6b7d0f3 commit 348c76a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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

0 comments on commit 348c76a

Please sign in to comment.