-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TW-504: config notifications for default push rules #568
base: main
Are you sure you want to change the base?
Changes from 2 commits
26219e3
7ad282d
176cd8f
efa5402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,28 +22,23 @@ class NotificationSettingsItem { | |
), | ||
NotificationSettingsItem( | ||
PushRuleKind.override, | ||
'.m.rule.contains_display_name', | ||
(c) => L10n.of(c)!.containsDisplayName, | ||
), | ||
NotificationSettingsItem( | ||
PushRuleKind.content, | ||
'.m.rule.contains_user_name', | ||
(c) => L10n.of(c)!.containsUserName, | ||
'm.rule.invite_for_me', | ||
(c) => L10n.of(c)!.inviteForMe, | ||
), | ||
NotificationSettingsItem( | ||
PushRuleKind.override, | ||
'.m.rule.invite_for_me', | ||
(c) => L10n.of(c)!.inviteForMe, | ||
'.m.rule.suppress_notices', | ||
(c) => L10n.of(c)!.botMessages, | ||
), | ||
NotificationSettingsItem( | ||
PushRuleKind.override, | ||
'.m.rule.member_event', | ||
(c) => L10n.of(c)!.memberChanges, | ||
'm.rule.change_group_name', | ||
(c) => "Group chat name change", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l10n |
||
), | ||
NotificationSettingsItem( | ||
PushRuleKind.override, | ||
'.m.rule.suppress_notices', | ||
(c) => L10n.of(c)!.botMessages, | ||
'm.rule.change_avatar_group', | ||
(c) => "Group chat avatar change", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l10n |
||
), | ||
]; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:matrix/matrix.dart'; | ||
|
||
extension ClientPushRulesExtension on Client { | ||
Future<void> setupUserDefinedPushRule({ | ||
required String ruleId, | ||
List<PushCondition>? conditions, | ||
String? after, | ||
String? before, | ||
}) async { | ||
await setPushRule( | ||
'global', | ||
PushRuleKind.override, | ||
ruleId, | ||
[ | ||
PushRuleAction.notify, | ||
{"set_tweak": "sound", "value": "default"} | ||
], | ||
conditions: conditions, | ||
after: after, | ||
before: before, | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import 'package:fluffychat/domain/model/tom_server_information.dart'; | |
import 'package:fluffychat/domain/repository/tom_configurations_repository.dart'; | ||
import 'package:fluffychat/utils/client_manager.dart'; | ||
import 'package:fluffychat/utils/localized_exception_extension.dart'; | ||
import 'package:fluffychat/utils/matrix_sdk_extensions/client_push_rules_extension.dart'; | ||
import 'package:fluffychat/utils/platform_infos.dart'; | ||
import 'package:fluffychat/utils/uia_request_manager.dart'; | ||
import 'package:fluffychat/utils/url_launcher.dart'; | ||
|
@@ -448,6 +449,77 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver { | |
createVoipPlugin(); | ||
} | ||
|
||
Future<void> _setUpUserDefinedPushRules(Client client) async { | ||
await client.setPushRuleEnabled( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
'global', | ||
PushRuleKind.override, | ||
'.m.rule.invite_for_me', | ||
false, | ||
); | ||
await client.setPushRuleEnabled( | ||
'global', | ||
PushRuleKind.override, | ||
'.m.rule.member_event', | ||
false, | ||
); | ||
|
||
await client.setupUserDefinedPushRule( | ||
ruleId: 'm.rule.invite_for_me', | ||
conditions: [ | ||
PushCondition( | ||
kind: 'event_match', | ||
key: 'type', | ||
pattern: EventTypes.RoomMember, | ||
), | ||
PushCondition( | ||
kind: 'event_match', | ||
key: 'content.membership', | ||
pattern: 'invite', | ||
), | ||
PushCondition( | ||
kind: 'event_match', | ||
key: 'state_key', | ||
pattern: '${client.userID}', | ||
), | ||
], | ||
); | ||
|
||
await client.setupUserDefinedPushRule( | ||
ruleId: 'm.rule.change_group_name', | ||
conditions: [ | ||
PushCondition( | ||
kind: 'event_match', | ||
key: 'type', | ||
pattern: EventTypes.RoomName, | ||
), | ||
], | ||
after: 'm.rule.invite_for_me', | ||
); | ||
|
||
await client.setupUserDefinedPushRule( | ||
ruleId: 'm.rule.change_avatar_group', | ||
conditions: [ | ||
PushCondition( | ||
kind: 'event_match', | ||
key: 'type', | ||
pattern: EventTypes.RoomAvatar, | ||
), | ||
], | ||
after: 'm.rule.invite_for_me', | ||
); | ||
|
||
await client.setupUserDefinedPushRule( | ||
ruleId: 'm.rule.set_me_as_admin', | ||
conditions: [ | ||
PushCondition( | ||
kind: 'event_match', | ||
key: 'type', | ||
pattern: EventTypes.RoomPowerLevels, | ||
), | ||
], | ||
); | ||
} | ||
|
||
void createVoipPlugin() async { | ||
if (await store.getItemBool(SettingKeys.experimentalVoip) == false) { | ||
voipPlugin = null; | ||
|
@@ -501,6 +573,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver { | |
if (homeServer != null) { | ||
_setUpHomeServer(homeServer.baseUrl); | ||
} | ||
|
||
_storeToMConfiguration(client, tomServer, identityServer); | ||
setUpAuthorization(client); | ||
} | ||
|
@@ -522,14 +595,15 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver { | |
} | ||
} | ||
|
||
void _setUpHomeServer(Uri homeServerUri) { | ||
void _setUpHomeServer(Uri homeServerUri) async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need |
||
final homeServerUrlInterceptor = getIt.get<DynamicUrlInterceptors>( | ||
instanceName: NetworkDI.homeServerUrlInterceptorName, | ||
); | ||
Logs().d( | ||
'MatrixState::_setUpHomeServer: ${homeServerUrlInterceptor.baseUrl}', | ||
); | ||
homeServerUrlInterceptor.changeBaseUrl(homeServerUri.toString()); | ||
_setUpUserDefinedPushRules(client); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make sure to call it one time in login? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure this will not make conflict with other setup in other device? |
||
} | ||
|
||
void _setUpIdentityServer(IdentityServerInformation identityServer) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please show demo for new settings