Skip to content

Commit

Permalink
Fix: refs were not filtered properly in message websocket
Browse files Browse the repository at this point in the history
Problem: we checked refs as a message-level fields instead of
`content.ref`.
  • Loading branch information
odesenfans committed Jul 23, 2023
1 parent 93485b8 commit 1fc0457
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/aleph/web/controllers/messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import logging
from typing import List, Optional, Any, Dict, Iterable

Expand Down Expand Up @@ -30,7 +29,6 @@
PendingMessage,
AlephMessage,
format_message_dict,
PostMessage,
)
from aleph.toolkit.shield import shielded
from aleph.types.db_session import DbSessionFactory, DbSession
Expand Down Expand Up @@ -267,7 +265,6 @@ def message_matches_filters(
"sender": "addresses",
"type": "message_type",
"item_hash": "hashes",
"ref": "refs",
"chain": "chains",
"channel": "channels",
}
Expand All @@ -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:
Expand Down

0 comments on commit 1fc0457

Please sign in to comment.