Merge branch 'develop' into markjh/pushers_stream

pull/4/merge
Mark Haines 9 years ago
commit 6df1c79c22
  1. 4
      synapse/config/registration.py
  2. 17
      synapse/handlers/federation.py
  3. 39
      synapse/handlers/room.py
  4. 4
      synapse/util/caches/stream_change_cache.py

@ -37,6 +37,10 @@ class RegistrationConfig(Config):
self.trusted_third_party_id_servers = config["trusted_third_party_id_servers"] self.trusted_third_party_id_servers = config["trusted_third_party_id_servers"]
self.allow_guest_access = config.get("allow_guest_access", False) self.allow_guest_access = config.get("allow_guest_access", False)
self.invite_3pid_guest = (
self.allow_guest_access and config.get("invite_3pid_guest", False)
)
def default_config(self, **kwargs): def default_config(self, **kwargs):
registration_shared_secret = random_string_with_symbols(50) registration_shared_secret = random_string_with_symbols(50)

@ -813,7 +813,22 @@ class FederationHandler(BaseHandler):
target_hosts, target_hosts,
signed_event signed_event
) )
defer.returnValue(None)
context = yield self.state_handler.compute_event_context(event)
event_stream_id, max_stream_id = yield self.store.persist_event(
event,
context=context,
backfilled=False,
)
target_user = UserID.from_string(event.state_key)
self.notifier.on_new_room_event(
event, event_stream_id, max_stream_id,
extra_users=[target_user],
)
defer.returnValue(event)
@defer.inlineCallbacks @defer.inlineCallbacks
def _make_and_verify_event(self, target_hosts, room_id, user_id, membership, def _make_and_verify_event(self, target_hosts, room_id, user_id, membership,

@ -877,23 +877,11 @@ class RoomMemberHandler(BaseHandler):
user. user.
""" """
registration_handler = self.hs.get_handlers().registration_handler
guest_access_token = yield registration_handler.guest_access_token_for(
medium=medium,
address=address,
inviter_user_id=inviter_user_id,
)
guest_user_info = yield self.hs.get_auth().get_user_by_access_token(
guest_access_token
)
is_url = "%s%s/_matrix/identity/api/v1/store-invite" % ( is_url = "%s%s/_matrix/identity/api/v1/store-invite" % (
id_server_scheme, id_server, id_server_scheme, id_server,
) )
data = yield self.hs.get_simple_http_client().post_urlencoded_get_json(
is_url, invite_config = {
{
"medium": medium, "medium": medium,
"address": address, "address": address,
"room_id": room_id, "room_id": room_id,
@ -904,9 +892,28 @@ class RoomMemberHandler(BaseHandler):
"sender": inviter_user_id, "sender": inviter_user_id,
"sender_display_name": inviter_display_name, "sender_display_name": inviter_display_name,
"sender_avatar_url": inviter_avatar_url, "sender_avatar_url": inviter_avatar_url,
"guest_user_id": guest_user_info["user"].to_string(),
"guest_access_token": guest_access_token,
} }
if self.hs.config.invite_3pid_guest:
registration_handler = self.hs.get_handlers().registration_handler
guest_access_token = yield registration_handler.guest_access_token_for(
medium=medium,
address=address,
inviter_user_id=inviter_user_id,
)
guest_user_info = yield self.hs.get_auth().get_user_by_access_token(
guest_access_token
)
invite_config.update({
"guest_access_token": guest_access_token,
"guest_user_id": guest_user_info["user"].to_string(),
})
data = yield self.hs.get_simple_http_client().post_urlencoded_get_json(
is_url,
invite_config
) )
# TODO: Check for success # TODO: Check for success
token = data["token"] token = data["token"]

@ -99,9 +99,7 @@ class StreamChangeCache(object):
keys = self._cache.keys() keys = self._cache.keys()
i = keys.bisect_right(stream_pos) i = keys.bisect_right(stream_pos)
return ( return [self._cache[k] for k in keys[i:]]
self._cache[k] for k in keys[i:]
)
else: else:
return None return None

Loading…
Cancel
Save