mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Adds POST /api/notifications/test, which delivers a canned test push to every registered device through the existing relay path (not persisted to the notifications list), wired into the router and OpenAPI. In Settings, a "Send test notification" button appears under the push toggle, only when push is enabled on this device, so the full backend -> relay -> FCM -> APNs -> device path can be verified on demand without waiting for a real device event. Backend, API and widget tests added; clippy and dart analyze clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
part of '../oott_api.dart';
|
|
|
|
/// Notification endpoints: listing and read/new state transitions.
|
|
extension NotificationApi on BackendAPI {
|
|
Future<void> markNotificationAsRead(int id) async {
|
|
await _dio.get('/notifications/$id');
|
|
}
|
|
|
|
Future<void> markNotificationAsNew(int id) async {
|
|
await _dio.post('/notifications/$id/mark_as_new');
|
|
}
|
|
|
|
Future<void> markAllNotificationsAsRead() async {
|
|
await _dio.post('/notifications/mark_all_as_old');
|
|
}
|
|
|
|
/// Asks the backend to deliver a one-off test push to every registered device,
|
|
/// used from Settings to verify end-to-end push delivery.
|
|
Future<void> sendTestNotification() async {
|
|
await _dio.post('/notifications/test');
|
|
}
|
|
|
|
Future<({List<Notification> items, int totalCount})> listNotifications(
|
|
bool? isNew, {
|
|
int page = 0,
|
|
int perPage = 5,
|
|
CancelToken? cancelToken,
|
|
}) async {
|
|
final response = await _dio.get(
|
|
'/notifications',
|
|
queryParameters: {
|
|
'is_new': isNew ?? '',
|
|
'page_offset': page * perPage,
|
|
'page_limit': perPage,
|
|
},
|
|
cancelToken: cancelToken,
|
|
);
|
|
|
|
return _paginate(
|
|
response.data as Map<String, dynamic>,
|
|
(item) => Notification.fromJson(item),
|
|
);
|
|
}
|
|
}
|