mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:06:08 -04:00
Do not assume that account data is of the correct form. (#8454)
This fixes a bug where `m.ignored_user_list` was assumed to be a dict, leading to odd behavior for users who set it to something else.
This commit is contained in:
parent
e3debf9682
commit
c5251c6fbd
6 changed files with 34 additions and 21 deletions
|
@ -18,6 +18,7 @@ import abc
|
|||
import logging
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from synapse.api.constants import AccountDataTypes
|
||||
from synapse.storage._base import SQLBaseStore, db_to_json
|
||||
from synapse.storage.database import DatabasePool
|
||||
from synapse.storage.util.id_generators import StreamIdGenerator
|
||||
|
@ -291,14 +292,18 @@ class AccountDataWorkerStore(SQLBaseStore, metaclass=abc.ABCMeta):
|
|||
self, ignored_user_id: str, ignorer_user_id: str, cache_context: _CacheContext
|
||||
) -> bool:
|
||||
ignored_account_data = await self.get_global_account_data_by_type_for_user(
|
||||
"m.ignored_user_list",
|
||||
AccountDataTypes.IGNORED_USER_LIST,
|
||||
ignorer_user_id,
|
||||
on_invalidate=cache_context.invalidate,
|
||||
)
|
||||
if not ignored_account_data:
|
||||
return False
|
||||
|
||||
return ignored_user_id in ignored_account_data.get("ignored_users", {})
|
||||
try:
|
||||
return ignored_user_id in ignored_account_data.get("ignored_users", {})
|
||||
except TypeError:
|
||||
# The type of the ignored_users field is invalid.
|
||||
return False
|
||||
|
||||
|
||||
class AccountDataStore(AccountDataWorkerStore):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue