From 2d60212e1268aa51c6509caab529a9059b7dd16d Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Mon, 19 Jun 2023 11:16:44 +0200 Subject: [PATCH] incorporate requested changes Signed-off-by: Christian Richter --- services/audit/pkg/types/helpers.go | 12 ------------ services/audit/pkg/types/messages.go | 17 +++++++++-------- 2 files changed, 9 insertions(+), 20 deletions(-) delete mode 100644 services/audit/pkg/types/helpers.go diff --git a/services/audit/pkg/types/helpers.go b/services/audit/pkg/types/helpers.go deleted file mode 100644 index 989cb66c20..0000000000 --- a/services/audit/pkg/types/helpers.go +++ /dev/null @@ -1,12 +0,0 @@ -package types - -import "strings" - -// SplitStorageIDFromSpaceID splits the storage- and spaceid- from the given string -func SplitStorageIDFromSpaceID(id string) (string, string) { - ids := strings.Split(id, "$") - if len(ids) != 2 { - return id, "" - } - return ids[0], ids[1] -} diff --git a/services/audit/pkg/types/messages.go b/services/audit/pkg/types/messages.go index ce28ae52f0..049e08f5bf 100644 --- a/services/audit/pkg/types/messages.go +++ b/services/audit/pkg/types/messages.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/cs3org/reva/v2/pkg/events" + "github.com/cs3org/reva/v2/pkg/storagespace" ) // short identifiers for audit actions @@ -139,49 +140,49 @@ func MessageFileVersionRestored(executant, item, version string) string { // MessageSpaceCreated returns the human readable string that describes the action func MessageSpaceCreated(executant, spaceID, name string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' created a space '%s' with name '%s' (storage: '%s')", executant, spaceID, name, storagID) } // MessageSpaceRenamed returns the human readable string that describes the action func MessageSpaceRenamed(executant, spaceID, name string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' renamed space '%s' to '%s' (storage: '%s')", executant, spaceID, name, storagID) } // MessageSpaceDisabled returns the human readable string that describes the action func MessageSpaceDisabled(executant, spaceID string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' disabled the space '%s' (storage: '%s')", executant, spaceID, storagID) } // MessageSpaceEnabled returns the human readable string that describes the action func MessageSpaceEnabled(executant, spaceID string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' (re-) enabled the space '%s' (storage: '%s')", executant, spaceID, storagID) } // MessageSpaceDeleted returns the human readable string that describes the action func MessageSpaceDeleted(executant, spaceID string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' deleted the space '%s' (storage: '%s')", executant, spaceID, storagID) } // MessageSpaceShared returns the human readable string that describes the action func MessageSpaceShared(executant, spaceID, grantee string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' shared the space '%s' with '%s' (storage: '%s')", executant, spaceID, grantee, storagID) } // MessageSpaceUnshared returns the human readable string that describes the action func MessageSpaceUnshared(executant, spaceID, grantee string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' unshared the space '%s' with '%s' (storage: '%s')", executant, spaceID, grantee, storagID) } // MessageSpaceUpdated returns the human readable string that describes the action func MessageSpaceUpdated(executant, spaceID, name string, quota uint64, opaque map[string]string) string { - storagID, spaceID := SplitStorageIDFromSpaceID(spaceID) + storagID, spaceID := storagespace.SplitStorageID(spaceID) return fmt.Sprintf("user '%s' updated space '%s'. name: '%s', quota: '%d', opaque: '%s' (storage: '%s')", executant, spaceID, name, quota, opaque, storagID) }