8081d98c67
Initial public release. Anonymous on-device identity (no phone number, e-mail, or password), Signal-protocol cryptography (X3DH + PQXDH, Double Ratchet, sealed sender) via libsignal, a metadata-minimizing relay, group chats, disappearing messages, encrypted local storage, optional Tor transport, and a UI localized into Czech, English, German, Russian, and Italian. Monorepo: Flutter client (app/), Rust relay + wire types (rust/), protobuf definitions (proto/), self-host deploy (deploy/). Licensed under AGPL-3.0 with an app-store distribution exception (§7).
91 lines
3.2 KiB
Dart
91 lines
3.2 KiB
Dart
/// Lokální notifikace pro push budíčky.
|
|
///
|
|
/// Zásada: notifikace NIKDY nenese obsah, odesílatele ani počet zpráv —
|
|
/// při killed-state budíčku je DB zamčená (PIN → Argon2id), takže ani
|
|
/// technicky NELZE nic dešifrovat. Generické „máš nové zprávy" je tudíž
|
|
/// jediná poctivá (a metadata-čistá) možnost — stejný model jako
|
|
/// zamčený Threema/Signal.
|
|
library;
|
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
import 'package:sepot/core/l10n/l10n.dart';
|
|
import 'package:sepot/providers/locale_provider.dart';
|
|
|
|
class PushNotifier {
|
|
PushNotifier._();
|
|
|
|
static final _plugin = FlutterLocalNotificationsPlugin();
|
|
static bool _ready = false;
|
|
|
|
/// Jedno pevné id — opakované budíčky aktualizují touž notifikaci,
|
|
/// žádné hromadění (počet by sám o sobě byl metadata leak).
|
|
static const int _notificationId = 1;
|
|
|
|
static Future<void> _ensureInit() async {
|
|
if (_ready) return;
|
|
final l10n = l10nFor(await LocaleNotifier.readStored());
|
|
await _plugin.initialize(
|
|
InitializationSettings(
|
|
android: const AndroidInitializationSettings('@mipmap/ic_launcher'),
|
|
linux: LinuxInitializationSettings(
|
|
defaultActionName: l10n.pushActionOpen,
|
|
),
|
|
),
|
|
);
|
|
_ready = true;
|
|
}
|
|
|
|
/// Sdílené detaily notifikace — channel ID 'zpravy' je NEMĚNNÉ
|
|
/// (Android by při změně vytvořil nový kanál), name/description se
|
|
/// lokalizují (systém je čte při vytvoření kanálu).
|
|
static NotificationDetails _details(AppLocalizations l10n) {
|
|
return NotificationDetails(
|
|
android: AndroidNotificationDetails(
|
|
'zpravy',
|
|
l10n.pushChannelMessagesName,
|
|
channelDescription: l10n.pushChannelMessagesDescription,
|
|
importance: Importance.high,
|
|
priority: Priority.high,
|
|
category: AndroidNotificationCategory.message,
|
|
),
|
|
linux: const LinuxNotificationDetails(),
|
|
);
|
|
}
|
|
|
|
/// Android 13+ runtime permission — volat při zapnutí pushe v nastavení.
|
|
static Future<void> requestPermission() async {
|
|
await _ensureInit();
|
|
await _plugin
|
|
.resolvePlatformSpecificImplementation<
|
|
AndroidFlutterLocalNotificationsPlugin>()
|
|
?.requestNotificationsPermission();
|
|
}
|
|
|
|
/// Notifikace o přijaté zprávě, když appka běží, ale není v popředí.
|
|
/// Jen jméno odesílatele — obsah zprávy do notifikace NIKDY (šifrovaný
|
|
/// obsah nepatří do notification logu OS ani na zamčenou obrazovku).
|
|
static Future<void> showMessageNotification(String senderName) async {
|
|
await _ensureInit();
|
|
final l10n = l10nFor(await LocaleNotifier.readStored());
|
|
await _plugin.show(
|
|
_notificationId,
|
|
l10n.commonAppName,
|
|
l10n.pushNewMessageFrom(senderName),
|
|
_details(l10n),
|
|
);
|
|
}
|
|
|
|
/// Generická notifikace bez obsahu. Klepnutí otevře appku (unlock →
|
|
/// WS připojení → fronta se vyleje normální cestou).
|
|
static Future<void> showWakeNotification() async {
|
|
await _ensureInit();
|
|
final l10n = l10nFor(await LocaleNotifier.readStored());
|
|
await _plugin.show(
|
|
_notificationId,
|
|
l10n.commonAppName,
|
|
l10n.pushNewMessages,
|
|
_details(l10n),
|
|
);
|
|
}
|
|
}
|