Skip to content

feat: webhook notifications for new devices and critical risks (#78) - #84

Merged
reloadfast merged 2 commits into
mainfrom
feat/webhook-notifications-78
Mar 1, 2026
Merged

reloadfast merged 2 commits into
mainfrom
feat/webhook-notifications-78

Conversation

@reloadfast

Copy link
Copy Markdown
Owner

Summary

Closes #78

Adds webhook notification support so NetworkCrawler can push alerts to ntfy.sh, Gotify, Home Assistant, Slack, Discord, or any HTTP endpoint.

Changes

Backend

  • app/models/settings.py: New AppSetting key-value ORM model (app_settings table)
  • app/notifications.py: get/set_webhook_url(), send_webhook(), notify_scan_complete()
  • app/scan_runner.py: _persist_result returns new device IDs; notify_scan_complete called after each scan
  • app/db.py: Registers app.models.settings in init_db()
  • app/api/__init__.py: GET /api/settings, PATCH /api/settings, POST /api/settings/webhook/test

Frontend

  • SettingsPage.tsx: Webhook URL input, Save + Test buttons with inline success/error feedback

Tests

  • tests/test_notifications.py: 7 unit tests (send_webhook success/failure, notify_scan_complete skip/fire conditions)

Webhook payload

{
  "event": "scan_complete",
  "scan_id": 42,
  "summary": "1 new device(s) detected",
  "new_devices": [{"ip": "...", "hostname": "...", "mac": "...", "vendor": "..."}],
  "risk_counts": {"critical": 0, "high": 2},
  "title": "NetworkCrawler Alert",
  "message": "1 new device(s) detected"
}

Compatible with ntfy.sh (use topic URL directly), Gotify, and any JSON webhook endpoint.

reloadfast and others added 2 commits March 1, 2026 12:24
- Add AppSetting key-value model (app_settings table)
- Add notifications.py: get/set webhook URL, send_webhook, notify_scan_complete
- Scan runner: _persist_result returns new device IDs; notify after each scan
- API: GET/PATCH /api/settings, POST /api/settings/webhook/test
- Settings UI: webhook URL field, Save and Test buttons with inline feedback
- Tests: 7 unit tests covering send_webhook and notify_scan_complete

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@reloadfast
reloadfast merged commit 26c0a7e into main Mar 1, 2026
7 checks passed
@reloadfast
reloadfast deleted the feat/webhook-notifications-78 branch March 1, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webhook notifications: alert on new device or critical risk via HTTP POST (ntfy.sh / Gotify / Discord)

1 participant