Skip to content

Commit 9d2533e

Browse files
authored
extend app /notify endpoint to allow reporting errors (#5085)
1 parent 7c299e3 commit 9d2533e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

changelog/unreleased/app-notify.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Enhancement: extend app /notify endpoint to allow reporting errors
2+
3+
https://github.com/cs3org/reva/pull/5085

internal/http/services/appprovider/appprovider.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"context"
2323
"crypto/tls"
2424
"encoding/json"
25+
"io"
2526
"net/http"
2627
"path"
2728

@@ -469,10 +470,17 @@ func (s *svc) handleNotify(w http.ResponseWriter, r *http.Request) {
469470
fileRef.ResourceId = resourceID
470471
}
471472

473+
// the body of the request may contain any error the client got when attempting to open the app
474+
failure, _ := io.ReadAll(r.Body)
475+
472476
// log the fileid for later correlation / monitoring
473477
ctx := r.Context()
474478
log := appctx.GetLogger(ctx)
475-
log.Info().Interface("resource", fileRef).Msg("file successfully opened in app")
479+
if len(failure) == 0 {
480+
log.Info().Interface("resource", fileRef).Msg("file successfully opened in app")
481+
} else {
482+
log.Info().Interface("resource", fileRef).Str("failure", string(failure)).Msg("failed to open file in app")
483+
}
476484

477485
w.WriteHeader(http.StatusOK)
478486
}

0 commit comments

Comments
 (0)