-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: Add notification support #1381
base: main
Are you sure you want to change the base?
Changes from all commits
b779129
0e0dcd4
6f411ed
a53e05f
1a3f16b
be5165a
c558af0
d78bc8f
175d91e
b44d815
d23958b
b60b273
dc23da3
aea53a6
781583c
01bf021
8dedd8a
36e1b78
502d280
76de2b6
87bdc5e
4f47715
6785dc4
e6760bc
05a47ea
c980fa1
c8a1734
3e048ca
b9dc26c
56afb8e
7316f88
79b60e4
082b224
81d27a6
a7a7b96
1a5ed72
98d73f9
66bb7c2
c5022f6
08ab490
9ef6757
e5c542b
5ad757f
04c8411
50ef770
8334aeb
0ba1cdc
e784377
fbb02d0
c4e1394
b4e5120
ef13134
fe406a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddNotificationSettings1727693832830 | ||
implements MigrationInterface | ||
{ | ||
name = 'AddNotificationSettings1727693832830'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// Create notification table | ||
await queryRunner.query(` | ||
CREATE TABLE "notification" ( | ||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
"name" VARCHAR NOT NULL, | ||
"agent" VARCHAR NOT NULL, | ||
"enabled" BOOLEAN DEFAULT false, | ||
"types" TEXT, | ||
"options" TEXT NOT NULL | ||
); | ||
`); | ||
|
||
// Create notification_rulegroup table with foreign key constraints directly | ||
await queryRunner.query(` | ||
CREATE TABLE "notification_rulegroup" ( | ||
"notificationId" INTEGER NOT NULL, | ||
"rulegroupId" INTEGER NOT NULL, | ||
PRIMARY KEY ("notificationId", "rulegroupId"), | ||
FOREIGN KEY ("notificationId") REFERENCES "notification"("id") ON DELETE CASCADE, | ||
FOREIGN KEY ("rulegroupId") REFERENCES "rule_group"("id") ON DELETE CASCADE | ||
); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
// Drop the tables in reverse order | ||
await queryRunner.query(`DROP TABLE "notification_rulegroup"`); | ||
await queryRunner.query(`DROP TABLE "notification"`); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class NotificationSettingsAboutScale1732008945000 | ||
implements MigrationInterface | ||
{ | ||
name = 'NotificationSettingsAboutScale1732008945000'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "notification" ADD COLUMN "aboutScale" INTEGER NOT NULL DEFAULT 3; | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "notification" DROP COLUMN "aboutScale"; | ||
`); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Notification } from '../entities/notification.entities'; | ||
import { | ||
NotificationAgentConfig, | ||
NotificationAgentKey, | ||
NotificationType, | ||
} from '../notifications-interfaces'; | ||
|
||
export interface NotificationPayload { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to include some metadata in this payload where relevant, such as the collection name, and/or the media item name. The webhook agent only has access to the subject and message which isn't super useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's worth an exploration, i'll look into it. |
||
event?: string; | ||
subject: string; | ||
notifySystem: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with this and the leftover conditions |
||
image?: string; | ||
message?: string; | ||
extra?: { name: string; value: string }[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a leftover from overseerr as I can't see it being used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, also something that still needs cleaning up |
||
} | ||
|
||
export interface NotificationAgent { | ||
notification: Notification; | ||
shouldSend(): boolean; | ||
send(type: NotificationType, payload: NotificationPayload): Promise<boolean>; | ||
getIdentifier(): NotificationAgentKey; | ||
getSettings(): NotificationAgentConfig; | ||
getNotification(): Notification; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I brought up in Discord here about a possible handleMedia improvement. We may want to notify on individual media handling failures at some point once we've figured out what to do there.