diff --git a/changelog/unreleased/add-storage-id-to-audit-log.md b/changelog/unreleased/add-storage-id-to-audit-log.md new file mode 100644 index 0000000000..dd9eb887a9 --- /dev/null +++ b/changelog/unreleased/add-storage-id-to-audit-log.md @@ -0,0 +1,6 @@ +Enhancement: We added the storage id to the audit log for spaces + +We added the storage id to the audit log for spaces + +https://github.com/owncloud/ocis/pull/6548 +https://github.com/owncloud/ocis/issues/3753 \ No newline at end of file diff --git a/services/audit/pkg/types/helpers.go b/services/audit/pkg/types/helpers.go new file mode 100644 index 0000000000..f1aad63836 --- /dev/null +++ b/services/audit/pkg/types/helpers.go @@ -0,0 +1,8 @@ +package types + +import "strings" + +func SplitId(id string) (string, string) { + ids := strings.Split(id, "$") + return ids[0], ids[1] +} diff --git a/services/audit/pkg/types/constants.go b/services/audit/pkg/types/messages.go similarity index 89% rename from services/audit/pkg/types/constants.go rename to services/audit/pkg/types/messages.go index e41f53ba6c..8ef8e3fe7f 100644 --- a/services/audit/pkg/types/constants.go +++ b/services/audit/pkg/types/messages.go @@ -139,43 +139,51 @@ func MessageFileVersionRestored(executant, item, version string) string { // MessageSpaceCreated returns the human readable string that describes the action func MessageSpaceCreated(executant, spaceID, name string) string { - return fmt.Sprintf("user '%s' created a space '%s' with name '%s'", executant, spaceID, name) + storagId, spaceID := SplitId(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 { - return fmt.Sprintf("user '%s' renamed space '%s' to '%s'", executant, spaceID, name) + storagId, spaceID := SplitId(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 { - return fmt.Sprintf("user '%s' disabled the space '%s'", executant, spaceID) + storagId, spaceID := SplitId(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 { - return fmt.Sprintf("user '%s' (re-) enabled the space '%s'", executant, spaceID) + storagId, spaceID := SplitId(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 { - return fmt.Sprintf("user '%s' deleted the space '%s'", executant, spaceID) + storagId, spaceID := SplitId(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 { - return fmt.Sprintf("user '%s' shared the space '%s' with '%s'", executant, spaceID, grantee) + storagId, spaceID := SplitId(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 { - return fmt.Sprintf("user '%s' unshared the space '%s' with '%s'", executant, spaceID, grantee) + storagId, spaceID := SplitId(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 { - return fmt.Sprintf("user '%s' updated space '%s'. name: '%s', quota: '%d', opaque: '%s'", - executant, spaceID, name, quota, opaque) + storagId, spaceID := SplitId(spaceID) + return fmt.Sprintf("user '%s' updated space '%s'. name: '%s', quota: '%d', opaque: '%s' (storage: '%s')", + executant, spaceID, name, quota, opaque, storagId) } // MessageUserCreated returns the human readable string that describes the action