Skip to content

Commit

Permalink
fix ocs api shared with me response (#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rby authored Nov 30, 2020
1 parent da040e1 commit 7e3efcb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
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

0 comments on commit 7e3efcb

Please sign in to comment.