diff --git a/changelog/unreleased/fix-ocs-share-api.md b/changelog/unreleased/fix-ocs-share-api.md new file mode 100644 index 00000000000..ccdd6d9eb11 --- /dev/null +++ b/changelog/unreleased/fix-ocs-share-api.md @@ -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 diff --git a/internal/http/services/owncloud/ocs/config/config.go b/internal/http/services/owncloud/ocs/config/config.go index 1ac227358d7..bed7cb64009 100644 --- a/internal/http/services/owncloud/ocs/config/config.go +++ b/internal/http/services/owncloud/ocs/config/config.go @@ -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 @@ -39,6 +40,10 @@ func (c *Config) Init() { c.Prefix = "ocs" } + if c.SharePrefix == "" { + c.SharePrefix = "/Shares" + } + if c.DefaultUploadProtocol == "" { c.DefaultUploadProtocol = "tus" } diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 21b2d1df608..f4d4219032d 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -53,6 +53,7 @@ import ( type Handler struct { gatewayAddr string publicURL string + sharePrefix string displayNameCache *ttlmap.TTLMap } @@ -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 } @@ -813,6 +815,9 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { continue } h.addDisplaynames(r.Context(), gwc, data) + // 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) }