0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-15 00:03:51 +01:00

More bug fixes

This commit is contained in:
Erik Johnston 2014-12-08 17:50:56 +00:00
parent ee3df06183
commit 609c31e8df
5 changed files with 35 additions and 30 deletions

View file

@ -39,7 +39,7 @@ def check_event_content_hash(event, hash_algorithm=hashlib.sha256):
),
Codes.UNAUTHORIZED,
)
message_hash_base64 = event.hashes[name.name]
message_hash_base64 = event.hashes[name]
try:
message_hash_bytes = decode_base64(message_hash_base64)
except:

View file

@ -157,11 +157,4 @@ class FrozenEvent(EventBase):
def get_dict(self):
# We need to unfreeze what we return
d = _unfreeze(self._event_dict)
d.update({
"signatures": self.signatures,
"unsigned": self.unsigned,
})
return d
return _unfreeze(super(FrozenEvent, self).get_dict())

View file

@ -337,23 +337,29 @@ class FederationHandler(BaseHandler):
self.room_queues[room_id] = []
builder = self.event_builder_factory.new(
event.get_pdu_json()
)
try:
event.event_id = self.event_factory.create_event_id()
event.origin = self.hs.hostname
event.content = content
builder.event_id = self.event_factory.create_event_id()
builder.origin = self.hs.hostname
builder.content = content
if not hasattr(event, "signatures"):
event.signatures = {}
builder.signatures = {}
add_hashes_and_signatures(
event,
builder,
self.hs.hostname,
self.hs.config.signing_key[0],
)
new_event = builder.build()
ret = yield self.replication_layer.send_join(
target_host,
event
new_event
)
state = ret["state"]
@ -363,7 +369,7 @@ class FederationHandler(BaseHandler):
logger.debug("do_invite_join auth_chain: %s", auth_chain)
logger.debug("do_invite_join state: %s", state)
logger.debug("do_invite_join event: %s", event)
logger.debug("do_invite_join event: %s", new_event)
try:
yield self.store.store_room(
@ -400,13 +406,13 @@ class FederationHandler(BaseHandler):
)
yield self._handle_new_event(
event,
new_event,
state=state,
current_state=state,
)
yield self.notifier.on_new_room_event(
event, extra_users=[joinee]
new_event, extra_users=[joinee]
)
logger.debug("Finished joining %s to %s", joinee, room_id)
@ -457,7 +463,7 @@ class FederationHandler(BaseHandler):
event.internal_metadata.outlier = False
yield self._handle_new_event(event)
context = yield self._handle_new_event(event)
extra_users = []
if event.type == RoomMemberEvent.TYPE:
@ -480,7 +486,7 @@ class FederationHandler(BaseHandler):
destinations = set()
for k, s in event.state_events.items():
for k, s in context.current_state.items():
try:
if k[0] == RoomMemberEvent.TYPE:
if s.content["membership"] == Membership.JOIN:
@ -492,14 +498,12 @@ class FederationHandler(BaseHandler):
"Failed to get destination from event %s", s.event_id
)
new_pdu.destinations = list(destinations)
yield self.replication_layer.send_pdu(new_pdu)
yield self.replication_layer.send_pdu(new_pdu, destinations)
auth_chain = yield self.store.get_auth_chain(event.event_id)
defer.returnValue({
"state": event.state_events.values(),
"state": context.current_state.values(),
"auth_chain": auth_chain,
})
@ -652,6 +656,7 @@ class FederationHandler(BaseHandler):
context = EventContext()
yield self.state_handler.annotate_context_with_state(
event,
context,
old_state=state
)
@ -664,7 +669,6 @@ class FederationHandler(BaseHandler):
if e_id not in known_ids:
e = yield self.store.get_event(
e_id,
context,
allow_none=True,
)
@ -689,7 +693,10 @@ class FederationHandler(BaseHandler):
yield self.store.persist_event(
event,
context=context,
backfilled=backfilled,
is_new_state=(is_new_state and not backfilled),
current_state=current_state,
)
defer.returnValue(context)

View file

@ -171,6 +171,7 @@ class RoomCreationHandler(BaseHandler):
event_keys = {
"room_id": room_id,
"sender": creator_id,
"state_key": "",
}
def create(etype, content, **kwargs):
@ -187,7 +188,6 @@ class RoomCreationHandler(BaseHandler):
creation_event = create(
etype=RoomCreateEvent.TYPE,
content={"creator": creator.to_string()},
state_key="",
)
join_event = create(
@ -388,7 +388,7 @@ class RoomMemberHandler(BaseHandler):
host = hosts[0]
content.update({"membership": Membership.JOIN})
event, context = yield self.create_new_client_event({
builder = self.event_builder_factory.new({
"type": RoomMemberEvent.TYPE,
"state_key": joinee.to_string(),
"room_id": room_id,
@ -396,6 +396,7 @@ class RoomMemberHandler(BaseHandler):
"membership": Membership.JOIN,
"content": content,
})
event, context = yield self._create_new_client_event(builder)
yield self._do_join(event, context, room_host=host, do_auth=True)
@ -442,7 +443,11 @@ class RoomMemberHandler(BaseHandler):
if should_do_dance:
handler = self.hs.get_handlers().federation_handler
have_joined = yield handler.do_invite_join(
room_host, room_id, event.user_id, event.content, context
room_host,
room_id,
event.user_id,
event.get_dict()["content"], # FIXME To get a non-frozen dict
context
)
# We want to do the _do_update inside the room lock.

View file

@ -160,13 +160,13 @@ class StateHandler(object):
group, curr_state, prev_state = ret
context.current_state = curr_state
context.state_group = group
context.state_group = group if not event.is_state() else None
prev_state = yield self.store.add_event_hashes(
prev_state
)
if hasattr(event, "auth_events") and event.auth_events:
if hasattr(event, "auth_events"):
auth_ids = zip(*event.auth_events)[0]
context.auth_events = {
k: v