Skip to content

Commit

Permalink
split events
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Richter <[email protected]>
  • Loading branch information
dragonchaser committed Sep 13, 2024
1 parent d21bd7e commit 1c177a7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
30 changes: 25 additions & 5 deletions services/activitylog/pkg/service/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions services/activitylog/pkg/service/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c177a7

Please sign in to comment.