added push rule to prevent notifications for text-to-speech events
This commit is contained in:
parent
3b3fba9ce5
commit
63f6dcc32d
4 changed files with 40 additions and 1 deletions
|
|
@ -770,6 +770,7 @@ class ChatListController extends State<ChatList>
|
|||
await pangeaController.subscriptionController.initialize();
|
||||
pangeaController.afterSyncAndFirstLoginInitialization(context);
|
||||
await pangeaController.inviteBotToExistingSpaces();
|
||||
await pangeaController.setPangeaPushRules();
|
||||
} else {
|
||||
ErrorHandler.logError(
|
||||
m: "didn't run afterSyncAndFirstLoginInitialization because not mounted",
|
||||
|
|
|
|||
|
|
@ -18,4 +18,5 @@ class PangeaEventTypes {
|
|||
static const botOptions = "pangea.bot_options";
|
||||
|
||||
static const userAge = "pangea.user_age";
|
||||
static const textToSpeechRule = "p.rule.text_to_speech";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:developer';
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:fluffychat/pangea/constants/class_default_values.dart';
|
||||
import 'package:fluffychat/pangea/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/controllers/class_controller.dart';
|
||||
import 'package:fluffychat/pangea/controllers/contextual_definition_controller.dart';
|
||||
import 'package:fluffychat/pangea/controllers/language_controller.dart';
|
||||
|
|
@ -243,4 +244,35 @@ class PangeaController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setPangeaPushRules() async {
|
||||
if (!(matrixState.client.globalPushRules?.override?.any(
|
||||
(element) => element.ruleId == PangeaEventTypes.textToSpeechRule,
|
||||
) ??
|
||||
false)) {
|
||||
await matrixState.client.setPushRule(
|
||||
'global',
|
||||
PushRuleKind.override,
|
||||
PangeaEventTypes.textToSpeechRule,
|
||||
[PushRuleAction.dontNotify],
|
||||
conditions: [
|
||||
PushCondition(
|
||||
kind: 'event_match',
|
||||
key: 'content.msgtype',
|
||||
pattern: MessageTypes.Audio,
|
||||
),
|
||||
PushCondition(
|
||||
kind: 'event_match',
|
||||
key: 'content.transcription.lang_code',
|
||||
pattern: '*',
|
||||
),
|
||||
PushCondition(
|
||||
kind: 'event_match',
|
||||
key: 'content.transcription.text',
|
||||
pattern: '*',
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'dart:convert';
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/utils/any_state_holder.dart';
|
||||
import 'package:fluffychat/utils/client_manager.dart';
|
||||
|
|
@ -372,7 +373,11 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
e.type == EventUpdateType.timeline &&
|
||||
[EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||
.contains(e.content['type']) &&
|
||||
e.content['sender'] != c.userID,
|
||||
e.content['sender'] != c.userID
|
||||
// #Pangea
|
||||
&&
|
||||
!e.content['content']?.containsKey(ModelKey.transcription),
|
||||
// Pangea#,
|
||||
)
|
||||
.listen(showLocalNotification);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue