From 96e8dc1bf899073ee7cc1e0b8894274f0d64004c Mon Sep 17 00:00:00 2001 From: jkoberg Date: Tue, 25 Jun 2024 16:20:20 +0200 Subject: [PATCH] fix(activitylog): multiple minor bugfixes Signed-off-by: jkoberg --- changelog/unreleased/activitylog-fixes.md | 5 +++++ services/activitylog/pkg/service/http.go | 7 ++++++- services/activitylog/pkg/service/response.go | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/activitylog-fixes.md diff --git a/changelog/unreleased/activitylog-fixes.md b/changelog/unreleased/activitylog-fixes.md new file mode 100644 index 00000000000..c2e509d37bc --- /dev/null +++ b/changelog/unreleased/activitylog-fixes.md @@ -0,0 +1,5 @@ +Enhancement: Various fixes for the activitylog service + +First round of fixes to make the activitylog service more robust and reliable. + +https://github.com/owncloud/ocis/pull/9467 diff --git a/services/activitylog/pkg/service/http.go b/services/activitylog/pkg/service/http.go index 1fbd2fb53d6..9c2388f9fe9 100644 --- a/services/activitylog/pkg/service/http.go +++ b/services/activitylog/pkg/service/http.go @@ -17,6 +17,7 @@ import ( "github.com/cs3org/reva/v2/pkg/utils" "google.golang.org/grpc/metadata" + libregraph "github.com/owncloud/libre-graph-api-go" "github.com/owncloud/ocis/v2/ocis-pkg/ast" "github.com/owncloud/ocis/v2/ocis-pkg/kql" "github.com/owncloud/ocis/v2/ocis-pkg/l10n" @@ -83,7 +84,7 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h return } - var resp GetActivitiesResponse + resp := GetActivitiesResponse{Activities: make([]libregraph.Activity, 0, len(evRes.GetEvents()))} for _, e := range evRes.GetEvents() { delete(toDelete, e.GetId()) @@ -269,6 +270,10 @@ func (s *ActivitylogService) getFilters(query string) (*provider.ResourceId, int if err != nil { return nil, limit, nil, nil, err } + if rid.GetOpaqueId() == "" { + // space root requested - fix format + rid.OpaqueId = rid.GetSpaceId() + } pref := func(a RawActivity) bool { for _, f := range prefilters { if !f(a) { diff --git a/services/activitylog/pkg/service/response.go b/services/activitylog/pkg/service/response.go index 9a9d710bc2c..0c04a6ba4c7 100644 --- a/services/activitylog/pkg/service/response.go +++ b/services/activitylog/pkg/service/response.go @@ -57,6 +57,9 @@ func WithResource(ref *provider.Reference, addSpace bool) ActivityOption { return func(ctx context.Context, gwc gateway.GatewayAPIClient, vars map[string]interface{}) error { info, err := utils.GetResource(ctx, ref, gwc) if err != nil { + vars["resource"] = Resource{ + Name: filepath.Base(ref.GetPath()), + } return err } @@ -209,7 +212,7 @@ func (s *ActivitylogService) GetVars(ctx context.Context, opts ...ActivityOption vars := make(map[string]interface{}) for _, opt := range opts { if err := opt(ctx, gwc, vars); err != nil { - return nil, err + s.log.Info().Err(err).Msg("error getting activity vars") } }