summary refs log tree commit diff
path: root/synapse/storage/databases/main/stream.py
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2024-01-23 15:30:03 +0000
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2024-01-23 15:30:03 +0000
commitd5e213e16f98ff247d89bc6a4f5d2e494b0b9efe (patch)
tree823ab2bac8da6a8d2e9223aaf2227f41a852e096 /synapse/storage/databases/main/stream.py
parentSpeed up e2e device keys queries for bot accounts (diff)
parentUpdate changelog (diff)
downloadsynapse-d5e213e16f98ff247d89bc6a4f5d2e494b0b9efe.tar.xz
Merge branch 'release-v1.100' into matrix-org-hotfixes
Diffstat (limited to 'synapse/storage/databases/main/stream.py')
-rw-r--r--synapse/storage/databases/main/stream.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/synapse/storage/databases/main/stream.py b/synapse/storage/databases/main/stream.py

index aeeb74b46d..19041cc35b 100644 --- a/synapse/storage/databases/main/stream.py +++ b/synapse/storage/databases/main/stream.py
@@ -1,6 +1,9 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2019 The Matrix.org Foundation C.I.C. +# Copyright 2017 Vector Creations Ltd +# Copyright 2014-2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify @@ -398,14 +401,25 @@ def filter_to_clause(event_filter: Optional[Filter]) -> Tuple[str, List[str]]: clauses = [] args = [] + # Handle event types with potential wildcard characters if event_filter.types: - clauses.append( - "(%s)" % " OR ".join("event.type = ?" for _ in event_filter.types) - ) - args.extend(event_filter.types) - + type_clauses = [] + for typ in event_filter.types: + if "*" in typ: + type_clauses.append("event.type LIKE ?") + typ = typ.replace("*", "%") # Replace * with % for SQL LIKE pattern + else: + type_clauses.append("event.type = ?") + args.append(typ) + clauses.append("(%s)" % " OR ".join(type_clauses)) + + # Handle event types to exclude with potential wildcard characters for typ in event_filter.not_types: - clauses.append("event.type != ?") + if "*" in typ: + clauses.append("event.type NOT LIKE ?") + typ = typ.replace("*", "%") + else: + clauses.append("event.type != ?") args.append(typ) if event_filter.senders: