mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Report delivered device count from the test-notification endpoint
POST /api/notifications/test previously returned a blanket 200 even when there
were no registered devices, so a test that reached nobody looked like a success.
push::send now returns the number of devices the relay confirmed delivery to, and
the endpoint returns it as {"delivered": N}. Settings shows "sent to N device(s)"
on success and an explicit "No devices are registered..." warning when N is 0,
which is the case that previously masqueraded as success.
Backend, API and widget tests updated; clippy and dart analyze clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0075072196
commit
475edcb2cf
@@ -143,12 +143,22 @@ class _SettingsState extends State<Settings> {
|
||||
Future<void> _sendTestNotification() async {
|
||||
setState(() => _testBusy = true);
|
||||
try {
|
||||
await BackendAPI.instance.sendTestNotification();
|
||||
final delivered = await BackendAPI.instance.sendTestNotification();
|
||||
if (!mounted) return;
|
||||
UISnackbars.showSuccess(
|
||||
context,
|
||||
'Test notification sent. It should arrive shortly.',
|
||||
);
|
||||
if (delivered == 0) {
|
||||
// The request succeeded but no device received it — usually the backend
|
||||
// lost this device's token (e.g. after a restart); re-toggle to re-register.
|
||||
UISnackbars.showError(
|
||||
context,
|
||||
'No devices are registered to receive push notifications.',
|
||||
);
|
||||
} else {
|
||||
final devices = delivered == 1 ? 'device' : 'devices';
|
||||
UISnackbars.showSuccess(
|
||||
context,
|
||||
'Test notification sent to $delivered $devices.',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Failed to send test notification: $e');
|
||||
if (!mounted) return;
|
||||
|
||||
Reference in New Issue
Block a user