getExpiredKeys method
Streams all keys that have expired. The returned Future
completes once the backend has accepted the request (surfacing
any setup failure eagerly); the Stream then yields the keys.
Implementation
@override
Future<Stream<String>> getExpiredKeys() async {
final now = DateTime.now().toUtc().millisecondsSinceEpoch;
final maxTtlMillis = AtNotification.maxTtl.inMilliseconds;
final rows = _db.raw.select(
"SELECT id FROM notifications WHERE status = 'expired' "
'OR (expires_at IS NOT NULL AND expires_at <= ?) '
'OR notification_datetime <= ?;',
[now, now - maxTtlMillis]);
return Stream.fromIterable(rows.map((r) => r['id'] as String));
}