mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-01 18:01:28 -06:00
5
changelog/unreleased/initiator-ids.md
Normal file
5
changelog/unreleased/initiator-ids.md
Normal file
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user