fix(activitylog): fix limit parameter

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2024-09-25 13:45:35 +02:00
parent 78095bc1fe
commit 9b2bae31c9
2 changed files with 9 additions and 4 deletions

View File

@@ -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

View File

@@ -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")