added guardian letters with chat and multiple answer functionalities
This commit is contained in:
@@ -12,6 +12,7 @@ import 'nid_store.dart';
|
||||
import 'push_actions.dart';
|
||||
import 'push_avatar.dart';
|
||||
import 'push_subject.dart';
|
||||
import 'push_target.dart';
|
||||
|
||||
/// Renders decrypted push subjects (and plaintext Connect pushes) as local
|
||||
/// notifications. Talk messages of one chat stack into a SINGLE
|
||||
@@ -23,6 +24,8 @@ class PushRenderer {
|
||||
static const talkChannelName = 'Talk-Nachrichten';
|
||||
static const generalChannelId = 'nextcloud_general';
|
||||
static const generalChannelName = 'Benachrichtigungen';
|
||||
static const parentLettersChannelId = 'parent_letters';
|
||||
static const parentLettersChannelName = 'Elternbriefe';
|
||||
|
||||
static const String iosTalkCategory = 'TALK_MESSAGE';
|
||||
|
||||
@@ -67,6 +70,14 @@ class PushRenderer {
|
||||
description: 'Allgemeine Benachrichtigungen',
|
||||
),
|
||||
);
|
||||
await android.createNotificationChannel(
|
||||
const AndroidNotificationChannel(
|
||||
parentLettersChannelId,
|
||||
parentLettersChannelName,
|
||||
description: 'Neue Elternbriefe und Antworten der Schule',
|
||||
importance: Importance.high,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Renders a decrypted Nextcloud push subject.
|
||||
@@ -350,23 +361,35 @@ class PushRenderer {
|
||||
required String body,
|
||||
Map<String, String>? data,
|
||||
}) async {
|
||||
final id = _fallbackId('$title$body');
|
||||
const androidDetails = AndroidNotificationDetails(
|
||||
generalChannelId,
|
||||
generalChannelName,
|
||||
final parentLetterId = data?[parentLetterIdKey];
|
||||
final isParentLetter =
|
||||
data?['type'] == parentLetterPushType &&
|
||||
parentLetterId != null &&
|
||||
parentLetterId.isNotEmpty;
|
||||
// One notification per letter: a reply replaces the letter's earlier one.
|
||||
final id = isParentLetter
|
||||
? parentLetterNotificationId(parentLetterId)
|
||||
: _fallbackId('$title$body');
|
||||
final androidDetails = AndroidNotificationDetails(
|
||||
isParentLetter ? parentLettersChannelId : generalChannelId,
|
||||
isParentLetter ? parentLettersChannelName : generalChannelName,
|
||||
importance: Importance.high,
|
||||
priority: Priority.high,
|
||||
color: _accentColor,
|
||||
styleInformation: isParentLetter ? BigTextStyleInformation(body) : null,
|
||||
);
|
||||
await _plugin.show(
|
||||
id: id,
|
||||
title: title,
|
||||
body: body,
|
||||
notificationDetails: const NotificationDetails(android: androidDetails),
|
||||
notificationDetails: NotificationDetails(android: androidDetails),
|
||||
payload: data == null ? null : jsonEncode(data),
|
||||
);
|
||||
}
|
||||
|
||||
static int parentLetterNotificationId(String letterId) =>
|
||||
stableChatNotificationId('parent-letter:$letterId');
|
||||
|
||||
String _payload({required String? chatToken, required int nid}) =>
|
||||
jsonEncode({'chatToken': ?chatToken, 'nid': nid});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user