From 9ef00dbf277dc9351e7e23b39f8cfcd8a535bf06 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Tue, 17 Sep 2024 10:07:37 +0200 Subject: [PATCH 1/3] feat(activitylog): Add FileUpdated Activity Signed-off-by: jkoberg --- changelog/unreleased/fileupdated-activity.md | 5 +++++ services/activitylog/pkg/service/http.go | 3 +++ services/activitylog/pkg/service/response.go | 1 + .../features/apiActivities/shareActivities.feature | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fileupdated-activity.md diff --git a/changelog/unreleased/fileupdated-activity.md b/changelog/unreleased/fileupdated-activity.md new file mode 100644 index 00000000000..484922af5fe --- /dev/null +++ b/changelog/unreleased/fileupdated-activity.md @@ -0,0 +1,5 @@ +Enhancement: Add an Activity for FileUpdated + +Previously FileUpdated has also triggered a FileAdded Activity + +https://github.com/owncloud/ocis/pull/10072 diff --git a/services/activitylog/pkg/service/http.go b/services/activitylog/pkg/service/http.go index deaebe94658..208e9c9f5b3 100644 --- a/services/activitylog/pkg/service/http.go +++ b/services/activitylog/pkg/service/http.go @@ -109,6 +109,9 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h continue case events.UploadReady: message = MessageResourceCreated + if ev.IsVersion { + message = MessageResourceUpdated + } 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: diff --git a/services/activitylog/pkg/service/response.go b/services/activitylog/pkg/service/response.go index c03dc9f169c..4c0b59c7d9f 100644 --- a/services/activitylog/pkg/service/response.go +++ b/services/activitylog/pkg/service/response.go @@ -21,6 +21,7 @@ import ( // Translations var ( MessageResourceCreated = l10n.Template("{user} added {resource} to {space}") + MessageResourceUpdated = l10n.Template("{user} updated {resource} in {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}") diff --git a/tests/acceptance/features/apiActivities/shareActivities.feature b/tests/acceptance/features/apiActivities/shareActivities.feature index 4994330b0ee..c92c2dc7c91 100644 --- a/tests/acceptance/features/apiActivities/shareActivities.feature +++ b/tests/acceptance/features/apiActivities/shareActivities.feature @@ -637,7 +637,7 @@ Feature: check share activity "required": ["message","variables"], "properties": { "message": { - "const": "{user} added {resource} to {space}" + "const": "{user} updated {resource} in {space}" }, "variables": { "type": "object", From aa8221a78baedef033497ae366fe384b71e0b0a8 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Wed, 18 Sep 2024 09:28:05 +0200 Subject: [PATCH 2/3] fix test --- .../apiActivities/shareActivities.feature | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/features/apiActivities/shareActivities.feature b/tests/acceptance/features/apiActivities/shareActivities.feature index c92c2dc7c91..94f37403b75 100644 --- a/tests/acceptance/features/apiActivities/shareActivities.feature +++ b/tests/acceptance/features/apiActivities/shareActivities.feature @@ -540,6 +540,47 @@ Feature: check share activity "properties": { "message": { "const": "{user} added {resource} to {space}" + }, + "variables": { + "type": "object", + "required": ["resource","space","user"], + "properties": { + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "FOLDER" + } + } + }, + "space": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%!%user_id_pattern%$" + }, + "name": { + "const": "Alice Hansen" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "Alice" + } + } + } + } } } } @@ -598,7 +639,7 @@ Feature: check share activity "properties": { "id": { "type": "string", - "pattern": "^%user_id_pattern%!%user_id_pattern%$" + "pattern": "^%file_id_pattern%$" }, "name": { "const": "Alice Hansen" @@ -658,7 +699,7 @@ Feature: check share activity "properties": { "id": { "type": "string", - "pattern": "^%user_id_pattern%!%user_id_pattern%$" + "pattern": "^%file_id_pattern%$" }, "name": { "const": "Alice Hansen" From e3d2f24fd81d6a9e8fb445af546522e0c64faef8 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 18 Sep 2024 10:07:22 +0200 Subject: [PATCH 3/3] fix(activitylog): space -> folder Signed-off-by: jkoberg --- services/activitylog/pkg/service/response.go | 2 +- tests/acceptance/features/apiActivities/shareActivities.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/activitylog/pkg/service/response.go b/services/activitylog/pkg/service/response.go index 4c0b59c7d9f..e8c80f8af27 100644 --- a/services/activitylog/pkg/service/response.go +++ b/services/activitylog/pkg/service/response.go @@ -21,7 +21,7 @@ import ( // Translations var ( MessageResourceCreated = l10n.Template("{user} added {resource} to {space}") - MessageResourceUpdated = l10n.Template("{user} updated {resource} in {space}") + MessageResourceUpdated = l10n.Template("{user} updated {resource} in {folder}") MessageResourceTrashed = l10n.Template("{user} deleted {resource} from {space}") MessageResourceMoved = l10n.Template("{user} moved {resource} to {space}") MessageResourceRenamed = l10n.Template("{user} renamed {oldResource} to {resource}") diff --git a/tests/acceptance/features/apiActivities/shareActivities.feature b/tests/acceptance/features/apiActivities/shareActivities.feature index 94f37403b75..7d039e5b323 100644 --- a/tests/acceptance/features/apiActivities/shareActivities.feature +++ b/tests/acceptance/features/apiActivities/shareActivities.feature @@ -678,7 +678,7 @@ Feature: check share activity "required": ["message","variables"], "properties": { "message": { - "const": "{user} updated {resource} in {space}" + "const": "{user} updated {resource} in {folder}" }, "variables": { "type": "object",