match method

Implementation

EvaluatedPushRuleAction match(Event event) {
  final memberCount = event.room.getParticipants([Membership.join]).length;
  final displayName = event.room
      .unsafeGetUserFromMemoryOrFallback(event.room.client.userID!)
      .displayName;
  final content = _flattenJson(event.toJson(), {}, '');
  // ensure roomid is present
  content['room_id'] = event.room.id;

  for (final o in _override) {
    final actions = o.match(content, displayName, memberCount, event.room);
    if (actions != null) {
      return actions;
    }
  }

  final roomActions = _room_rules[event.room.id];
  if (roomActions != null) {
    return roomActions;
  }

  final senderActions = _sender_rules[event.senderId];
  if (senderActions != null) {
    return senderActions;
  }

  for (final o in _content_rules) {
    final actions = o.match(content, displayName, memberCount, event.room);
    if (actions != null) {
      return actions;
    }
  }

  for (final o in _underride) {
    final actions = o.match(content, displayName, memberCount, event.room);
    if (actions != null) {
      return actions;
    }
  }

  return EvaluatedPushRuleAction();
}