mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Fix bug which caused failure on join with malformed membership events (#8385)
This commit is contained in:
parent
cbabb312e0
commit
302dc89f6a
1
changelog.d/8385.bugfix
Normal file
1
changelog.d/8385.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix a bug which could cause errors in rooms with malformed membership events, on servers using sqlite.
|
@ -17,7 +17,7 @@
|
|||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
from collections import OrderedDict, namedtuple
|
from collections import OrderedDict, namedtuple
|
||||||
from typing import TYPE_CHECKING, Dict, Iterable, List, Set, Tuple
|
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set, Tuple
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
from prometheus_client import Counter
|
from prometheus_client import Counter
|
||||||
@ -1108,6 +1108,10 @@ class PersistEventsStore:
|
|||||||
def _store_room_members_txn(self, txn, events, backfilled):
|
def _store_room_members_txn(self, txn, events, backfilled):
|
||||||
"""Store a room member in the database.
|
"""Store a room member in the database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def str_or_none(val: Any) -> Optional[str]:
|
||||||
|
return val if isinstance(val, str) else None
|
||||||
|
|
||||||
self.db_pool.simple_insert_many_txn(
|
self.db_pool.simple_insert_many_txn(
|
||||||
txn,
|
txn,
|
||||||
table="room_memberships",
|
table="room_memberships",
|
||||||
@ -1118,8 +1122,8 @@ class PersistEventsStore:
|
|||||||
"sender": event.user_id,
|
"sender": event.user_id,
|
||||||
"room_id": event.room_id,
|
"room_id": event.room_id,
|
||||||
"membership": event.membership,
|
"membership": event.membership,
|
||||||
"display_name": event.content.get("displayname", None),
|
"display_name": str_or_none(event.content.get("displayname")),
|
||||||
"avatar_url": event.content.get("avatar_url", None),
|
"avatar_url": str_or_none(event.content.get("avatar_url")),
|
||||||
}
|
}
|
||||||
for event in events
|
for event in events
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user