From e25ce90fe558cb26ca0b2146757b399e6d700941 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 13 Sep 2024 12:12:14 +0200 Subject: [PATCH] split events Signed-off-by: Christian Richter --- services/activitylog/pkg/service/http.go | 30 ++++++++++++++++---- services/activitylog/pkg/service/response.go | 23 ++++++++------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/services/activitylog/pkg/service/http.go b/services/activitylog/pkg/service/http.go index deaebe94658..ffc8634fd03 100644 --- a/services/activitylog/pkg/service/http.go +++ b/services/activitylog/pkg/service/http.go @@ -108,19 +108,35 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h // error already logged in unwrapEvent continue case events.UploadReady: - message = MessageResourceCreated + if ev.FileRef.GetPath() == "/" { + message = MessageResourceInSpaceCreated + } else { + message = MessageResourceInFolderCreated + } ts = utils.TSToTime(ev.Timestamp) 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 + if ev.Ref.GetPath() == "/" { + message = MessageResourceInSpaceCreated + } else { + message = MessageResourceInFolderCreated + } ts = utils.TSToTime(ev.Timestamp) vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""), WithSpace(toSpace(ev.Ref))) case events.ContainerCreated: - message = MessageResourceCreated + if ev.Ref.GetPath() == "/" { + message = MessageResourceInSpaceCreated + } else { + message = MessageResourceInFolderCreated + } ts = utils.TSToTime(ev.Timestamp) vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""), WithSpace(toSpace(ev.Ref))) case events.ItemTrashed: - message = MessageResourceTrashed + if ev.Ref.GetPath() == "/" { + message = MessageResourceInSpaceTrashed + } else { + message = MessageResourceInFolderTrashed + } ts = utils.TSToTime(ev.Timestamp) vars, err = s.GetVars(ctx, WithTrashedResource(ev.Ref, ev.ID), WithUser(ev.Executant, ""), WithSpace(toSpace(ev.Ref))) case events.ItemMoved: @@ -129,7 +145,11 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h message = MessageResourceRenamed vars, err = s.GetVars(ctx, WithResource(ev.Ref, false), WithOldResource(ev.OldReference), WithUser(ev.Executant, "")) case false: - message = MessageResourceMoved + if ev.Ref.GetPath() == "/" { + message = MessageResourceInSpaceMoved + } else { + message = MessageResourceInFolderMoved + } vars, err = s.GetVars(ctx, WithResource(ev.Ref, true), WithUser(ev.Executant, ""), WithSpace(toSpace(ev.Ref))) } ts = utils.TSToTime(ev.Timestamp) diff --git a/services/activitylog/pkg/service/response.go b/services/activitylog/pkg/service/response.go index c03dc9f169c..8d479a1c16c 100644 --- a/services/activitylog/pkg/service/response.go +++ b/services/activitylog/pkg/service/response.go @@ -20,16 +20,19 @@ import ( // Translations var ( - MessageResourceCreated = l10n.Template("{user} added {resource} to {space}") - MessageResourceTrashed = l10n.Template("{user} deleted {resource} from {space}") - MessageResourceMoved = l10n.Template("{user} moved {resource} to {space}") - MessageResourceRenamed = l10n.Template("{user} renamed {oldResource} to {resource}") - MessageShareCreated = l10n.Template("{user} shared {resource} with {sharee}") - MessageShareDeleted = l10n.Template("{user} removed {sharee} from {resource}") - MessageLinkCreated = l10n.Template("{user} shared {resource} via link") - MessageLinkDeleted = l10n.Template("{user} removed link to {resource}") - MessageSpaceShared = l10n.Template("{user} added {sharee} as member of {space}") - MessageSpaceUnshared = l10n.Template("{user} removed {sharee} from {space}") + MessageResourceInSpaceCreated = l10n.Template("{user} added {resource} to {space}") + MessageResourceInSpaceTrashed = l10n.Template("{user} deleted {resource} from {space}") + MessageResourceInSpaceMoved = l10n.Template("{user} moved {resource} to {space}") + MessageResourceInFolderCreated = l10n.Template("{user} added {resource} to {folder}") + MessageResourceInFolderTrashed = l10n.Template("{user} deleted {resource} from {folder}") + MessageResourceInFolderMoved = l10n.Template("{user} moved {resource} to {folder}") + MessageResourceRenamed = l10n.Template("{user} renamed {oldResource} to {resource}") + MessageShareCreated = l10n.Template("{user} shared {resource} with {sharee}") + MessageShareDeleted = l10n.Template("{user} removed {sharee} from {resource}") + MessageLinkCreated = l10n.Template("{user} shared {resource} via link") + MessageLinkDeleted = l10n.Template("{user} removed link to {resource}") + MessageSpaceShared = l10n.Template("{user} added {sharee} as member of {space}") + MessageSpaceUnshared = l10n.Template("{user} removed {sharee} from {space}") ) // GetActivitiesResponse is the response on GET activities requests