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

@@ -28,6 +28,20 @@ class NotificationSettingsUpdate(BaseModel):
ntfy_enabled: Optional[bool] = None
rss_enabled: Optional[bool] = None
class NtfyTestRequest(BaseModel):
ntfy_topic_url: str
ntfy_auth_method: str = "none"
ntfy_token: str = ""
ntfy_username: str = ""
ntfy_password: str = ""
class NotificationTestResult(BaseModel):
status: str # "ok" | "error"
detail: str
event_count: Optional[int] = None # RSS only
T = TypeVar("T")