Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci] Delete userlog events #7410

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/unreleased/bump-reva.md
Expand Up @@ -6,3 +6,4 @@ https://github.com/owncloud/ocis/pull/7138
https://github.com/owncloud/ocis/pull/6427
https://github.com/owncloud/ocis/pull/7178
https://github.com/owncloud/ocis/pull/7217
https://github.com/owncloud/ocis/pull/7410
5 changes: 5 additions & 0 deletions changelog/unreleased/delete-outdated-userlog-events.md
@@ -0,0 +1,5 @@
Bugfix: Delete outdated userlog events

Userlog will now delete events when the user has no longer access to the underlying resource

https://github.com/owncloud/ocis/pull/7410
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -13,7 +13,7 @@ require (
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/coreos/go-oidc/v3 v3.6.0
github.com/cs3org/go-cs3apis v0.0.0-20230516150832-730ac860c71d
github.com/cs3org/reva/v2 v2.16.1-0.20230926132524-45fce234f21b
github.com/cs3org/reva/v2 v2.16.1-0.20231004143709-c089e31b8175
github.com/disintegration/imaging v1.6.2
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
github.com/egirna/icap-client v0.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -1011,8 +1011,8 @@ github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo
github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4=
github.com/crewjam/saml v0.4.13 h1:TYHggH/hwP7eArqiXSJUvtOPNzQDyQ7vwmwEqlFWhMc=
github.com/crewjam/saml v0.4.13/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA=
github.com/cs3org/reva/v2 v2.16.1-0.20230926132524-45fce234f21b h1:G5lYtoDjMLPvPJk9hXEVJoVTHJZEuCWZ2Wr+n0rpJAA=
github.com/cs3org/reva/v2 v2.16.1-0.20230926132524-45fce234f21b/go.mod h1:WFSfkOQNmUggMed4lUQTF2vd9hg0acvsHI6awGwnwxQ=
github.com/cs3org/reva/v2 v2.16.1-0.20231004143709-c089e31b8175 h1:3rWU0bw0q2SlaScyTKX5Xb5usVdznz4ygV2DnHKtlzM=
github.com/cs3org/reva/v2 v2.16.1-0.20231004143709-c089e31b8175/go.mod h1:WFSfkOQNmUggMed4lUQTF2vd9hg0acvsHI6awGwnwxQ=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
15 changes: 15 additions & 0 deletions services/userlog/pkg/service/http.go
Expand Up @@ -61,6 +61,7 @@ func (ul *UserlogService) HandleGetEvents(w http.ResponseWriter, r *http.Request

conv := NewConverter(ctx, r.Header.Get(HeaderAcceptLanguage), gwc, ul.cfg.Service.Name, ul.cfg.TranslationPath)

var outdatedEvents []string
resp := GetEventResponseOC10{}
for _, e := range evs {
etype, ok := ul.registeredEvents[e.Type]
Expand All @@ -77,13 +78,27 @@ func (ul *UserlogService) HandleGetEvents(w http.ResponseWriter, r *http.Request

noti, err := conv.ConvertEvent(e.Id, einterface)
if err != nil {
if utils.IsErrNotFound(err) || utils.IsErrPermissionDenied(err) {
outdatedEvents = append(outdatedEvents, e.Id)
continue
}
ul.log.Error().Err(err).Str("eventid", e.Id).Str("eventtype", e.Type).Msg("failed to convert event")
continue
}

resp.OCS.Data = append(resp.OCS.Data, noti)
}

// delete outdated events asynchronously
if len(outdatedEvents) > 0 {
go func() {
err := ul.DeleteEvents(u.GetId().GetOpaqueId(), outdatedEvents)
if err != nil {
ul.log.Error().Err(err).Msg("failed to delete events")
}
}()
}

glevs, err := ul.GetGlobalEvents(ctx)
if err != nil {
ul.log.Error().Err(err).Int("returned statuscode", http.StatusInternalServerError).Msg("get global events failed")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 49 additions & 11 deletions vendor/github.com/cs3org/reva/v2/pkg/utils/grpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Expand Up @@ -357,7 +357,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.16.1-0.20230926132524-45fce234f21b
# github.com/cs3org/reva/v2 v2.16.1-0.20231004143709-c089e31b8175
## explicit; go 1.20
github.com/cs3org/reva/v2/cmd/revad/internal/grace
github.com/cs3org/reva/v2/cmd/revad/runtime
Expand Down