mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(notifications): add Pushover (#598)
* feat(notifications): add pushover * add db migration * fix lint error * some small corrections * fixed README * added missing columns to postgres_migrate.go * use token for user_key * refactor(notifications): change priority to int * fix: only test selected events --------- Co-authored-by: soup <soup@r4tio.dev> Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
1b8f2fce3c
commit
da5492febb
12 changed files with 290 additions and 37 deletions
|
@ -386,6 +386,10 @@ export const NotificationTypeOptions: OptionBasicTyped<NotificationType>[] = [
|
|||
{
|
||||
label: "Telegram",
|
||||
value: "TELEGRAM"
|
||||
},
|
||||
{
|
||||
label: "Pushover",
|
||||
value: "PUSHOVER"
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import Select, { components, ControlProps, InputProps, MenuProps, OptionProps }
|
|||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
import { PasswordFieldWide, SwitchGroupWide, TextFieldWide } from "@components/inputs";
|
||||
import { NumberFieldWide, PasswordFieldWide, SwitchGroupWide, TextFieldWide } from "@components/inputs";
|
||||
import DEBUG from "@components/debug";
|
||||
import { EventOptions, NotificationTypeOptions, SelectOption } from "@domain/constants";
|
||||
import { APIClient } from "@api/APIClient";
|
||||
|
@ -120,10 +120,41 @@ function FormFieldsTelegram() {
|
|||
);
|
||||
}
|
||||
|
||||
function FormFieldsPushover() {
|
||||
return (
|
||||
<div className="border-t border-gray-200 dark:border-gray-700 py-4">
|
||||
<div className="px-4 space-y-1">
|
||||
<Dialog.Title className="text-lg font-medium text-gray-900 dark:text-white">Settings</Dialog.Title>
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400">
|
||||
Register a new <a href="https://support.pushover.net/i175-how-do-i-get-an-api-or-application-token" rel="noopener noreferrer" target="_blank" className="font-medium text-blue-500 underline underline-offset-1 hover:text-blue-400">application</a> and add its API Token here.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<PasswordFieldWide
|
||||
name="api_key"
|
||||
label="API Token"
|
||||
help="API Token"
|
||||
/>
|
||||
<PasswordFieldWide
|
||||
name="token"
|
||||
label="User Key"
|
||||
help="User Key"
|
||||
/>
|
||||
<NumberFieldWide
|
||||
name="priority"
|
||||
label="Priority"
|
||||
help="-2, -1, 0 (default), 1, or 2"
|
||||
required={true}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const componentMap: componentMapType = {
|
||||
DISCORD: <FormFieldsDiscord />,
|
||||
NOTIFIARR: <FormFieldsNotifiarr />,
|
||||
TELEGRAM: <FormFieldsTelegram />
|
||||
TELEGRAM: <FormFieldsTelegram />,
|
||||
PUSHOVER: <FormFieldsPushover />
|
||||
};
|
||||
|
||||
interface NotificationAddFormValues {
|
||||
|
@ -398,6 +429,7 @@ interface InitialValues {
|
|||
webhook?: string;
|
||||
token?: string;
|
||||
api_key?: string;
|
||||
priority?: number;
|
||||
channel?: string;
|
||||
events: NotificationEvent[];
|
||||
}
|
||||
|
@ -445,6 +477,7 @@ export function NotificationUpdateForm({ isOpen, toggle, notification }: UpdateP
|
|||
webhook: notification.webhook,
|
||||
token: notification.token,
|
||||
api_key: notification.api_key,
|
||||
priority: notification.priority,
|
||||
channel: notification.channel,
|
||||
events: notification.events || []
|
||||
};
|
||||
|
@ -529,4 +562,4 @@ export function NotificationUpdateForm({ isOpen, toggle, notification }: UpdateP
|
|||
)}
|
||||
</SlideOver>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -85,11 +85,19 @@ const TelegramIcon = () => (
|
|||
</svg>
|
||||
);
|
||||
|
||||
const PushoverIcon = () => (
|
||||
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" className="mr-2 h-4">
|
||||
<path d="m495.6 319.4 104-13.7-101.3 228.6c17.8-1.4 35.2-7.4 52.3-18.1 17.1-10.7 32.9-24.2 47.2-40.4 14.4-16.2 26.8-34.2 37.3-54.1 10.5-19.8 18-39.4 22.6-58.5 2.7-11.9 4-23.3 3.8-34.2-.2-10.9-3.1-20.5-8.6-28.7s-13.8-14.8-25-19.8-26.3-7.5-45.5-7.5c-22.4 0-44.4 3.6-66 10.9-21.7 7.3-41.7 17.9-60.2 31.8-18.5 13.9-34.5 31.2-48.2 52-13.7 20.8-23.5 44.4-29.4 70.8-2.3 8.7-3.6 15.6-4.1 20.9-.5 5.3-.6 9.6-.3 13 .2 3.4.7 6.1 1.4 7.9.7 1.8 1.3 3.6 1.7 5.5-23.3 0-40.3-4.7-51-14-10.7-9.3-13.3-25.7-7.9-48.9 5.5-24.2 17.9-47.2 37.3-69.1 19.4-21.9 42.4-41.2 69.1-57.8 26.7-16.6 55.9-29.9 87.6-39.7 31.7-9.8 62.6-14.7 92.7-14.7 26.5 0 48.7 3.8 66.7 11.3 18 7.5 32.1 17.5 42.1 29.8s16.3 26.7 18.8 43.1c2.5 16.4 1.7 33.5-2.4 51.3-5 21.4-14.5 43-28.4 64.7-13.9 21.7-31.4 41.3-52.3 58.8-21 17.6-45 31.8-72.2 42.8-27.1 10.9-56 16.4-86.6 16.4h-3.4l-86.9 195H302l193.6-435.4z"
|
||||
clipRule="evenodd" fill="currentColor" fillRule="evenodd"/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
|
||||
const iconComponentMap: componentMapType = {
|
||||
DISCORD: <span className="flex items-center px-2 py-0.5 rounded bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-400"><DiscordIcon /> Discord</span>,
|
||||
NOTIFIARR: <span className="flex items-center px-2 py-0.5 rounded bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-400"><DiscordIcon /> Notifiarr</span>,
|
||||
TELEGRAM: <span className="flex items-center px-2 py-0.5 rounded bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-400"><TelegramIcon /> Telegram</span>
|
||||
TELEGRAM: <span className="flex items-center px-2 py-0.5 rounded bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-400"><TelegramIcon /> Telegram</span>,
|
||||
PUSHOVER: <span className="flex items-center px-2 py-0.5 rounded bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-400"><PushoverIcon /> Pushover</span>
|
||||
};
|
||||
|
||||
interface ListItemProps {
|
||||
|
@ -151,4 +159,4 @@ function ListItem({ notification }: ListItemProps) {
|
|||
);
|
||||
}
|
||||
|
||||
export default NotificationSettings;
|
||||
export default NotificationSettings;
|
||||
|
|
5
web/src/types/Notification.d.ts
vendored
5
web/src/types/Notification.d.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
type NotificationType = "DISCORD" | "NOTIFIARR" | "TELEGRAM";
|
||||
type NotificationType = "DISCORD" | "NOTIFIARR" | "TELEGRAM" | "PUSHOVER";
|
||||
type NotificationEvent = "PUSH_APPROVED" | "PUSH_REJECTED" | "PUSH_ERROR" | "IRC_DISCONNECTED" | "IRC_RECONNECTED" | "APP_UPDATE_AVAILABLE";
|
||||
|
||||
interface Notification {
|
||||
|
@ -11,4 +11,5 @@ interface Notification {
|
|||
token?: string;
|
||||
api_key?: string;
|
||||
channel?: string;
|
||||
}
|
||||
priority?: number;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue