mirror of
https://github.com/rommapp/romm.git
synced 2026-12-04 21:02:21 +01:00
- Pasting a service's own URL (a Discord webhook's) or an Apprise URL in the channel dialog fills its fields in as soon as it's pasted, or says why it can't. POST /api/notification-channels/apprise-services/parse instantiates the plugin and matches the URL Apprise writes for it against the service's templates, so it works for every service; a new channel moves to the service the URL is for. - A failed delivery's error carries the start of the service's reply after Apprise's warning, so a 400 says why (Discord refuses a bot name containing "discord"). Apprise's log stays out of the server log. - Setup guides link Apprise's wiki instead of appriseit.com. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
1.8 KiB
TypeScript
78 lines
1.8 KiB
TypeScript
import type {
|
|
AppriseChannelCreatePayload,
|
|
AppriseServiceSchema,
|
|
AppriseUrlFieldsSchema,
|
|
EmailChannelCreatePayload,
|
|
NotificationChannelSchema,
|
|
NotificationChannelTestResult,
|
|
NotificationChannelUpdatePayload,
|
|
WebhookChannelCreatePayload,
|
|
} from "@/__generated__";
|
|
import api from "@/services/api";
|
|
|
|
export type NotificationChannelCreatePayload =
|
|
| AppriseChannelCreatePayload
|
|
| WebhookChannelCreatePayload
|
|
| EmailChannelCreatePayload;
|
|
|
|
async function getChannels() {
|
|
return api.get<NotificationChannelSchema[]>("/notification-channels");
|
|
}
|
|
|
|
async function getAppriseServices() {
|
|
return api.get<AppriseServiceSchema[]>(
|
|
"/notification-channels/apprise-services",
|
|
);
|
|
}
|
|
|
|
async function parseAppriseUrl(url: string) {
|
|
return api.post<AppriseUrlFieldsSchema>(
|
|
"/notification-channels/apprise-services/parse",
|
|
{ url },
|
|
);
|
|
}
|
|
|
|
async function create(payload: NotificationChannelCreatePayload) {
|
|
return api.post<NotificationChannelSchema>("/notification-channels", payload);
|
|
}
|
|
|
|
async function update(id: number, payload: NotificationChannelUpdatePayload) {
|
|
return api.patch<NotificationChannelSchema>(
|
|
`/notification-channels/${id}`,
|
|
payload,
|
|
);
|
|
}
|
|
|
|
async function remove(id: number) {
|
|
return api.delete(`/notification-channels/${id}`);
|
|
}
|
|
|
|
async function test(id: number) {
|
|
return api.post<NotificationChannelTestResult>(
|
|
`/notification-channels/${id}/test`,
|
|
);
|
|
}
|
|
|
|
async function confirm(id: number, code: string) {
|
|
return api.post<NotificationChannelSchema>(
|
|
`/notification-channels/${id}/confirm`,
|
|
{ code },
|
|
);
|
|
}
|
|
|
|
async function resendCode(id: number) {
|
|
return api.post(`/notification-channels/${id}/resend-code`);
|
|
}
|
|
|
|
export default {
|
|
getChannels,
|
|
getAppriseServices,
|
|
parseAppriseUrl,
|
|
create,
|
|
update,
|
|
remove,
|
|
test,
|
|
confirm,
|
|
resendCode,
|
|
};
|