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

refactor: changed from alllowercase to kebab-case for metadata keys #4695

Merged
merged 4 commits into from
May 24, 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
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 @@ -2,4 +2,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/4695
https://github.com/cs3org/reva/pull/4684
7 changes: 4 additions & 3 deletions internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rhttp/router"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/iancoleman/strcase"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
Expand Down Expand Up @@ -1147,18 +1148,18 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
appendMetadataProp := func(metadata map[string]string, tagNamespace string, name string, metadataPrefix string, keys []string) {
content := strings.Builder{}
for _, key := range keys {
lowerCaseKey := strings.ToLower(key)
kebabCaseKey := strcase.ToKebab(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

The keys are hardcoded above. Why even lower or kebap case them? IMO isVariableBitrate should just remain camel case. Any reasons against that?

Copy link
Member Author

Choose a reason for hiding this comment

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

@kobergj wanted to achieve a somewhat consistent format for keys in the propfind response. From a client perspective that is a good thing to achieve. A mix of kebab, camel and snake case in the keys is annoying as hell...

However, my strongest need is, that I can convert the keys easily to a different case so that they match an interface of mine. Types/interfaces in web are all camelCase, so I need to be able to convert as needed.

if v, ok := metadata[fmt.Sprintf("%s.%s", metadataPrefix, key)]; ok {
content.WriteString("<")
content.WriteString(tagNamespace)
content.WriteString(":")
content.WriteString(lowerCaseKey)
content.WriteString(kebabCaseKey)
content.WriteString(">")
content.Write(prop.Escaped("", v).InnerXML)
content.WriteString("</")
content.WriteString(tagNamespace)
content.WriteString(":")
content.WriteString(lowerCaseKey)
content.WriteString(kebabCaseKey)
content.WriteString(">")
}
}
Expand Down
Loading