Skip to content

Commit

Permalink
make exclude denials configurable
Browse files Browse the repository at this point in the history
Moved the exclude denials filter to the ocs layer so that it's still possible to get rejected shares from the usershareprovider
  • Loading branch information
David Christofas committed Sep 28, 2021
1 parent d96c8f5 commit e0c8e47
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
11 changes: 0 additions & 11 deletions internal/grpc/services/usershareprovider/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,6 @@ func (s *service) UpdateShare(ctx context.Context, req *collaboration.UpdateShar
}

func (s *service) ListReceivedShares(ctx context.Context, req *collaboration.ListReceivedSharesRequest) (*collaboration.ListReceivedSharesResponse, error) {
// For the UI add a filter to not display the denial shares
foundExclude := false
for _, f := range req.Filters {
if f.Type == collaboration.Filter_TYPE_EXCLUDE_DENIALS {
foundExclude = true
break
}
}
if !foundExclude {
req.Filters = append(req.Filters, &collaboration.Filter{Type: collaboration.Filter_TYPE_EXCLUDE_DENIALS})
}
shares, err := s.sm.ListReceivedShares(ctx, req.Filters) // TODO(labkode): check what to update
if err != nil {
return &collaboration.ListReceivedSharesResponse{
Expand Down
1 change: 1 addition & 0 deletions internal/http/services/owncloud/ocs/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Config struct {
DefaultUploadProtocol string `mapstructure:"default_upload_protocol"`
UserAgentChunkingMap map[string]string `mapstructure:"user_agent_chunking_map"`
SharePrefix string `mapstructure:"share_prefix"`
ShowRejectedShares bool `mapstructure:"show_rejected_shares"`
HomeNamespace string `mapstructure:"home_namespace"`
AdditionalInfoAttribute string `mapstructure:"additional_info_attribute"`
CacheWarmupDriver string `mapstructure:"cache_warmup_driver"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Handler struct {
publicURL string
sharePrefix string
homeNamespace string
showRejectedShares bool
additionalInfoTemplate *template.Template
userIdentifierCache *ttlcache.Cache
resourceInfoCache gcache.Cache
Expand Down Expand Up @@ -96,6 +97,7 @@ func (h *Handler) Init(c *config.Config) {
h.homeNamespace = c.HomeNamespace
h.resourceInfoCache = gcache.New(c.ResourceInfoCacheSize).LFU().Build()
h.resourceInfoCacheTTL = time.Second * time.Duration(c.ResourceInfoCacheTTL)
h.showRejectedShares = c.ShowRejectedShares

h.additionalInfoTemplate, _ = template.New("additionalInfo").Parse(c.AdditionalInfoAttribute)

Expand Down Expand Up @@ -544,8 +546,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
return
}
}

filters := []*collaboration.Filter{}
var filters []*collaboration.Filter
var shareTypes []string
shareTypesParam := r.URL.Query().Get("share_types")
if shareTypesParam != "" {
Expand Down Expand Up @@ -573,6 +574,9 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
response.WriteOCSSuccess(w, r, []*conversions.ShareData{})
return
}
if !h.showRejectedShares {
filters = append(filters, share.ExcludeDenialsFilter())
}

lrsRes, err := client.ListReceivedShares(ctx, &collaboration.ListReceivedSharesRequest{Filters: filters})
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/share/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,10 @@ func MatchesFilter(share *collaboration.Share, filter *collaboration.Filter) boo
return false
}
}

// ExcludeDenialsFilter returns the collaboration filter to not list rejected shares.
func ExcludeDenialsFilter() *collaboration.Filter {
return &collaboration.Filter{
Type: collaboration.Filter_TYPE_EXCLUDE_DENIALS,
}
}
1 change: 1 addition & 0 deletions tests/oc-integration-tests/drone/frontend.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ files_namespace = "/oc"
webdav_namespace = "/home"

[http.services.ocs]
show_rejected_shares = true

[http.services.ocs.capabilities.capabilities.core.status]
version = "10.0.11.5"
Expand Down
1 change: 1 addition & 0 deletions tests/oc-integration-tests/local/frontend.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ files_namespace = "/users"
webdav_namespace = "/home"

[http.services.ocs]
show_rejected_shares = true

[http.services.ocs.capabilities.capabilities.core.status]
version = "10.0.11.5"
Expand Down

0 comments on commit e0c8e47

Please sign in to comment.