Skip to content

Commit

Permalink
fix: convert dates for propfinds from RFC3339 (ocis) to RFC1123 (ocdav)
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed May 17, 2024
1 parent 348c76a commit 58a900b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/add-photo-and-image-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ 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
https://github.com/cs3org/reva/pull/4688
14 changes: 14 additions & 0 deletions internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,18 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
}
}

convertRFC3339ToRFC1123 := func(metadata map[string]string, tagNamespace string, name string, metadataPrefix string, keys []string) {
for _, key := range keys {
mdKey := fmt.Sprintf("%s.%s", metadataPrefix, key)
if v, ok := metadata[mdKey]; ok {
parsedTime, err := time.Parse(time.RFC3339, v)
if err == nil {
metadata[mdKey] = parsedTime.Format(net.RFC1123)
}
}
}
}

// when allprops has been requested
if pf.Allprop != nil {
// return all known properties
Expand Down Expand Up @@ -1273,6 +1285,7 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
appendMetadataProp(k, "oc", "audio", "libre.graph.audio", audioKeys)
appendMetadataProp(k, "oc", "location", "libre.graph.location", locationKeys)
appendMetadataProp(k, "oc", "image", "libre.graph.image", imageKeys)
convertRFC3339ToRFC1123(k, "oc", "photo", "libre.graph.photo", []string{"takenDateTime"})
appendMetadataProp(k, "oc", "photo", "libre.graph.photo", photoKeys)
}

Expand Down Expand Up @@ -1561,6 +1574,7 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
}
case "photo":
if k := md.GetArbitraryMetadata().GetMetadata(); k != nil {
convertRFC3339ToRFC1123(k, "oc", "photo", "libre.graph.photo", []string{"takenDateTime"})
appendMetadataProp(k, "oc", "photo", "libre.graph.photo", photoKeys)
}
case "name":
Expand Down

0 comments on commit 58a900b

Please sign in to comment.