Skip to content

Commit

Permalink
implementation
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Mar 16, 2022
1 parent c8c4b77 commit 9a318b5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 14 deletions.
36 changes: 29 additions & 7 deletions internal/grpc/interceptors/eventsmiddleware/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,35 +145,57 @@ func LinkRemoved(r *link.RemovePublicShareResponse, req *link.RemovePublicShareR

// FileUploaded converts the response to an event
func FileUploaded(r *provider.InitiateFileUploadResponse, req *provider.InitiateFileUploadRequest) events.FileUploaded {
return events.FileUploaded{}
return events.FileUploaded{
FileID: req.Ref,
}
}

// FileDownloaded converts the response to an event
func FileDownloaded(r *provider.InitiateFileDownloadResponse, req *provider.InitiateFileDownloadRequest) events.FileDownloaded {
return events.FileDownloaded{}
return events.FileDownloaded{
FileID: req.Ref,
}
}

// ItemTrashed converts the response to an event
func ItemTrashed(r *provider.DeleteResponse, req *provider.DeleteRequest) events.ItemTrashed {
return events.ItemTrashed{}
return events.ItemTrashed{
FileID: req.Ref,
}
}

// ItemMoved converts the response to an event
func ItemMoved(r *provider.MoveResponse, req *provider.MoveRequest) events.ItemMoved {
return events.ItemMoved{}
return events.ItemMoved{
FileID: req.Destination,
OldReference: req.Source,
}
}

// ItemPurged converts the response to an event
func ItemPurged(r *provider.PurgeRecycleResponse, req *provider.PurgeRecycleRequest) events.ItemPurged {
return events.ItemPurged{}
return events.ItemPurged{
FileID: req.Ref,
}
}

// ItemRestored converts the response to an event
func ItemRestored(r *provider.RestoreRecycleItemResponse, req *provider.RestoreRecycleItemRequest) events.ItemRestored {
return events.ItemRestored{}
ref := req.Ref
if req.RestoreRef != nil {
ref = req.RestoreRef
}
return events.ItemRestored{
FileID: ref,
OldReference: req.Ref,
Key: req.Key,
}
}

// FileVersionRestored converts the response to an event
func FileVersionRestored(r *provider.RestoreFileVersionResponse, req *provider.RestoreFileVersionRequest) events.FileVersionRestored {
return events.FileVersionRestored{}
return events.FileVersionRestored{
FileID: req.Ref,
Key: req.Key,
}
}
48 changes: 41 additions & 7 deletions pkg/events/files.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,70 @@
// Copyright 2018-2022 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

package events

import (
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
)

// FileUploaded is emitted when a file is uploaded
type FileUploaded struct {
FileID string
FileID *provider.Reference
Owner *user.UserId
}

//FileDownloaded is emitted when a file is downloaded
type FileDownloaded struct {
FileID string
FileID *provider.Reference
Owner *user.UserId
}

// ItemTrashed is emitted when a file or folder is trashed
type ItemTrashed struct {
FileID string
FileID *provider.Reference
Owner *user.UserId
}

// ItemMoved is emitted when a file or folder is moved
type ItemMoved struct {
FileID string
FileID *provider.Reference
Owner *user.UserId
OldReference *provider.Reference
}

// ItemPurged is emitted when a file or folder is removed from trashbin
type ItemPurged struct {
FileID string
FileID *provider.Reference
Owner *user.UserId
}

// ItemRestored is emitted when a file or folder is restored from trashbin
type ItemRestored struct {
FileID string
FileID *provider.Reference
Owner *user.UserId
OldReference *provider.Reference
Key string
}

// FileVersionRestored is emitted when a file version is restored
type FileVersionRestored struct {
FileID string
FileID *provider.Reference
Owner *user.UserId
Key string
}

0 comments on commit 9a318b5

Please sign in to comment.