From 1fc0457d104a2dc6dbf6ab4d772dc95f38e19a83 Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Mon, 24 Jul 2023 00:19:53 +0200 Subject: [PATCH] Fix: refs were not filtered properly in message websocket Problem: we checked refs as a message-level fields instead of `content.ref`. --- src/aleph/web/controllers/messages.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/aleph/web/controllers/messages.py b/src/aleph/web/controllers/messages.py index 61ea0f75f..6d1f409b1 100644 --- a/src/aleph/web/controllers/messages.py +++ b/src/aleph/web/controllers/messages.py @@ -1,4 +1,3 @@ -import asyncio import logging from typing import List, Optional, Any, Dict, Iterable @@ -30,7 +29,6 @@ PendingMessage, AlephMessage, format_message_dict, - PostMessage, ) from aleph.toolkit.shield import shielded from aleph.types.db_session import DbSessionFactory, DbSession @@ -267,7 +265,6 @@ def message_matches_filters( "sender": "addresses", "type": "message_type", "item_hash": "hashes", - "ref": "refs", "chain": "chains", "channel": "channels", } @@ -281,6 +278,11 @@ def message_matches_filters( # Process filters on content and content.content message_content = message.content + if refs := query_params.refs: + ref = getattr(message_content, "ref", None) + if ref not in refs: + return False + if content_types := query_params.content_types: content_type = getattr(message_content, "type", None) if content_type not in content_types: