Skip to content

Commit

Permalink
Merge pull request #10085 from 2403905/issue-10012
Browse files Browse the repository at this point in the history
Added the LinkUpdated activity in the space context
  • Loading branch information
2403905 authored Sep 18, 2024
2 parents 4423fb2 + a5f6482 commit 9c0f51b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-acitivity-update-public-link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Added LinkUpdated activity

Added the LinkUpdated activity in the space context

https://github.com/owncloud/ocis/pull/10085
https://github.com/owncloud/ocis/issues/10012
1 change: 1 addition & 0 deletions services/activitylog/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var _registeredEvents = []events.Unmarshaller{
events.ShareCreated{},
events.ShareRemoved{},
events.LinkCreated{},
events.LinkUpdated{},
events.LinkRemoved{},
events.SpaceShared{},
events.SpaceUnshared{},
Expand Down
10 changes: 10 additions & 0 deletions services/activitylog/pkg/service/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h
message = MessageLinkCreated
ts = utils.TSToTime(ev.CTime)
vars, err = s.GetVars(ctx, WithResource(toRef(ev.ItemID), false), WithUser(ev.Executant, ""))
case events.LinkUpdated:
if ev.Sharer != nil && ev.ItemID != nil && ev.Sharer.GetOpaqueId() == ev.ItemID.GetSpaceId() {
continue
}
message = MessageLinkUpdated
ts = utils.TSToTime(ev.CTime)
vars, err = s.GetVars(ctx,
WithResource(toRef(ev.ItemID), false),
WithUser(ev.Executant, ""),
WithLinkFieldUpdated(&ev))
case events.LinkRemoved:
message = MessageLinkDeleted
ts = utils.TSToTime(ev.Timestamp)
Expand Down
29 changes: 29 additions & 0 deletions services/activitylog/pkg/service/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/events"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
libregraph "github.com/owncloud/libre-graph-api-go"
Expand All @@ -28,6 +29,7 @@ var (
MessageShareCreated = l10n.Template("{user} shared {resource} with {sharee}")
MessageShareDeleted = l10n.Template("{user} removed {sharee} from {resource}")
MessageLinkCreated = l10n.Template("{user} shared {resource} via link")
MessageLinkUpdated = l10n.Template("{user} updated {field} for a link {token} on {resource}")
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}")
Expand Down Expand Up @@ -216,6 +218,33 @@ func WithSpace(spaceid *provider.StorageSpaceId) ActivityOption {
}
}

func WithLinkFieldUpdated(e *events.LinkUpdated) ActivityOption {
return func(_ context.Context, _ gateway.GatewayAPIClient, vars map[string]interface{}) error {
f := "some field"
switch e.FieldUpdated {
case "TYPE_PERMISSIONS":
f = "permission"
case "TYPE_PASSWORD":
f = "password"
case "TYPE_EXPIRATION":
f = "expiration date"
case "TYPE_DISPLAYNAME":
f = "display name"
case "TYPE_DESCRIPTION":
f = "description"
}
vars["field"] = Resource{
ID: e.ItemID.GetOpaqueId(),
Name: f,
}
vars["token"] = Resource{
ID: e.ItemID.GetOpaqueId(),
Name: e.Token,
}
return nil
}
}

// NewActivity creates a new activity
func NewActivity(message string, ts time.Time, eventID string, vars map[string]interface{}) libregraph.Activity {
return libregraph.Activity{
Expand Down
4 changes: 4 additions & 0 deletions services/activitylog/pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func (a *ActivitylogService) Run() {
err = a.AddActivity(toRef(ev.ItemID), e.ID, ev.Timestamp)
case events.LinkCreated:
err = a.AddActivity(toRef(ev.ItemID), e.ID, utils.TSToTime(ev.CTime))
case events.LinkUpdated:
if ev.Sharer != nil && ev.ItemID != nil && ev.Sharer.GetOpaqueId() != ev.ItemID.GetSpaceId() {
err = a.AddActivity(toRef(ev.ItemID), e.ID, utils.TSToTime(ev.CTime))
}
case events.LinkRemoved:
err = a.AddActivity(toRef(ev.ItemID), e.ID, utils.TSToTime(ev.Timestamp))
case events.SpaceShared:
Expand Down

0 comments on commit 9c0f51b

Please sign in to comment.