diff --git a/changelog/unreleased/add-missing-timestamps.md b/changelog/unreleased/add-missing-timestamps.md new file mode 100644 index 0000000000..1cd20846fc --- /dev/null +++ b/changelog/unreleased/add-missing-timestamps.md @@ -0,0 +1,6 @@ +Bugfix: We added missing timestamps to events + +We added missing timestamps to events + +https://github.com/cs3org/reva/pull/3919 +https://github.com/owncloud/ocis/issues/3753 \ No newline at end of file diff --git a/internal/grpc/interceptors/eventsmiddleware/conversion.go b/internal/grpc/interceptors/eventsmiddleware/conversion.go index 98647c631b..6041e5ba44 100644 --- a/internal/grpc/interceptors/eventsmiddleware/conversion.go +++ b/internal/grpc/interceptors/eventsmiddleware/conversion.go @@ -37,6 +37,7 @@ func ContainerCreated(r *provider.CreateContainerResponse, req *provider.CreateC SpaceOwner: spaceOwner, Executant: executant, Ref: req.Ref, + Timestamp: utils.TSNow(), } } @@ -166,6 +167,7 @@ func LinkAccessFailed(r *link.GetPublicShareByTokenResponse, req *link.GetPublic Executant: executant, Status: r.Status.Code, Message: r.Status.Message, + Timestamp: utils.TSNow(), } if r.Share != nil { e.ShareID = r.Share.Id @@ -180,6 +182,7 @@ func LinkRemoved(r *link.RemovePublicShareResponse, req *link.RemovePublicShareR Executant: executant, ShareID: req.Ref.GetId(), ShareToken: req.Ref.GetToken(), + Timestamp: utils.TSNow(), } } @@ -189,6 +192,7 @@ func FileTouched(r *provider.TouchFileResponse, req *provider.TouchFileRequest, SpaceOwner: spaceOwner, Executant: executant, Ref: req.Ref, + Timestamp: utils.TSNow(), } } @@ -198,6 +202,7 @@ func FileUploaded(r *provider.InitiateFileUploadResponse, req *provider.Initiate SpaceOwner: spaceOwner, Executant: executant, Ref: req.Ref, + Timestamp: utils.TSNow(), } } @@ -206,6 +211,7 @@ func FileDownloaded(r *provider.InitiateFileDownloadResponse, req *provider.Init return events.FileDownloaded{ Executant: executant, Ref: req.Ref, + Timestamp: utils.TSNow(), } } @@ -221,6 +227,7 @@ func ItemTrashed(r *provider.DeleteResponse, req *provider.DeleteRequest, spaceO SpaceId: req.Ref.GetResourceId().GetSpaceId(), OpaqueId: opaqueID, }, + Timestamp: utils.TSNow(), } } @@ -231,6 +238,7 @@ func ItemMoved(r *provider.MoveResponse, req *provider.MoveRequest, spaceOwner, Executant: executant, Ref: req.Destination, OldReference: req.Source, + Timestamp: utils.TSNow(), } } @@ -239,6 +247,7 @@ func ItemPurged(r *provider.PurgeRecycleResponse, req *provider.PurgeRecycleRequ return events.ItemPurged{ Executant: executant, Ref: req.Ref, + Timestamp: utils.TSNow(), } } @@ -254,6 +263,7 @@ func ItemRestored(r *provider.RestoreRecycleItemResponse, req *provider.RestoreR Ref: ref, OldReference: req.Ref, Key: req.Key, + Timestamp: utils.TSNow(), } } @@ -264,6 +274,7 @@ func FileVersionRestored(r *provider.RestoreFileVersionResponse, req *provider.R Executant: executant, Ref: req.Ref, Key: req.Key, + Timestamp: utils.TSNow(), } } @@ -288,6 +299,7 @@ func SpaceRenamed(r *provider.UpdateStorageSpaceResponse, req *provider.UpdateSt ID: r.StorageSpace.Id, Owner: extractOwner(r.StorageSpace.Owner), Name: r.StorageSpace.Name, + Timestamp: utils.TSNow(), } } @@ -297,6 +309,7 @@ func SpaceUpdated(r *provider.UpdateStorageSpaceResponse, req *provider.UpdateSt Executant: executant, ID: r.StorageSpace.Id, Space: r.StorageSpace, + Timestamp: utils.TSNow(), } } @@ -306,6 +319,7 @@ func SpaceEnabled(r *provider.UpdateStorageSpaceResponse, req *provider.UpdateSt Executant: executant, ID: r.StorageSpace.Id, Owner: extractOwner(r.StorageSpace.Owner), + Timestamp: utils.TSNow(), } } diff --git a/pkg/events/files.go b/pkg/events/files.go index 802072ee75..cc21a4b07d 100644 --- a/pkg/events/files.go +++ b/pkg/events/files.go @@ -23,6 +23,7 @@ import ( user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ) // ContainerCreated is emitted when a directory has been created @@ -31,6 +32,7 @@ type ContainerCreated struct { Executant *user.UserId Ref *provider.Reference Owner *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -46,6 +48,7 @@ type FileUploaded struct { Executant *user.UserId Ref *provider.Reference Owner *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -60,6 +63,7 @@ type FileTouched struct { SpaceOwner *user.UserId Executant *user.UserId Ref *provider.Reference + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -74,6 +78,7 @@ type FileDownloaded struct { Executant *user.UserId Ref *provider.Reference Owner *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -90,6 +95,7 @@ type ItemTrashed struct { ID *provider.ResourceId Ref *provider.Reference Owner *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -106,6 +112,7 @@ type ItemMoved struct { Ref *provider.Reference Owner *user.UserId OldReference *provider.Reference + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -121,6 +128,7 @@ type ItemPurged struct { ID *provider.ResourceId Ref *provider.Reference Owner *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -139,6 +147,7 @@ type ItemRestored struct { Owner *user.UserId OldReference *provider.Reference Key string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -155,6 +164,7 @@ type FileVersionRestored struct { Ref *provider.Reference Owner *user.UserId Key string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface diff --git a/pkg/events/groups.go b/pkg/events/groups.go index c6bff4a9b0..b9d4645621 100644 --- a/pkg/events/groups.go +++ b/pkg/events/groups.go @@ -22,12 +22,14 @@ import ( "encoding/json" user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" + types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ) // GroupCreated is emitted when a group was created type GroupCreated struct { Executant *user.UserId GroupID string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -41,6 +43,7 @@ func (GroupCreated) Unmarshal(v []byte) (interface{}, error) { type GroupDeleted struct { Executant *user.UserId GroupID string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -55,6 +58,7 @@ type GroupMemberAdded struct { Executant *user.UserId GroupID string UserID string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -69,6 +73,7 @@ type GroupMemberRemoved struct { Executant *user.UserId GroupID string UserID string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -80,8 +85,9 @@ func (GroupMemberRemoved) Unmarshal(v []byte) (interface{}, error) { // GroupFeature represents a group feature type GroupFeature struct { - Name string - Value string + Name string + Value string + Timestamp *types.Timestamp } // GroupFeatureChanged is emitted when a group feature was changed @@ -89,6 +95,7 @@ type GroupFeatureChanged struct { Executant *user.UserId GroupID string Features []GroupFeature + Timestamp *types.Timestamp } // Unmarshal to fulfill unmarshaller interface diff --git a/pkg/events/postprocessing.go b/pkg/events/postprocessing.go index 2e4f8e57bb..74968e28e3 100644 --- a/pkg/events/postprocessing.go +++ b/pkg/events/postprocessing.go @@ -24,6 +24,7 @@ import ( user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ) type ( @@ -59,6 +60,7 @@ type BytesReceived struct { Filename string Filesize uint64 URL string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -80,6 +82,7 @@ type StartPostprocessingStep struct { RevaToken string // for file retrieval in after upload case StepToStart Postprocessingstep + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -99,6 +102,7 @@ type PostprocessingStepFinished struct { Result interface{} // result information see VirusscanResult for example Error error // possible error of the step Outcome PostprocessingOutcome // some services may cause postprocessing to stop + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -128,6 +132,7 @@ type VirusscanResult struct { Scandate time.Time ResourceID *provider.ResourceId ErrorMsg string // empty when no error + Timestamp *types.Timestamp } // PostprocessingFinished is emitted by *some* service which can decide that @@ -138,6 +143,7 @@ type PostprocessingFinished struct { ExecutingUser *user.User Result map[Postprocessingstep]interface{} // it is a map[step]Event Outcome PostprocessingOutcome + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -155,7 +161,7 @@ type UploadReady struct { ExecutingUser *user.User FileRef *provider.Reference Failed bool - Timestamp time.Time + Timestamp *types.Timestamp // add reference here? We could use it to inform client pp is finished } diff --git a/pkg/events/sharing.go b/pkg/events/sharing.go index 2551e5e3a4..77c7f04bed 100644 --- a/pkg/events/sharing.go +++ b/pkg/events/sharing.go @@ -206,6 +206,7 @@ type LinkAccessFailed struct { Token string Status rpc.Code Message string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -221,6 +222,7 @@ type LinkRemoved struct { // split protobuf Ref ShareID *link.PublicShareId ShareToken string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface diff --git a/pkg/events/spaces.go b/pkg/events/spaces.go index 4b9817c70d..03ab3ff0a6 100644 --- a/pkg/events/spaces.go +++ b/pkg/events/spaces.go @@ -53,6 +53,7 @@ type SpaceRenamed struct { ID *provider.StorageSpaceId Owner *user.UserId Name string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -81,6 +82,7 @@ type SpaceEnabled struct { Executant *user.UserId ID *provider.StorageSpaceId Owner *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -144,6 +146,7 @@ type SpaceUpdated struct { Executant *user.UserId ID *provider.StorageSpaceId Space *provider.StorageSpace + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -162,6 +165,7 @@ type SpaceMembershipExpired struct { // split the protobuf Grantee oneof so we can use stdlib encoding/json GranteeUserID *user.UserId GranteeGroupID *group.GroupId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface diff --git a/pkg/events/tags.go b/pkg/events/tags.go index 44b6adf05c..0bac8263a9 100644 --- a/pkg/events/tags.go +++ b/pkg/events/tags.go @@ -23,6 +23,7 @@ import ( user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ) // TagsAdded is emitted when a Tag has been added @@ -31,6 +32,7 @@ type TagsAdded struct { Tags string Ref *provider.Reference Executant *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -46,6 +48,7 @@ type TagsRemoved struct { Tags string Ref *provider.Reference Executant *user.UserId + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface diff --git a/pkg/events/users.go b/pkg/events/users.go index bf9b4fe00f..205af508a0 100644 --- a/pkg/events/users.go +++ b/pkg/events/users.go @@ -20,15 +20,16 @@ package events import ( "encoding/json" - "time" user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" + types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ) // UserCreated is emitted when a user was created type UserCreated struct { Executant *user.UserId UserID string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -42,6 +43,7 @@ func (UserCreated) Unmarshal(v []byte) (interface{}, error) { type UserDeleted struct { Executant *user.UserId UserID string + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -53,8 +55,9 @@ func (UserDeleted) Unmarshal(v []byte) (interface{}, error) { // UserFeature represents a user feature type UserFeature struct { - Name string - Value string + Name string + Value string + Timestamp *types.Timestamp } // UserFeatureChanged is emitted when a user feature was changed @@ -62,6 +65,7 @@ type UserFeatureChanged struct { Executant *user.UserId UserID string Features []UserFeature + Timestamp *types.Timestamp } // Unmarshal to fulfill umarshaller interface @@ -74,7 +78,7 @@ func (UserFeatureChanged) Unmarshal(v []byte) (interface{}, error) { // PersonalDataExtracted is emitted when a user data extraction is finished type PersonalDataExtracted struct { Executant *user.UserId - Timestamp time.Time + Timestamp *types.Timestamp ErrorMsg string } diff --git a/pkg/rhttp/datatx/datatx.go b/pkg/rhttp/datatx/datatx.go index e7c8bedcb5..db6072b6da 100644 --- a/pkg/rhttp/datatx/datatx.go +++ b/pkg/rhttp/datatx/datatx.go @@ -28,6 +28,7 @@ import ( "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/storage" "github.com/cs3org/reva/v2/pkg/storage/cache" + "github.com/cs3org/reva/v2/pkg/utils" ) // DataTX provides an abstraction around various data transfer protocols. @@ -46,6 +47,7 @@ func EmitFileUploadedEvent(spaceOwnerOrManager, executant *userv1beta1.UserId, r Owner: spaceOwnerOrManager, Executant: executant, Ref: ref, + Timestamp: utils.TSNow(), } return events.Publish(publisher, uploadedEv) diff --git a/pkg/storage/utils/decomposedfs/decomposedfs.go b/pkg/storage/utils/decomposedfs/decomposedfs.go index c065966b3a..bbca3e8d22 100644 --- a/pkg/storage/utils/decomposedfs/decomposedfs.go +++ b/pkg/storage/utils/decomposedfs/decomposedfs.go @@ -262,7 +262,7 @@ func (fs *Decomposedfs) Postprocessing(ch <-chan events.Event) { }, Path: utils.MakeRelativePath(filepath.Join(up.Info.MetaData["dir"], up.Info.MetaData["filename"])), }, - Timestamp: now, + Timestamp: utils.TimeToTS(now), SpaceOwner: n.SpaceOwnerOrManager(ctx), }, ); err != nil {