-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
notification.go
111 lines (99 loc) · 3.81 KB
/
notification.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (c) 2021 - 2024, Ludvig Lundgren and the autobrr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later
package domain
import (
"context"
"time"
)
type NotificationRepo interface {
List(ctx context.Context) ([]Notification, error)
Find(ctx context.Context, params NotificationQueryParams) ([]Notification, int, error)
FindByID(ctx context.Context, id int) (*Notification, error)
Store(ctx context.Context, notification Notification) (*Notification, error)
Update(ctx context.Context, notification Notification) (*Notification, error)
Delete(ctx context.Context, notificationID int) error
}
type NotificationSender interface {
Send(event NotificationEvent, payload NotificationPayload) error
CanSend(event NotificationEvent) bool
}
type Notification struct {
ID int `json:"id"`
Name string `json:"name"`
Type NotificationType `json:"type"`
Enabled bool `json:"enabled"`
Events []string `json:"events"`
Token string `json:"token"`
APIKey string `json:"api_key"`
Webhook string `json:"webhook"`
Title string `json:"title"`
Icon string `json:"icon"`
Username string `json:"username"`
Host string `json:"host"`
Password string `json:"password"`
Channel string `json:"channel"`
Rooms string `json:"rooms"`
Targets string `json:"targets"`
Devices string `json:"devices"`
Priority int32 `json:"priority"`
Topic string `json:"topic"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type NotificationPayload struct {
Subject string
Message string
Event NotificationEvent
ReleaseName string
Filter string
Indexer string
InfoHash string
Size uint64
Status ReleasePushStatus
Action string
ActionType ActionType
ActionClient string
Rejections []string
Protocol ReleaseProtocol // torrent, usenet
Implementation ReleaseImplementation // irc, rss, api
Timestamp time.Time
}
type NotificationType string
const (
NotificationTypeDiscord NotificationType = "DISCORD"
NotificationTypeNotifiarr NotificationType = "NOTIFIARR"
NotificationTypeIFTTT NotificationType = "IFTTT"
NotificationTypeJoin NotificationType = "JOIN"
NotificationTypeMattermost NotificationType = "MATTERMOST"
NotificationTypeMatrix NotificationType = "MATRIX"
NotificationTypePushBullet NotificationType = "PUSH_BULLET"
NotificationTypePushover NotificationType = "PUSHOVER"
NotificationTypeRocketChat NotificationType = "ROCKETCHAT"
NotificationTypeSlack NotificationType = "SLACK"
NotificationTypeTelegram NotificationType = "TELEGRAM"
NotificationTypeGotify NotificationType = "GOTIFY"
NotificationTypeNtfy NotificationType = "NTFY"
NotificationTypeLunaSea NotificationType = "LUNASEA"
NotificationTypeShoutrrr NotificationType = "SHOUTRRR"
)
type NotificationEvent string
const (
NotificationEventAppUpdateAvailable NotificationEvent = "APP_UPDATE_AVAILABLE"
NotificationEventPushApproved NotificationEvent = "PUSH_APPROVED"
NotificationEventPushRejected NotificationEvent = "PUSH_REJECTED"
NotificationEventPushError NotificationEvent = "PUSH_ERROR"
NotificationEventIRCDisconnected NotificationEvent = "IRC_DISCONNECTED"
NotificationEventIRCReconnected NotificationEvent = "IRC_RECONNECTED"
NotificationEventTest NotificationEvent = "TEST"
)
type NotificationEventArr []NotificationEvent
type NotificationQueryParams struct {
Limit uint64
Offset uint64
Sort map[string]string
Filters struct {
Indexers []string
PushStatus string
}
Search string
}