diff --git a/changelog/unreleased/initiator-ids.md b/changelog/unreleased/initiator-ids.md new file mode 100644 index 000000000..013fa2bec --- /dev/null +++ b/changelog/unreleased/initiator-ids.md @@ -0,0 +1,5 @@ +Enhancement: Initiator-IDs + +Allows sending a header `Initiator-ID` on http requests. This id will be added to sse events so clients can figure out if their particular instance was triggering the event. Additionally this adds the etag of the file/folder to all sse events. + +https://github.com/owncloud/ocis/pull/8701 diff --git a/services/postprocessing/pkg/postprocessing/postprocessing.go b/services/postprocessing/pkg/postprocessing/postprocessing.go index e3c9ca6bf..afdc15f70 100644 --- a/services/postprocessing/pkg/postprocessing/postprocessing.go +++ b/services/postprocessing/pkg/postprocessing/postprocessing.go @@ -12,15 +12,16 @@ import ( // Postprocessing handles postprocessing of a file type Postprocessing struct { - ID string - URL string - User *user.User - Filename string - Filesize uint64 - ResourceID *provider.ResourceId - Steps []events.Postprocessingstep - Status Status - Failures int + ID string + URL string + User *user.User + Filename string + Filesize uint64 + ResourceID *provider.ResourceId + Steps []events.Postprocessingstep + Status Status + Failures int + InitiatorID string config config.Postprocessing } diff --git a/services/postprocessing/pkg/service/service.go b/services/postprocessing/pkg/service/service.go index f2a3c122e..3d1a81f07 100644 --- a/services/postprocessing/pkg/service/service.go +++ b/services/postprocessing/pkg/service/service.go @@ -7,6 +7,7 @@ import ( "fmt" "time" + ctxpkg "github.com/cs3org/reva/v2/pkg/ctx" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/utils" "github.com/owncloud/ocis/v2/ocis-pkg/log" @@ -92,13 +93,14 @@ func (pps *PostprocessingService) processEvent(e events.Event) error { switch ev := e.Event.(type) { case events.BytesReceived: pp = &postprocessing.Postprocessing{ - ID: ev.UploadID, - URL: ev.URL, - User: ev.ExecutingUser, - Filename: ev.Filename, - Filesize: ev.Filesize, - ResourceID: ev.ResourceID, - Steps: pps.steps, + ID: ev.UploadID, + URL: ev.URL, + User: ev.ExecutingUser, + Filename: ev.Filename, + Filesize: ev.Filesize, + ResourceID: ev.ResourceID, + Steps: pps.steps, + InitiatorID: e.InitiatorID, } next = pp.Init(ev) case events.PostprocessingStepFinished: @@ -160,11 +162,14 @@ func (pps *PostprocessingService) processEvent(e events.Event) error { } if pp != nil { + ctx = ctxpkg.ContextSetInitiator(ctx, pp.InitiatorID) + if err := storePP(pps.store, pp); err != nil { pps.log.Error().Str("uploadID", pp.ID).Err(err).Msg("cannot store upload") return fmt.Errorf("%w: cannot store upload", errEvent) } } + if next != nil { if err := events.Publish(ctx, pps.pub, next); err != nil { pps.log.Error().Err(err).Msg("unable to publish event")