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

fix ocs api shared with me response #1346

Merged
merged 1 commit into from
Nov 30, 2020
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
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-ocs-share-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: fix the ocs share with me response

The path of the files shared with me was incorrect.

https://github.com/owncloud/product/issues/204
https://github.com/cs3org/reva/pull/1346
5 changes: 5 additions & 0 deletions internal/http/services/owncloud/ocs/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Config struct {
GatewaySvc string `mapstructure:"gatewaysvc"`
DefaultUploadProtocol string `mapstructure:"default_upload_protocol"`
UserAgentChunkingMap map[string]string `mapstructure:"user_agent_chunking_map"`
SharePrefix string `mapstructure:"share_prefix"`
}

// Init sets sane defaults
Expand All @@ -39,6 +40,10 @@ func (c *Config) Init() {
c.Prefix = "ocs"
}

if c.SharePrefix == "" {
c.SharePrefix = "/Shares"
}

if c.DefaultUploadProtocol == "" {
c.DefaultUploadProtocol = "tus"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
type Handler struct {
gatewayAddr string
publicURL string
sharePrefix string
displayNameCache *ttlmap.TTLMap
}

Expand All @@ -61,6 +62,7 @@ func (h *Handler) Init(c *config.Config) error {
h.gatewayAddr = c.GatewaySvc
h.publicURL = c.Config.Host
h.displayNameCache = ttlmap.New(1000, 60)
h.sharePrefix = c.SharePrefix
return nil
}

Expand Down Expand Up @@ -814,6 +816,12 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
}
h.addDisplaynames(r.Context(), gwc, data)

if data.State == ocsStateAccepted {
// Needed because received shares can be jailed in a folder in the users home
data.FileTarget = path.Join(h.sharePrefix, path.Base(info.Path))
data.Path = path.Join(h.sharePrefix, path.Base(info.Path))
}

shares = append(shares, data)
}

Expand Down