vikunja/pkg/models/events.go

248 lines
6.1 KiB
Go
Raw Normal View History

2021-01-31 14:08:39 +00:00
// Vikunja is a to-do list application to facilitate your life.
// Copyright 2018-2021 Vikunja and contributors. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public Licensee as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public Licensee for more details.
//
// You should have received a copy of the GNU Affero General Public Licensee
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package models
2021-01-31 20:22:54 +00:00
import (
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/web"
2021-01-31 20:22:54 +00:00
)
2021-01-31 19:38:57 +00:00
2021-01-31 20:59:03 +00:00
/////////////////
// Task Events //
/////////////////
2021-02-02 19:14:15 +00:00
// TaskCreatedEvent represents an event where a task has been created
2021-01-31 14:08:39 +00:00
type TaskCreatedEvent struct {
Task *Task
Doer web.Auth
2021-01-31 14:08:39 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TaskCreatedEvent
2021-02-02 18:49:17 +00:00
func (t *TaskCreatedEvent) Name() string {
2021-01-31 14:08:39 +00:00
return "task.created"
}
2021-02-02 19:14:15 +00:00
// TaskUpdatedEvent represents an event where a task has been updated
2021-01-31 20:15:33 +00:00
type TaskUpdatedEvent struct {
Task *Task
Doer web.Auth
2021-01-31 20:15:33 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TaskUpdatedEvent
2021-02-02 18:49:17 +00:00
func (t *TaskUpdatedEvent) Name() string {
2021-01-31 20:15:33 +00:00
return "task.updated"
}
// TaskDeletedEvent represents a TaskDeletedEvent event
type TaskDeletedEvent struct {
Task *Task
Doer web.Auth
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TaskDeletedEvent
2021-02-02 18:49:17 +00:00
func (t *TaskDeletedEvent) Name() string {
return "task.deleted"
}
2021-02-02 19:14:15 +00:00
// TaskAssigneeCreatedEvent represents an event where a task has been assigned to a user
2021-01-31 20:22:54 +00:00
type TaskAssigneeCreatedEvent struct {
Task *Task
Assignee *user.User
Doer web.Auth
2021-01-31 20:22:54 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TaskAssigneeCreatedEvent
2021-02-02 18:49:17 +00:00
func (t *TaskAssigneeCreatedEvent) Name() string {
2021-01-31 20:22:54 +00:00
return "task.assignee.created"
}
2021-02-02 19:14:15 +00:00
// TaskCommentCreatedEvent represents an event where a task comment has been created
2021-01-31 20:51:06 +00:00
type TaskCommentCreatedEvent struct {
Task *Task
Comment *TaskComment
Doer web.Auth
2021-01-31 20:51:06 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TaskCommentCreatedEvent
2021-02-02 18:49:17 +00:00
func (t *TaskCommentCreatedEvent) Name() string {
2021-01-31 20:51:06 +00:00
return "task.comment.created"
}
2021-01-31 20:55:10 +00:00
2021-01-31 20:59:03 +00:00
//////////////////////
// Namespace Events //
//////////////////////
2021-02-02 19:14:15 +00:00
// NamespaceCreatedEvent represents an event where a namespace has been created
2021-01-31 20:55:10 +00:00
type NamespaceCreatedEvent struct {
Namespace *Namespace
Doer web.Auth
2021-01-31 20:55:10 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for NamespaceCreatedEvent
2021-02-02 18:49:17 +00:00
func (n *NamespaceCreatedEvent) Name() string {
2021-01-31 20:55:10 +00:00
return "namespace.created"
}
2021-01-31 20:59:03 +00:00
2021-02-02 19:14:15 +00:00
// NamespaceUpdatedEvent represents an event where a namespace has been updated
2021-01-31 20:59:03 +00:00
type NamespaceUpdatedEvent struct {
Namespace *Namespace
Doer web.Auth
2021-01-31 20:59:03 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for NamespaceUpdatedEvent
2021-02-02 18:49:17 +00:00
func (n *NamespaceUpdatedEvent) Name() string {
2021-01-31 20:59:03 +00:00
return "namespace.updated"
}
2021-01-31 21:01:34 +00:00
// NamespaceDeletedEvent represents a NamespaceDeletedEvent event
type NamespaceDeletedEvent struct {
Namespace *Namespace
Doer web.Auth
}
// TopicName defines the name for NamespaceDeletedEvent
2021-02-02 18:49:17 +00:00
func (t *NamespaceDeletedEvent) Name() string {
return "namespace.deleted"
}
2021-01-31 21:01:34 +00:00
/////////////////
// List Events //
/////////////////
2021-02-02 19:14:15 +00:00
// ListCreatedEvent represents an event where a list has been created
2021-01-31 21:01:34 +00:00
type ListCreatedEvent struct {
List *List
Doer web.Auth
2021-01-31 21:01:34 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for ListCreatedEvent
2021-02-02 18:49:17 +00:00
func (l *ListCreatedEvent) Name() string {
2021-01-31 21:01:34 +00:00
return "list.created"
}
2021-01-31 21:03:33 +00:00
2021-02-02 19:14:15 +00:00
// ListUpdatedEvent represents an event where a list has been updated
2021-01-31 21:03:33 +00:00
type ListUpdatedEvent struct {
List *List
Doer web.Auth
2021-01-31 21:03:33 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for ListUpdatedEvent
2021-02-02 18:49:17 +00:00
func (l *ListUpdatedEvent) Name() string {
2021-01-31 21:03:33 +00:00
return "list.updated"
}
2021-01-31 21:06:23 +00:00
2021-02-02 19:14:15 +00:00
// ListDeletedEvent represents an event where a list has been deleted
type ListDeletedEvent struct {
List *List
Doer web.Auth
}
2021-02-02 19:14:15 +00:00
// Name defines the name for ListDeletedEvent
2021-02-02 18:49:17 +00:00
func (t *ListDeletedEvent) Name() string {
return "list.deleted"
}
2021-01-31 21:06:23 +00:00
////////////////////
// Sharing Events //
////////////////////
2021-02-02 19:14:15 +00:00
// ListSharedWithUserEvent represents an event where a list has been shared with a user
2021-01-31 21:06:23 +00:00
type ListSharedWithUserEvent struct {
List *List
User *user.User
Doer web.Auth
2021-01-31 21:06:23 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for ListSharedWithUserEvent
2021-02-02 18:49:17 +00:00
func (l *ListSharedWithUserEvent) Name() string {
2021-01-31 21:06:23 +00:00
return "list.shared.user"
}
2021-01-31 21:08:43 +00:00
2021-02-02 19:14:15 +00:00
// ListSharedWithTeamEvent represents an event where a list has been shared with a team
2021-01-31 21:08:43 +00:00
type ListSharedWithTeamEvent struct {
List *List
Team *Team
Doer web.Auth
2021-01-31 21:08:43 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for ListSharedWithTeamEvent
2021-02-02 18:49:17 +00:00
func (l *ListSharedWithTeamEvent) Name() string {
2021-01-31 21:08:43 +00:00
return "list.shared.team"
}
2021-01-31 21:20:25 +00:00
2021-02-02 19:14:15 +00:00
// NamespaceSharedWithUserEvent represents an event where a namespace has been shared with a user
2021-01-31 21:20:25 +00:00
type NamespaceSharedWithUserEvent struct {
Namespace *Namespace
User *user.User
Doer web.Auth
2021-01-31 21:20:25 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for NamespaceSharedWithUserEvent
2021-02-02 18:49:17 +00:00
func (n *NamespaceSharedWithUserEvent) Name() string {
2021-01-31 21:20:25 +00:00
return "namespace.shared.user"
}
2021-02-02 19:14:15 +00:00
// NamespaceSharedWithTeamEvent represents an event where a namespace has been shared with a team
2021-01-31 21:20:25 +00:00
type NamespaceSharedWithTeamEvent struct {
Namespace *Namespace
Team *Team
Doer web.Auth
2021-01-31 21:20:25 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for NamespaceSharedWithTeamEvent
2021-02-02 18:49:17 +00:00
func (n *NamespaceSharedWithTeamEvent) Name() string {
2021-01-31 21:20:25 +00:00
return "namespace.shared.team"
}
2021-01-31 21:23:58 +00:00
/////////////////
// Team Events //
/////////////////
2021-02-02 19:14:15 +00:00
// TeamMemberAddedEvent defines an event where a user is added to a team
2021-01-31 21:23:58 +00:00
type TeamMemberAddedEvent struct {
Team *Team
Member *user.User
Doer web.Auth
2021-01-31 21:23:58 +00:00
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TeamMemberAddedEvent
2021-02-02 18:49:17 +00:00
func (t *TeamMemberAddedEvent) Name() string {
2021-01-31 21:23:58 +00:00
return "team.member.added"
}
// TeamCreatedEvent represents a TeamCreatedEvent event
type TeamCreatedEvent struct {
Team *Team
Doer web.Auth
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TeamCreatedEvent
2021-02-02 18:49:17 +00:00
func (t *TeamCreatedEvent) Name() string {
return "team.created"
}
// TeamDeletedEvent represents a TeamDeletedEvent event
type TeamDeletedEvent struct {
Team *Team
Doer web.Auth
}
2021-02-02 19:14:15 +00:00
// Name defines the name for TeamDeletedEvent
2021-02-02 18:49:17 +00:00
func (t *TeamDeletedEvent) Name() string {
return "team.deleted"
}