Merge branch 'erikj/perf_room_members_fix' of github.com:matrix-org/synapse into erikj/profile_rununtilconcurrent

This commit is contained in:
Erik Johnston 2015-06-01 15:03:47 +01:00
commit d92b3884cc
8 changed files with 17 additions and 6 deletions

View file

@ -21,3 +21,5 @@ handlers:
root: root:
level: INFO level: INFO
handlers: [journal] handlers: [journal]
disable_existing_loggers: False

View file

@ -26,6 +26,7 @@ class CaptchaConfig(Config):
config["captcha_ip_origin_is_x_forwarded"] config["captcha_ip_origin_is_x_forwarded"]
) )
self.captcha_bypass_secret = config.get("captcha_bypass_secret") self.captcha_bypass_secret = config.get("captcha_bypass_secret")
self.recaptcha_siteverify_api = config["recaptcha_siteverify_api"]
def default_config(self, config_dir_path, server_name): def default_config(self, config_dir_path, server_name):
return """\ return """\
@ -48,4 +49,7 @@ class CaptchaConfig(Config):
# A secret key used to bypass the captcha test entirely. # A secret key used to bypass the captcha test entirely.
#captcha_bypass_secret: "YOUR_SECRET_HERE" #captcha_bypass_secret: "YOUR_SECRET_HERE"
# The API endpoint to use for verifying m.login.recaptcha responses.
recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify"
""" """

View file

@ -131,7 +131,7 @@ class FrozenEvent(EventBase):
if USE_FROZEN_DICTS: if USE_FROZEN_DICTS:
frozen_dict = freeze(event_dict) frozen_dict = freeze(event_dict)
else: else:
frozen_dict = dict(event_dict) frozen_dict = event_dict
super(FrozenEvent, self).__init__( super(FrozenEvent, self).__init__(
frozen_dict, frozen_dict,

View file

@ -188,7 +188,7 @@ class AuthHandler(BaseHandler):
try: try:
client = SimpleHttpClient(self.hs) client = SimpleHttpClient(self.hs)
resp_body = yield client.post_urlencoded_get_json( resp_body = yield client.post_urlencoded_get_json(
"https://www.google.com/recaptcha/api/siteverify", self.hs.config.recaptcha_siteverify_api,
args={ args={
'secret': self.hs.config.recaptcha_private_key, 'secret': self.hs.config.recaptcha_private_key,
'response': user_response, 'response': user_response,

View file

@ -254,9 +254,7 @@ class RoomMemberHandler(BaseHandler):
@defer.inlineCallbacks @defer.inlineCallbacks
def get_room_members(self, room_id): def get_room_members(self, room_id):
users = yield self.store.get_users_in_room(room_id) return self.store.get_user_objs_in_room(room_id)
defer.returnValue([UserID.from_string(u) for u in users])
@defer.inlineCallbacks @defer.inlineCallbacks
def fetch_room_distributions_into(self, room_id, localusers=None, def fetch_room_distributions_into(self, room_id, localusers=None,

View file

@ -290,7 +290,6 @@ def respond_with_json(request, code, json_object, send_cors=False,
json_bytes = encode_json( json_bytes = encode_json(
json_object, using_frozen_dicts=synapse.events.USE_FROZEN_DICTS json_object, using_frozen_dicts=synapse.events.USE_FROZEN_DICTS
) )
logger.debug("json_bytes: %r %r", json_object, json_bytes)
return respond_with_json_bytes( return respond_with_json_bytes(
request, code, json_bytes, request, code, json_bytes,

View file

@ -128,6 +128,7 @@ class EventsStore(SQLBaseStore):
txn.call_after(self.get_current_state_for_key.invalidate_all) txn.call_after(self.get_current_state_for_key.invalidate_all)
txn.call_after(self.get_rooms_for_user.invalidate_all) txn.call_after(self.get_rooms_for_user.invalidate_all)
txn.call_after(self.get_users_in_room.invalidate, event.room_id) txn.call_after(self.get_users_in_room.invalidate, event.room_id)
txn.call_after(self.get_user_objs_in_room.invalidate, event.room_id)
txn.call_after(self.get_joined_hosts_for_room.invalidate, event.room_id) txn.call_after(self.get_joined_hosts_for_room.invalidate, event.room_id)
txn.call_after(self.get_room_name_and_aliases, event.room_id) txn.call_after(self.get_room_name_and_aliases, event.room_id)

View file

@ -67,6 +67,7 @@ class RoomMemberStore(SQLBaseStore):
txn.call_after(self.get_rooms_for_user.invalidate, target_user_id) txn.call_after(self.get_rooms_for_user.invalidate, target_user_id)
txn.call_after(self.get_joined_hosts_for_room.invalidate, event.room_id) txn.call_after(self.get_joined_hosts_for_room.invalidate, event.room_id)
txn.call_after(self.get_users_in_room.invalidate, event.room_id) txn.call_after(self.get_users_in_room.invalidate, event.room_id)
txn.call_after(self.get_user_objs_in_room.invalidate, event.room_id)
def get_room_member(self, user_id, room_id): def get_room_member(self, user_id, room_id):
"""Retrieve the current state of a room member. """Retrieve the current state of a room member.
@ -101,6 +102,12 @@ class RoomMemberStore(SQLBaseStore):
return [r["user_id"] for r in rows] return [r["user_id"] for r in rows]
return self.runInteraction("get_users_in_room", f) return self.runInteraction("get_users_in_room", f)
@cached()
def get_user_objs_in_room(self, room_id):
return self.get_users_in_room(room_id).addCallback(
lambda users: [UserID.from_string(u) for u in users]
)
def get_room_members(self, room_id, membership=None): def get_room_members(self, room_id, membership=None):
"""Retrieve the current room member list for a room. """Retrieve the current room member list for a room.