0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-18 18:34:11 +01:00

Merge branch 'release-v0.12.0' into develop

This commit is contained in:
Mark Haines 2015-12-14 14:46:55 +00:00
commit 15e9885197
3 changed files with 23 additions and 7 deletions

View file

@ -17,6 +17,7 @@ from ._base import BaseHandler
from synapse.streams.config import PaginationConfig from synapse.streams.config import PaginationConfig
from synapse.api.constants import Membership, EventTypes from synapse.api.constants import Membership, EventTypes
from synapse.util import unwrapFirstError
from twisted.internet import defer from twisted.internet import defer
@ -209,9 +210,10 @@ class SyncHandler(BaseHandler):
joined = [] joined = []
invited = [] invited = []
archived = [] archived = []
deferreds = []
for event in room_list: for event in room_list:
if event.membership == Membership.JOIN: if event.membership == Membership.JOIN:
room_sync = yield self.full_state_sync_for_joined_room( room_sync_deferred = self.full_state_sync_for_joined_room(
room_id=event.room_id, room_id=event.room_id,
sync_config=sync_config, sync_config=sync_config,
now_token=now_token, now_token=now_token,
@ -220,7 +222,8 @@ class SyncHandler(BaseHandler):
tags_by_room=tags_by_room, tags_by_room=tags_by_room,
account_data_by_room=account_data_by_room, account_data_by_room=account_data_by_room,
) )
joined.append(room_sync) room_sync_deferred.addCallback(joined.append)
deferreds.append(room_sync_deferred)
elif event.membership == Membership.INVITE: elif event.membership == Membership.INVITE:
invite = yield self.store.get_event(event.event_id) invite = yield self.store.get_event(event.event_id)
invited.append(InvitedSyncResult( invited.append(InvitedSyncResult(
@ -231,7 +234,7 @@ class SyncHandler(BaseHandler):
leave_token = now_token.copy_and_replace( leave_token = now_token.copy_and_replace(
"room_key", "s%d" % (event.stream_ordering,) "room_key", "s%d" % (event.stream_ordering,)
) )
room_sync = yield self.full_state_sync_for_archived_room( room_sync_deferred = self.full_state_sync_for_archived_room(
sync_config=sync_config, sync_config=sync_config,
room_id=event.room_id, room_id=event.room_id,
leave_event_id=event.event_id, leave_event_id=event.event_id,
@ -240,7 +243,12 @@ class SyncHandler(BaseHandler):
tags_by_room=tags_by_room, tags_by_room=tags_by_room,
account_data_by_room=account_data_by_room, account_data_by_room=account_data_by_room,
) )
archived.append(room_sync) room_sync_deferred.addCallback(archived.append)
deferreds.append(room_sync_deferred)
yield defer.gatherResults(
deferreds, consumeErrors=True
).addErrback(unwrapFirstError)
defer.returnValue(SyncResult( defer.returnValue(SyncResult(
presence=presence, presence=presence,

View file

@ -354,17 +354,20 @@ class SyncRestServlet(RestServlet):
logger.debug("Replacing %s with %s in state dict", logger.debug("Replacing %s with %s in state dict",
timeline_event.event_id, prev_event_id) timeline_event.event_id, prev_event_id)
if prev_event_id is None: prev_content = timeline_event.unsigned.get('prev_content')
prev_sender = timeline_event.unsigned.get('prev_sender')
if prev_event_id is None or not prev_content or not prev_sender:
del result[event_key] del result[event_key]
else: else:
result[event_key] = FrozenEvent({ result[event_key] = FrozenEvent({
"type": timeline_event.type, "type": timeline_event.type,
"state_key": timeline_event.state_key, "state_key": timeline_event.state_key,
"content": timeline_event.unsigned['prev_content'], "content": prev_content,
"sender": timeline_event.unsigned['prev_sender'], "sender": prev_sender,
"event_id": prev_event_id, "event_id": prev_event_id,
"room_id": timeline_event.room_id, "room_id": timeline_event.room_id,
}) })
logger.debug("New value: %r", result.get(event_key)) logger.debug("New value: %r", result.get(event_key))
return result return result

View file

@ -85,6 +85,11 @@ class SearchStore(BackgroundUpdateStore):
# skip over it. # skip over it.
continue continue
if not isinstance(value, basestring):
# If the event body, name or topic isn't a string
# then skip over it
continue
event_search_rows.append((event_id, room_id, key, value)) event_search_rows.append((event_id, room_id, key, value))
if isinstance(self.database_engine, PostgresEngine): if isinstance(self.database_engine, PostgresEngine):