Merge pull request #5451 from owncloud/ainmosni/feature/add-reva-events-to-class-patch

Emit GroupFeatureChanged event on class patch.
This commit is contained in:
Daniël Franke
2023-01-24 11:41:08 +01:00
committed by GitHub
3 changed files with 28 additions and 1 deletions

2
go.mod
View File

@@ -11,7 +11,7 @@ require (
github.com/blevesearch/bleve/v2 v2.3.5
github.com/coreos/go-oidc/v3 v3.4.0
github.com/cs3org/go-cs3apis v0.0.0-20221012090518-ef2996678965
github.com/cs3org/reva/v2 v2.12.1-0.20230113095557-1a7bb8c77ed0
github.com/cs3org/reva/v2 v2.12.1-0.20230124073755-a6fe69ca6835
github.com/disintegration/imaging v1.6.2
github.com/ggwhite/go-masker v1.0.9
github.com/go-chi/chi/v5 v5.0.7

2
go.sum
View File

@@ -346,6 +346,8 @@ github.com/crewjam/saml v0.4.9 h1:X2jDv4dv3IvfT9t+RhADavzNFAcq3fVxzTCIH3G605U=
github.com/crewjam/saml v0.4.9/go.mod h1:9Zh6dWPtB3MSzTRt8fIFH60Z351QQ+s7hCU3J/tTlA4=
github.com/cs3org/reva/v2 v2.12.1-0.20230113095557-1a7bb8c77ed0 h1:OOFyGTaCOKo3uXFNNtUAQVSNYNDKlZ21EqdDLMHUzQQ=
github.com/cs3org/reva/v2 v2.12.1-0.20230113095557-1a7bb8c77ed0/go.mod h1:u73Df9JAZsDj43GIjQIb3DO1PLJuPutZXkRqQH0oGXA=
github.com/cs3org/reva/v2 v2.12.1-0.20230124073755-a6fe69ca6835 h1:501X6172E9DhjqRASOoCN8dW3l4cLhuu9pRp9OJI+Z8=
github.com/cs3org/reva/v2 v2.12.1-0.20230124073755-a6fe69ca6835/go.mod h1:u73Df9JAZsDj43GIjQIb3DO1PLJuPutZXkRqQH0oGXA=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=

View File

@@ -10,6 +10,8 @@ import (
"strings"
"github.com/CiscoM31/godata"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/events"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/v2/services/graph/pkg/service/v0/errorcode"
@@ -120,6 +122,15 @@ func (g Graph) PatchEducationClass(w http.ResponseWriter, r *http.Request) {
return
}
var features []events.GroupFeature
if displayName, ok := changes.GetDisplayNameOk(); ok {
features = append(features, events.GroupFeature{Name: "displayname", Value: *displayName})
}
if externalID, ok := changes.GetExternalIdOk(); ok {
features = append(features, events.GroupFeature{Name: "externalid", Value: *externalID})
}
_, err = g.identityEducationBackend.UpdateEducationClass(r.Context(), classID, *changes)
if err != nil {
logger.Error().
@@ -176,6 +187,20 @@ func (g Graph) PatchEducationClass(w http.ResponseWriter, r *http.Request) {
}
return
}
if len(features) > 0 {
e := events.GroupFeatureChanged{
GroupID: classID,
Features: features,
}
if currentUser, ok := revactx.ContextGetUser(r.Context()); ok {
e.Executant = currentUser.GetId()
}
g.publishEvent(e)
}
render.Status(r, http.StatusNoContent) // TODO StatusNoContent when prefer=minimal is used, otherwise OK and the resource in the body
render.NoContent(w, r)
}