Skip to content

Commit

Permalink
Merge pull request #9485 from kobergj/ActivitylogSpaceFix
Browse files Browse the repository at this point in the history
Activitylog Spaces
  • Loading branch information
kobergj authored Jun 27, 2024
2 parents 66e1548 + 43df861 commit bc3cf5b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/activitylog-fixes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,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/9485
https://github.com/owncloud/ocis/pull/9467
8 changes: 4 additions & 4 deletions services/activitylog/pkg/service/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h
case events.UploadReady:
message = MessageResourceCreated
ts = utils.TSToTime(ev.Timestamp)
vars, err = s.GetVars(ctx, WithResource(ev.FileRef, true), WithUser(ev.ExecutingUser.GetId(), ev.ExecutingUser.GetDisplayName()))
vars, err = s.GetVars(ctx, WithResource(ev.FileRef, true), WithUser(ev.ExecutingUser.GetId(), ev.ExecutingUser.GetDisplayName()), WithSpace(toSpace(ev.FileRef)))
case events.FileTouched:
message = MessageResourceCreated
ts = utils.TSToTime(ev.Timestamp)
vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""))
vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""), WithSpace(toSpace(ev.Ref)))
case events.ContainerCreated:
message = MessageResourceCreated
ts = utils.TSToTime(ev.Timestamp)
vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""))
vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""), WithSpace(toSpace(ev.Ref)))
case events.ItemTrashed:
message = MessageResourceTrashed
ts = utils.TSToTime(ev.Timestamp)
Expand All @@ -130,7 +130,7 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false), WithOldResource(ev.OldReference), WithUser(ev.Executant, ""))
case false:
message = MessageResourceMoved
vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""))
vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""), WithSpace(toSpace(ev.Ref)))
}
ts = utils.TSToTime(ev.Timestamp)
case events.ShareCreated:
Expand Down
5 changes: 5 additions & 0 deletions services/activitylog/pkg/service/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ func WithSharee(uid *user.UserId, gid *group.GroupId) ActivityOption {
// WithSpace sets the space variable for an activity
func WithSpace(spaceid *provider.StorageSpaceId) ActivityOption {
return func(ctx context.Context, gwc gateway.GatewayAPIClient, vars map[string]interface{}) error {
if _, ok := vars["space"]; ok {
// do not override space if already set
return nil
}

s, err := utils.GetSpace(ctx, spaceid.GetOpaqueId(), gwc)
if err != nil {
vars["space"] = Resource{
Expand Down

0 comments on commit bc3cf5b

Please sign in to comment.