Skip to content

Commit

Permalink
emit linkaccessfailed event when share is nil (#2643)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic authored Mar 17, 2022
1 parent 9911567 commit 701b083
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/make-linkaccessfailed-more-robust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: emit linkaccessfailed event when share is nil

The code no longer panics when a link access failed event has no share.

https://github.com/cs3org/reva/pull/2643
9 changes: 6 additions & 3 deletions internal/grpc/interceptors/eventsmiddleware/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,15 @@ func LinkAccessed(r *link.GetPublicShareByTokenResponse) events.LinkAccessed {

// LinkAccessFailed converts the response to an event
func LinkAccessFailed(r *link.GetPublicShareByTokenResponse, req *link.GetPublicShareByTokenRequest) events.LinkAccessFailed {
return events.LinkAccessFailed{
ShareID: r.Share.Id,
Token: r.Share.Token,
e := events.LinkAccessFailed{
Status: r.Status.Code,
Message: r.Status.Message,
}
if r.Share != nil {
e.ShareID = r.Share.Id
e.Token = r.Share.Token
}
return e
}

// LinkRemoved converts the response to an event
Expand Down

0 comments on commit 701b083

Please sign in to comment.