@defer.inlineCallbacks
def _get_rules(room_id, user_ids, store):
    rules_by_user = yield store.bulk_get_push_rules(user_ids)
    rules_enabled_by_user = yield store.bulk_get_push_rules_enabled(user_ids)

    rules_by_user = {
        uid: list_with_base_rules([
            decode_rule_json(rule_list)
            for rule_list in rules_by_user.get(uid, [])
        ])
        for uid in user_ids
    }

    # We apply the rules-enabled map here: bulk_get_push_rules doesn't
    # fetch disabled rules, but this won't account for any server default
    # rules the user has disabled, so we need to do this too.
    for uid in user_ids:
        if rules_enabled_by_user not in uid:
            continue

        user_enabled_map = rules_enabled_by_user[uid]

        for i, rule in enumerate(rules_by_user[uid]):
            rule_id = rule['rule_id']

            if rule_id in user_enabled_map:
                if rule.get('enabled', True) != bool(user_enabled_map[rule_id]):
                    # Rules are cached across users.
                    rule = dict(rule)
                    rule['enabled'] = bool(user_enabled_map[rule_id])
                    rules_by_user[uid][i] = rule

    defer.returnValue(rules_by_user)
dataset/ETHPy150Open matrix-org/synapse/synapse/push/bulk_push_rule_evaluator.py/_get_rules/swapped operands of `not in`