diff --git a/changelog/unreleased/fix-activity-limit.md b/changelog/unreleased/fix-activity-limit.md new file mode 100644 index 00000000000..06e42044c51 --- /dev/null +++ b/changelog/unreleased/fix-activity-limit.md @@ -0,0 +1,5 @@ +Bugfix: Fix activity limit + +When requesting a limit on activities, ocis would limit first, then filter and sort. Now it filters and sorts first, then limits. + +https://github.com/owncloud/ocis/pull/10165 diff --git a/services/activitylog/pkg/service/http.go b/services/activitylog/pkg/service/http.go index d888b9052a6..d3b5455b866 100644 --- a/services/activitylog/pkg/service/http.go +++ b/services/activitylog/pkg/service/http.go @@ -107,10 +107,6 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h for _, e := range evRes.GetEvents() { delete(toDelete, e.GetId()) - if limit != 0 && len(resp.Activities) >= limit { - continue - } - if !activityAccepted(e) { continue } @@ -221,6 +217,10 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h sort(resp.Activities) + if limit > 0 && limit < len(resp.Activities) { + resp.Activities = resp.Activities[:limit] + } + b, err := json.Marshal(resp) if err != nil { s.log.Error().Err(err).Msg("error marshalling activities")