mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 11:51:16 -06:00
Merge pull request #10266 from 2403905/issue-10210
Kept historical resource naming after renaming in activity for shares…
This commit is contained in:
6
changelog/unreleased/fix-activity-rename.md
Normal file
6
changelog/unreleased/fix-activity-rename.md
Normal file
@@ -0,0 +1,6 @@
|
||||
Bugfix: Kept historical resource naming in activity
|
||||
|
||||
Kept historical resource naming after renaming in activity for shares and public links.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/10266
|
||||
https://github.com/owncloud/ocis/issues/10210
|
||||
@@ -130,19 +130,19 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h
|
||||
message = MessageResourceUpdated
|
||||
}
|
||||
ts = utils.TSToTime(ev.Timestamp)
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.FileRef, false), WithUser(nil, ev.ExecutingUser, ev.ImpersonatingUser))
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.FileRef, false, ""), WithUser(nil, ev.ExecutingUser, ev.ImpersonatingUser))
|
||||
case events.FileTouched:
|
||||
message = MessageResourceCreated
|
||||
ts = utils.TSToTime(ev.Timestamp)
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false, ""), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
case events.FileDownloaded:
|
||||
message = MessageResourceDownloaded
|
||||
ts = utils.TSToTime(ev.Timestamp)
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false), WithUser(ev.Executant, nil, ev.ImpersonatingUser), WithVar("token", "", ev.ImpersonatingUser.GetId().GetOpaqueId()))
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false, ""), WithUser(ev.Executant, nil, ev.ImpersonatingUser), WithVar("token", "", ev.ImpersonatingUser.GetId().GetOpaqueId()))
|
||||
case events.ContainerCreated:
|
||||
message = MessageResourceCreated
|
||||
ts = utils.TSToTime(ev.Timestamp)
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false, ""), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
case events.ItemTrashed:
|
||||
message = MessageResourceTrashed
|
||||
ts = utils.TSToTime(ev.Timestamp)
|
||||
@@ -151,31 +151,42 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h
|
||||
switch isRename(ev.OldReference, ev.Ref) {
|
||||
case true:
|
||||
message = MessageResourceRenamed
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false), WithOldResource(ev.OldReference), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false, ""), WithOldResource(ev.OldReference), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
case false:
|
||||
message = MessageResourceMoved
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
vars, err = s.GetVars(ctx, WithResource(ev.Ref, false, ""), WithUser(ev.Executant, nil, ev.ImpersonatingUser))
|
||||
}
|
||||
ts = utils.TSToTime(ev.Timestamp)
|
||||
case events.ShareCreated:
|
||||
message = MessageShareCreated
|
||||
ts = utils.TSToTime(ev.CTime)
|
||||
vars, err = s.GetVars(ctx, WithResource(toRef(ev.ItemID), false), WithUser(ev.Executant, nil, nil), WithSharee(ev.GranteeUserID, ev.GranteeGroupID))
|
||||
vars, err = s.GetVars(ctx,
|
||||
WithResource(toRef(ev.ItemID), false, ev.ResourceName),
|
||||
WithUser(ev.Executant, nil, nil),
|
||||
WithSharee(ev.GranteeUserID, ev.GranteeGroupID))
|
||||
case events.ShareUpdated:
|
||||
if ev.Sharer != nil && ev.ItemID != nil && ev.Sharer.GetOpaqueId() == ev.ItemID.GetSpaceId() {
|
||||
continue
|
||||
}
|
||||
message = MessageShareUpdated
|
||||
ts = utils.TSToTime(ev.MTime)
|
||||
vars, err = s.GetVars(ctx, WithResource(toRef(ev.ItemID), false), WithUser(ev.Executant, nil, nil), WithTranslation(&t, loc, "field", ev.UpdateMask))
|
||||
vars, err = s.GetVars(ctx,
|
||||
WithResource(toRef(ev.ItemID), false, ev.ResourceName),
|
||||
WithUser(ev.Executant, nil, nil),
|
||||
WithTranslation(&t, loc, "field", ev.UpdateMask))
|
||||
case events.ShareRemoved:
|
||||
message = MessageShareDeleted
|
||||
ts = ev.Timestamp
|
||||
vars, err = s.GetVars(ctx, WithResource(toRef(ev.ItemID), false), WithUser(ev.Executant, nil, nil), WithSharee(ev.GranteeUserID, ev.GranteeGroupID))
|
||||
vars, err = s.GetVars(ctx,
|
||||
WithResource(toRef(ev.ItemID), false, ev.ResourceName),
|
||||
WithUser(ev.Executant, nil, nil),
|
||||
WithSharee(ev.GranteeUserID, ev.GranteeGroupID))
|
||||
case events.LinkCreated:
|
||||
message = MessageLinkCreated
|
||||
ts = utils.TSToTime(ev.CTime)
|
||||
vars, err = s.GetVars(ctx, WithResource(toRef(ev.ItemID), false), WithUser(ev.Executant, nil, nil))
|
||||
vars, err = s.GetVars(ctx,
|
||||
WithResource(toRef(ev.ItemID), false, ev.ResourceName),
|
||||
WithUser(ev.Executant, nil, nil))
|
||||
case events.LinkUpdated:
|
||||
if ev.Sharer != nil && ev.ItemID != nil && ev.Sharer.GetOpaqueId() == ev.ItemID.GetSpaceId() {
|
||||
continue
|
||||
@@ -183,14 +194,14 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h
|
||||
message = MessageLinkUpdated
|
||||
ts = utils.TSToTime(ev.MTime)
|
||||
vars, err = s.GetVars(ctx,
|
||||
WithResource(toRef(ev.ItemID), false),
|
||||
WithVar("resource", storagespace.FormatResourceID(ev.ItemID), ev.ResourceName),
|
||||
WithUser(ev.Executant, nil, nil),
|
||||
WithTranslation(&t, loc, "field", []string{ev.FieldUpdated}),
|
||||
WithVar("token", ev.ItemID.GetOpaqueId(), ev.Token))
|
||||
case events.LinkRemoved:
|
||||
message = MessageLinkDeleted
|
||||
ts = utils.TSToTime(ev.Timestamp)
|
||||
vars, err = s.GetVars(ctx, WithResource(toRef(ev.ItemID), false), WithUser(ev.Executant, nil, nil))
|
||||
vars, err = s.GetVars(ctx, WithResource(toRef(ev.ItemID), false, ""), WithUser(ev.Executant, nil, nil))
|
||||
case events.SpaceShared:
|
||||
message = MessageSpaceShared
|
||||
ts = ev.Timestamp
|
||||
|
||||
@@ -65,12 +65,15 @@ type Actor struct {
|
||||
type ActivityOption func(context.Context, gateway.GatewayAPIClient, map[string]interface{}) error
|
||||
|
||||
// WithResource sets the resource variable for an activity
|
||||
func WithResource(ref *provider.Reference, addSpace bool) ActivityOption {
|
||||
func WithResource(ref *provider.Reference, addSpace bool, explicitResourceName string) ActivityOption {
|
||||
return func(ctx context.Context, gwc gateway.GatewayAPIClient, vars map[string]interface{}) error {
|
||||
info, err := utils.GetResource(ctx, ref, gwc)
|
||||
if err != nil {
|
||||
if explicitResourceName == "" {
|
||||
explicitResourceName = filepath.Base(ref.GetPath())
|
||||
}
|
||||
vars["resource"] = Resource{
|
||||
Name: filepath.Base(ref.GetPath()),
|
||||
Name: explicitResourceName,
|
||||
}
|
||||
n := getFolderName(ctx, gwc, ref)
|
||||
vars["folder"] = Resource{
|
||||
@@ -79,9 +82,12 @@ func WithResource(ref *provider.Reference, addSpace bool) ActivityOption {
|
||||
return err
|
||||
}
|
||||
|
||||
if explicitResourceName == "" {
|
||||
explicitResourceName = info.GetName()
|
||||
}
|
||||
vars["resource"] = Resource{
|
||||
ID: storagespace.FormatResourceID(info.GetId()),
|
||||
Name: info.GetName(),
|
||||
Name: explicitResourceName,
|
||||
}
|
||||
|
||||
if addSpace {
|
||||
|
||||
@@ -1128,7 +1128,7 @@ Feature: check share activity
|
||||
},
|
||||
"variables": {
|
||||
"type": "object",
|
||||
"required": ["field","folder","resource","token","user"],
|
||||
"required": ["field","resource","token","user"],
|
||||
"properties": {
|
||||
"field": {
|
||||
"type": "object",
|
||||
@@ -1139,15 +1139,6 @@ Feature: check share activity
|
||||
}
|
||||
}
|
||||
},
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "new-space"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
@@ -1211,7 +1202,7 @@ Feature: check share activity
|
||||
},
|
||||
"variables": {
|
||||
"type": "object",
|
||||
"required": ["field","folder","resource","token","user"],
|
||||
"required": ["field","resource","token","user"],
|
||||
"properties": {
|
||||
"field": {
|
||||
"type": "object",
|
||||
@@ -1222,15 +1213,6 @@ Feature: check share activity
|
||||
}
|
||||
}
|
||||
},
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "new-space"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
@@ -1294,7 +1276,7 @@ Feature: check share activity
|
||||
},
|
||||
"variables": {
|
||||
"type": "object",
|
||||
"required": ["field","folder","resource","token","user"],
|
||||
"required": ["field","resource","token","user"],
|
||||
"properties": {
|
||||
"field": {
|
||||
"type": "object",
|
||||
@@ -1305,15 +1287,6 @@ Feature: check share activity
|
||||
}
|
||||
}
|
||||
},
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "new-space"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
@@ -1467,7 +1440,7 @@ Feature: check share activity
|
||||
},
|
||||
"variables": {
|
||||
"type": "object",
|
||||
"required": ["field","folder","resource","token","user"],
|
||||
"required": ["field","resource","token","user"],
|
||||
"properties": {
|
||||
"field": {
|
||||
"type": "object",
|
||||
@@ -1478,15 +1451,6 @@ Feature: check share activity
|
||||
}
|
||||
}
|
||||
},
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "new-space"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
@@ -1550,7 +1514,7 @@ Feature: check share activity
|
||||
},
|
||||
"variables": {
|
||||
"type": "object",
|
||||
"required": ["field","folder","resource","token","user"],
|
||||
"required": ["field","resource","token","user"],
|
||||
"properties": {
|
||||
"field": {
|
||||
"type": "object",
|
||||
@@ -1561,15 +1525,6 @@ Feature: check share activity
|
||||
}
|
||||
}
|
||||
},
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "new-space"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
@@ -1633,7 +1588,7 @@ Feature: check share activity
|
||||
},
|
||||
"variables": {
|
||||
"type": "object",
|
||||
"required": ["field","folder","resource","token","user"],
|
||||
"required": ["field","resource","token","user"],
|
||||
"properties": {
|
||||
"field": {
|
||||
"type": "object",
|
||||
@@ -1644,15 +1599,6 @@ Feature: check share activity
|
||||
}
|
||||
}
|
||||
},
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "new-space"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
@@ -2064,17 +2010,8 @@ Feature: check share activity
|
||||
},
|
||||
"variables": {
|
||||
"type": "object",
|
||||
"required": ["folder","resource","user"],
|
||||
"required": ["resource","user"],
|
||||
"properties": {
|
||||
"folder": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "Alice Hansen"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["id","name"],
|
||||
@@ -2287,4 +2224,3 @@ Feature: check share activity
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user