From 9a8d2b5d7bdfb818d756d69afbdcf77f48dcdb1f Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 23 Jun 2021 15:56:50 +0200 Subject: [PATCH 1/5] remove notifications key from ocs response --- .../http/services/owncloud/ocs/data/capabilities.go | 4 ++-- .../ocs/handlers/cloud/capabilities/capabilities.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/http/services/owncloud/ocs/data/capabilities.go b/internal/http/services/owncloud/ocs/data/capabilities.go index dc9e4b7815..a50e2983a9 100644 --- a/internal/http/services/owncloud/ocs/data/capabilities.go +++ b/internal/http/services/owncloud/ocs/data/capabilities.go @@ -55,7 +55,7 @@ type Capabilities struct { Files *CapabilitiesFiles `json:"files" xml:"files" mapstructure:"files"` Dav *CapabilitiesDav `json:"dav" xml:"dav"` FilesSharing *CapabilitiesFilesSharing `json:"files_sharing" xml:"files_sharing" mapstructure:"files_sharing"` - Notifications *CapabilitiesNotifications `json:"notifications" xml:"notifications"` + Notifications *CapabilitiesNotifications `json:"notifications,omitempty" xml:"notifications,omitempty"` } // CapabilitiesCore holds webdav config @@ -178,7 +178,7 @@ type CapabilitiesFilesSharingFederation struct { // CapabilitiesNotifications holds a list of notification endpoints type CapabilitiesNotifications struct { - Endpoints []string `json:"ocs-endpoints" xml:"ocs-endpoints>element" mapstructure:"endpoints"` + Endpoints []string `json:"ocs-endpoints,omitempty" xml:"ocs-endpoints>element,omitempty" mapstructure:"endpoints"` } // Version holds version information diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go index 7b3b0d21df..2c5f90f90b 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go @@ -191,12 +191,12 @@ func (h *Handler) Init(c *config.Config) { // notifications - if h.c.Capabilities.Notifications == nil { - h.c.Capabilities.Notifications = &data.CapabilitiesNotifications{} - } - if h.c.Capabilities.Notifications.Endpoints == nil { - h.c.Capabilities.Notifications.Endpoints = []string{"list", "get", "delete"} - } + //if h.c.Capabilities.Notifications == nil { + // h.c.Capabilities.Notifications = &data.CapabilitiesNotifications{} + //} + //if h.c.Capabilities.Notifications.Endpoints == nil { + //h.c.Capabilities.Notifications.Endpoints = []string{"list", "get", "delete"} + //} // version From 359ba8e3433e6e9ce53d4fed8b0bbcb470719801 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 30 Jul 2021 09:58:45 +0200 Subject: [PATCH 2/5] adjust test --- .../ocs/handlers/cloud/capabilities/capabilities_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go index 2b27d8d3cf..12af75d557 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go @@ -21,6 +21,7 @@ package capabilities import ( "encoding/json" "encoding/xml" + "fmt" "testing" "github.com/cs3org/reva/internal/http/services/owncloud/ocs/data" @@ -35,7 +36,7 @@ func TestMarshal(t *testing.T) { }, } - jsonExpect := `{"capabilities":{"core":null,"checksums":null,"files":null,"dav":null,"files_sharing":{"api_enabled":true,"resharing":false,"group_sharing":false,"auto_accept_share":false,"share_with_group_members_only":false,"share_with_membership_groups_only":false,"search_min_length":0,"default_permissions":0,"user_enumeration":null,"federation":null,"public":null,"user":null},"notifications":null},"version":null}` + jsonExpect := `{"capabilities":{"core":null,"checksums":null,"files":null,"dav":null,"files_sharing":{"api_enabled":true,"resharing":false,"group_sharing":false,"auto_accept_share":false,"share_with_group_members_only":false,"share_with_membership_groups_only":false,"search_min_length":0,"default_permissions":0,"user_enumeration":null,"federation":null,"public":null,"user":null}},"version":null}` xmlExpect := `10000000` jsonData, err := json.Marshal(&cd) @@ -43,6 +44,7 @@ func TestMarshal(t *testing.T) { t.Fail() } + fmt.Println(string(jsonData)) if string(jsonData) != jsonExpect { t.Fail() } From 9e063f1ff658b184902a08edd4e1a7db0f74c145 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 30 Jul 2021 10:08:12 +0200 Subject: [PATCH 3/5] fix linter --- .../ocs/handlers/cloud/capabilities/capabilities.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go index 2c5f90f90b..a153c79396 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go @@ -191,12 +191,12 @@ func (h *Handler) Init(c *config.Config) { // notifications - //if h.c.Capabilities.Notifications == nil { - // h.c.Capabilities.Notifications = &data.CapabilitiesNotifications{} - //} - //if h.c.Capabilities.Notifications.Endpoints == nil { - //h.c.Capabilities.Notifications.Endpoints = []string{"list", "get", "delete"} - //} + // if h.c.Capabilities.Notifications == nil { + // h.c.Capabilities.Notifications = &data.CapabilitiesNotifications{} + // } + // if h.c.Capabilities.Notifications.Endpoints == nil { + // h.c.Capabilities.Notifications.Endpoints = []string{"list", "get", "delete"} + // } // version From 45007de9ba31524baf64e05e4cd89d7b829f077b Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 30 Jul 2021 11:46:03 +0200 Subject: [PATCH 4/5] add changelog --- changelog/unreleased/disable-notifications.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/unreleased/disable-notifications.md diff --git a/changelog/unreleased/disable-notifications.md b/changelog/unreleased/disable-notifications.md new file mode 100644 index 0000000000..5fe3d384dd --- /dev/null +++ b/changelog/unreleased/disable-notifications.md @@ -0,0 +1,5 @@ +Bugfix: Disable notifications + +The presence of the key `notifications` in the capabilities' response would cause clients to attempt to poll the notifications endpoint, which is not yet supported. To prevent the unnecessary bandwidth we are disabling this altogether. + +https://github.com/cs3org/reva/pull/1819 \ No newline at end of file From fcba934f58881b754bd3a744f8645711d9ee8d97 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Mon, 2 Aug 2021 12:50:08 +0200 Subject: [PATCH 5/5] remove fmt --- .../ocs/handlers/cloud/capabilities/capabilities_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go index 12af75d557..ada4f4c56b 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go @@ -21,7 +21,6 @@ package capabilities import ( "encoding/json" "encoding/xml" - "fmt" "testing" "github.com/cs3org/reva/internal/http/services/owncloud/ocs/data" @@ -44,7 +43,6 @@ func TestMarshal(t *testing.T) { t.Fail() } - fmt.Println(string(jsonData)) if string(jsonData) != jsonExpect { t.Fail() }