feat(notifications): add Test button for ntfy and RSS with inline result

- POST /api/notifications/test/ntfy — sends a real push using current form
  values (not saved settings) so auth can be verified before saving; returns
  status + HTTP detail on success or error message on failure
- POST /api/notifications/test/rss — confirms the feed token exists and
  returns event count; no bill FK required
- NtfyTestRequest + NotificationTestResult schemas added
- Frontend: Test button next to Save on both ntfy and RSS sections; result
  shown inline as a green/red pill; uses current form state for ntfy so
  the user can test before committing

All future notification types should follow the same test-before-save pattern.

Authored-By: Jack Levy
This commit is contained in:
Jack Levy
2026-03-01 12:10:10 -05:00
parent 2e2fefb795
commit 50399adf44
4 changed files with 231 additions and 46 deletions

View File

@@ -165,6 +165,12 @@ export interface AnalysisStats {
remaining: number;
}
export interface NotificationTestResult {
status: "ok" | "error";
detail: string;
event_count?: number;
}
// Notifications
export const notificationsAPI = {
getSettings: () =>
@@ -173,6 +179,16 @@ export const notificationsAPI = {
apiClient.put<NotificationSettings>("/api/notifications/settings", data).then((r) => r.data),
resetRssToken: () =>
apiClient.post<NotificationSettings>("/api/notifications/settings/rss-reset").then((r) => r.data),
testNtfy: (data: {
ntfy_topic_url: string;
ntfy_auth_method: string;
ntfy_token: string;
ntfy_username: string;
ntfy_password: string;
}) =>
apiClient.post<NotificationTestResult>("/api/notifications/test/ntfy", data).then((r) => r.data),
testRss: () =>
apiClient.post<NotificationTestResult>("/api/notifications/test/rss").then((r) => r.data),
};
// Admin