fix: add push rule to block notifications for analytics room invites (#5190)
This commit is contained in:
parent
8ce368922b
commit
8c2cd7d022
4 changed files with 42 additions and 1 deletions
|
|
@ -76,6 +76,14 @@ extension AnalyticsClientExtension on Client {
|
|||
topic: "This room stores learning analytics for $userID.",
|
||||
preset: CreateRoomPreset.publicChat,
|
||||
visibility: Visibility.private,
|
||||
initialState: [
|
||||
StateEvent(
|
||||
type: EventTypes.RoomJoinRules,
|
||||
content: {
|
||||
ModelKey.joinRule: JoinRules.knock.name,
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
if (getRoomById(roomID) == null) {
|
||||
// Wait for room actually appears in sync
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ class PangeaEventTypes {
|
|||
|
||||
static const String report = 'm.report';
|
||||
static const textToSpeechRule = "p.rule.text_to_speech";
|
||||
static const analyticsInviteRule = "p.rule.analytics_invite";
|
||||
static const analyticsInviteContent = "p.analytics_request";
|
||||
|
||||
/// A request to the server to generate activities
|
||||
static const activityRequest = "pangea.activity_req";
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import 'package:fluffychat/config/app_config.dart';
|
|||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/client_analytics_extension.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/space_analytics/space_analytics_requested_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
|
||||
|
|
@ -91,7 +92,14 @@ class AnalyticsRequestIndicatorState extends State<AnalyticsRequestIndicator> {
|
|||
final rooms = entry.value;
|
||||
|
||||
final List<Future> futures = rooms
|
||||
.map((room) => resp ? room.invite(user.id) : room.kick(user.id))
|
||||
.map(
|
||||
(room) => resp
|
||||
? room.invite(
|
||||
user.id,
|
||||
reason: PangeaEventTypes.analyticsInviteContent,
|
||||
)
|
||||
: room.kick(user.id),
|
||||
)
|
||||
.toList();
|
||||
|
||||
await Future.wait(futures);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,29 @@ extension PangeaPushRulesExtension on Client {
|
|||
}
|
||||
}
|
||||
|
||||
if (!(globalPushRules?.override?.any(
|
||||
(element) => element.ruleId == PangeaEventTypes.analyticsInviteRule,
|
||||
) ??
|
||||
false)) {
|
||||
await setPushRule(
|
||||
PushRuleKind.override,
|
||||
PangeaEventTypes.analyticsInviteRule,
|
||||
[PushRuleAction.dontNotify],
|
||||
conditions: [
|
||||
PushCondition(
|
||||
kind: 'event_match',
|
||||
key: 'type',
|
||||
pattern: EventTypes.RoomMember,
|
||||
),
|
||||
PushCondition(
|
||||
kind: 'event_match',
|
||||
key: 'content.reason',
|
||||
pattern: PangeaEventTypes.analyticsInviteContent,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
if (!(globalPushRules?.override?.any(
|
||||
(element) => element.ruleId == PangeaEventTypes.textToSpeechRule,
|
||||
) ??
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue