pushRuleState property

PushRuleState get pushRuleState

Returns the PushRuleState for this room, based on the m.push_rules stored in the account_data.

Implementation

PushRuleState get pushRuleState {
  final globalPushRules =
      client.accountData['m.push_rules']?.content['global'];
  if (globalPushRules is! Map) {
    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) {
          return PushRuleState.dontNotify;
        }
        break;
      }
    }
  }

  if (globalPushRules['room'] is List) {
    for (final pushRule in globalPushRules['room']) {
      if (pushRule['rule_id'] == id) {
        if (pushRule['actions'].indexOf('dont_notify') != -1) {
          return PushRuleState.mentionsOnly;
        }
        break;
      }
    }
  }

  return PushRuleState.notify;
}