Skip to content

Commit

Permalink
Remove notifications key from ocs response (#1819)
Browse files Browse the repository at this point in the history
  • Loading branch information
refs authored Aug 4, 2021
1 parent f04644c commit abaa84c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/disable-notifications.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions internal/http/services/owncloud/ocs/data/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 := `<CapabilitiesData><capabilities><files_sharing><api_enabled>1</api_enabled><resharing>0</resharing><group_sharing>0</group_sharing><auto_accept_share>0</auto_accept_share><share_with_group_members_only>0</share_with_group_members_only><share_with_membership_groups_only>0</share_with_membership_groups_only><search_min_length>0</search_min_length><default_permissions>0</default_permissions></files_sharing></capabilities></CapabilitiesData>`

jsonData, err := json.Marshal(&cd)
Expand Down

0 comments on commit abaa84c

Please sign in to comment.