Merge pull request #1957 from famedly/krille/do-not-send-deprecated-dont-notify-actions
refactor: Do not set the deprecated dont_notify action in push rules
This commit is contained in:
commit
708144aeea
|
|
@ -2090,16 +2090,22 @@ class Room {
|
|||
/// Returns the [PushRuleState] for this room, based on the m.push_rules stored in
|
||||
/// the account_data.
|
||||
PushRuleState get pushRuleState {
|
||||
final globalPushRules =
|
||||
client.accountData['m.push_rules']?.content['global'];
|
||||
if (globalPushRules is! Map) {
|
||||
final globalPushRules = client.globalPushRules;
|
||||
if (globalPushRules == null) {
|
||||
// We have no push rules specified at all so we fallback to just notify:
|
||||
return PushRuleState.notify;
|
||||
}
|
||||
|
||||
if (globalPushRules['override'] is List) {
|
||||
for (final pushRule in globalPushRules['override']) {
|
||||
if (pushRule['rule_id'] == id) {
|
||||
if (pushRule['actions'].indexOf('dont_notify') != -1) {
|
||||
final overridePushRules = globalPushRules.override;
|
||||
if (overridePushRules != null) {
|
||||
for (final pushRule in overridePushRules) {
|
||||
if (pushRule.ruleId == id) {
|
||||
// "dont_notify" and "coalesce" should be ignored in actions since
|
||||
// https://spec.matrix.org/v1.7/client-server-api/#actions
|
||||
pushRule.actions
|
||||
..remove('dont_notify')
|
||||
..remove('coalesce');
|
||||
if (pushRule.actions.isEmpty) {
|
||||
return PushRuleState.dontNotify;
|
||||
}
|
||||
break;
|
||||
|
|
@ -2107,10 +2113,16 @@ class Room {
|
|||
}
|
||||
}
|
||||
|
||||
if (globalPushRules['room'] is List) {
|
||||
for (final pushRule in globalPushRules['room']) {
|
||||
if (pushRule['rule_id'] == id) {
|
||||
if (pushRule['actions'].indexOf('dont_notify') != -1) {
|
||||
final roomPushRules = globalPushRules.room;
|
||||
if (roomPushRules != null) {
|
||||
for (final pushRule in roomPushRules) {
|
||||
if (pushRule.ruleId == id) {
|
||||
// "dont_notify" and "coalesce" should be ignored in actions since
|
||||
// https://spec.matrix.org/v1.7/client-server-api/#actions
|
||||
pushRule.actions
|
||||
..remove('dont_notify')
|
||||
..remove('coalesce');
|
||||
if (pushRule.actions.isEmpty) {
|
||||
return PushRuleState.mentionsOnly;
|
||||
}
|
||||
break;
|
||||
|
|
@ -2142,13 +2154,13 @@ class Room {
|
|||
await client.setPushRule(
|
||||
PushRuleKind.room,
|
||||
id,
|
||||
[PushRuleAction.dontNotify],
|
||||
[],
|
||||
);
|
||||
} else if (pushRuleState == PushRuleState.notify) {
|
||||
await client.setPushRule(
|
||||
PushRuleKind.room,
|
||||
id,
|
||||
[PushRuleAction.dontNotify],
|
||||
[],
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
|
@ -2160,7 +2172,7 @@ class Room {
|
|||
await client.setPushRule(
|
||||
PushRuleKind.override,
|
||||
id,
|
||||
[PushRuleAction.dontNotify],
|
||||
[],
|
||||
conditions: [
|
||||
PushCondition(kind: 'event_match', key: 'room_id', pattern: id),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue