Skip to content

Commit

Permalink
add events definitions for users and groups (#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas authored Apr 6, 2022
1 parent 315a05a commit b89245f
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/user-group-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add definitions for user and group events

Enhance the events package with definitions for user and group events.

https://github.com/cs3org/reva/pull/2717
73 changes: 73 additions & 0 deletions pkg/events/groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2018-2022 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

package events

import (
"encoding/json"
)

// GroupCreated is emitted when a group was created
type GroupCreated struct {
GroupID string
}

// Unmarshal to fulfill umarshaller interface
func (GroupCreated) Unmarshal(v []byte) (interface{}, error) {
e := GroupCreated{}
err := json.Unmarshal(v, &e)
return e, err
}

// GroupDeleted is emitted when a group was deleted
type GroupDeleted struct {
GroupID string
}

// Unmarshal to fulfill umarshaller interface
func (GroupDeleted) Unmarshal(v []byte) (interface{}, error) {
e := GroupDeleted{}
err := json.Unmarshal(v, &e)
return e, err
}

// GroupMemberAdded is emitted when a user was added to a group
type GroupMemberAdded struct {
GroupID string
UserID string
}

// Unmarshal to fulfill umarshaller interface
func (GroupMemberAdded) Unmarshal(v []byte) (interface{}, error) {
e := GroupMemberAdded{}
err := json.Unmarshal(v, &e)
return e, err
}

// GroupMemberRemoved is emitted when a user was removed from a group
type GroupMemberRemoved struct {
GroupID string
UserID string
}

// Unmarshal to fulfill umarshaller interface
func (GroupMemberRemoved) Unmarshal(v []byte) (interface{}, error) {
e := GroupMemberRemoved{}
err := json.Unmarshal(v, &e)
return e, err
}
61 changes: 61 additions & 0 deletions pkg/events/users.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2018-2022 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

package events

import (
"encoding/json"
)

// UserCreated is emitted when a user was created
type UserCreated struct {
UserID string
}

// Unmarshal to fulfill umarshaller interface
func (UserCreated) Unmarshal(v []byte) (interface{}, error) {
e := UserCreated{}
err := json.Unmarshal(v, &e)
return e, err
}

// UserDeleted is emitted when a user was deleted
type UserDeleted struct {
UserID string
}

// Unmarshal to fulfill umarshaller interface
func (UserDeleted) Unmarshal(v []byte) (interface{}, error) {
e := UserDeleted{}
err := json.Unmarshal(v, &e)
return e, err
}

// UserFeatureChanged is emitted when a user feature was changed
type UserFeatureChanged struct {
UserID string
Feature string
Value string
}

// Unmarshal to fulfill umarshaller interface
func (UserFeatureChanged) Unmarshal(v []byte) (interface{}, error) {
e := UserFeatureChanged{}
err := json.Unmarshal(v, &e)
return e, err
}

0 comments on commit b89245f

Please sign in to comment.