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

add events definitions for users and groups #2717

Merged
merged 1 commit into from
Apr 6, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}