mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-09 05:39:52 -06:00
5
changelog/unreleased/file-unlocked-sse.md
Normal file
5
changelog/unreleased/file-unlocked-sse.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Enhancement: Send SSE when file is locked/unlocked
|
||||
|
||||
Send sse events when a file is locked or unlocked.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/8602
|
||||
2
go.mod
2
go.mod
@@ -14,7 +14,7 @@ require (
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible
|
||||
github.com/coreos/go-oidc/v3 v3.9.0
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781
|
||||
github.com/cs3org/reva/v2 v2.19.2-0.20240307091744-fa2caba1f4e4
|
||||
github.com/cs3org/reva/v2 v2.19.2-0.20240308081122-3b519e2f9a15
|
||||
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1019,8 +1019,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c=
|
||||
github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME=
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY=
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
|
||||
github.com/cs3org/reva/v2 v2.19.2-0.20240307091744-fa2caba1f4e4 h1:dOApLUv2cYnWU1Z8pqEBk8a9BEGe6VRl/f0sFmwzLw4=
|
||||
github.com/cs3org/reva/v2 v2.19.2-0.20240307091744-fa2caba1f4e4/go.mod h1:GRUrOp5HbFVwZTgR9bVrMZ/MvVy+Jhxw1PdMmhhKP9E=
|
||||
github.com/cs3org/reva/v2 v2.19.2-0.20240308081122-3b519e2f9a15 h1:++sksh5HfGlP5FMXww2UWFkSQ+8Y+GJuCdLbDQ09c1k=
|
||||
github.com/cs3org/reva/v2 v2.19.2-0.20240308081122-3b519e2f9a15/go.mod h1:GRUrOp5HbFVwZTgR9bVrMZ/MvVy+Jhxw1PdMmhhKP9E=
|
||||
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
|
||||
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
|
||||
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
|
||||
|
||||
@@ -30,6 +30,8 @@ var _registeredEvents = []events.Unmarshaller{
|
||||
events.ItemRestored{},
|
||||
events.ItemMoved{},
|
||||
events.ContainerCreated{},
|
||||
events.FileLocked{},
|
||||
events.FileUnlocked{},
|
||||
}
|
||||
|
||||
// Server is the entrypoint for the server command.
|
||||
|
||||
@@ -139,6 +139,12 @@ func (cl *ClientlogService) processEvent(event events.Event) {
|
||||
}
|
||||
evType = "item-renamed"
|
||||
users, data, err = processFileEvent(ctx, e.Ref, gwc)
|
||||
case events.FileLocked:
|
||||
evType = "file-locked"
|
||||
users, data, err = processFileEvent(ctx, e.Ref, gwc)
|
||||
case events.FileUnlocked:
|
||||
evType = "file-unlocked"
|
||||
users, data, err = processFileEvent(ctx, e.Ref, gwc)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -216,6 +216,24 @@ func FileDownloaded(r *provider.InitiateFileDownloadResponse, req *provider.Init
|
||||
}
|
||||
}
|
||||
|
||||
// FileLocked converts the response to an events
|
||||
func FileLocked(r *provider.SetLockResponse, req *provider.SetLockRequest, owner, executant *user.UserId) events.FileLocked {
|
||||
return events.FileLocked{
|
||||
Executant: executant,
|
||||
Ref: req.Ref,
|
||||
Timestamp: utils.TSNow(),
|
||||
}
|
||||
}
|
||||
|
||||
// FileUnlocked converts the response to an event
|
||||
func FileUnlocked(r *provider.UnlockResponse, req *provider.UnlockRequest, owner, executant *user.UserId) events.FileUnlocked {
|
||||
return events.FileUnlocked{
|
||||
Executant: executant,
|
||||
Ref: req.Ref,
|
||||
Timestamp: utils.TSNow(),
|
||||
}
|
||||
}
|
||||
|
||||
// ItemTrashed converts the response to an event
|
||||
func ItemTrashed(r *provider.DeleteResponse, req *provider.DeleteRequest, spaceOwner, executant *user.UserId) events.ItemTrashed {
|
||||
opaqueID := utils.ReadPlainFromOpaque(r.Opaque, "opaque_id")
|
||||
|
||||
@@ -184,6 +184,15 @@ func NewUnary(m map[string]interface{}) (grpc.UnaryServerInterceptor, int, error
|
||||
if isSuccess(v) {
|
||||
ev = FileTouched(v, req.(*provider.TouchFileRequest), ownerID, executantID)
|
||||
}
|
||||
case *provider.SetLockResponse:
|
||||
fmt.Println("set lock response", v)
|
||||
if isSuccess(v) {
|
||||
ev = FileLocked(v, req.(*provider.SetLockRequest), ownerID, executantID)
|
||||
}
|
||||
case *provider.UnlockResponse:
|
||||
if isSuccess(v) {
|
||||
ev = FileUnlocked(v, req.(*provider.UnlockRequest), ownerID, executantID)
|
||||
}
|
||||
}
|
||||
|
||||
if ev != nil {
|
||||
|
||||
30
vendor/github.com/cs3org/reva/v2/pkg/events/files.go
generated
vendored
30
vendor/github.com/cs3org/reva/v2/pkg/events/files.go
generated
vendored
@@ -88,6 +88,36 @@ func (FileDownloaded) Unmarshal(v []byte) (interface{}, error) {
|
||||
return e, err
|
||||
}
|
||||
|
||||
// FileLocked is emitted when a file is locked
|
||||
type FileLocked struct {
|
||||
Executant *user.UserId
|
||||
Ref *provider.Reference
|
||||
Owner *user.UserId
|
||||
Timestamp *types.Timestamp
|
||||
}
|
||||
|
||||
// Unmarshal to fulfill umarshaller interface
|
||||
func (FileLocked) Unmarshal(v []byte) (interface{}, error) {
|
||||
e := FileLocked{}
|
||||
err := json.Unmarshal(v, &e)
|
||||
return e, err
|
||||
}
|
||||
|
||||
// FileUnlocked is emitted when a file is unlocked
|
||||
type FileUnlocked struct {
|
||||
Executant *user.UserId
|
||||
Ref *provider.Reference
|
||||
Owner *user.UserId
|
||||
Timestamp *types.Timestamp
|
||||
}
|
||||
|
||||
// Unmarshal to fulfill umarshaller interface
|
||||
func (FileUnlocked) Unmarshal(v []byte) (interface{}, error) {
|
||||
e := FileUnlocked{}
|
||||
err := json.Unmarshal(v, &e)
|
||||
return e, err
|
||||
}
|
||||
|
||||
// ItemTrashed is emitted when a file or folder is trashed
|
||||
type ItemTrashed struct {
|
||||
SpaceOwner *user.UserId
|
||||
|
||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -359,7 +359,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1
|
||||
github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1
|
||||
github.com/cs3org/go-cs3apis/cs3/tx/v1beta1
|
||||
github.com/cs3org/go-cs3apis/cs3/types/v1beta1
|
||||
# github.com/cs3org/reva/v2 v2.19.2-0.20240307091744-fa2caba1f4e4
|
||||
# github.com/cs3org/reva/v2 v2.19.2-0.20240308081122-3b519e2f9a15
|
||||
## explicit; go 1.21
|
||||
github.com/cs3org/reva/v2/cmd/revad/internal/grace
|
||||
github.com/cs3org/reva/v2/cmd/revad/runtime
|
||||
|
||||
Reference in New Issue
Block a user