mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
PR tweaks: set earlier on and use 'as json' for compat
This commit is contained in:
parent
806a6c886a
commit
ebc4830666
@ -219,20 +219,17 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||||||
|
|
||||||
# get all rooms matching the room ID regex.
|
# get all rooms matching the room ID regex.
|
||||||
room_entries = yield self.get_all_rooms() # RoomEntry list
|
room_entries = yield self.get_all_rooms() # RoomEntry list
|
||||||
matching_room_id_list = [
|
matching_room_list = set([
|
||||||
r.room_id for r in room_entries if
|
r.room_id for r in room_entries if
|
||||||
service.is_interested_in_room(r.room_id)
|
service.is_interested_in_room(r.room_id)
|
||||||
]
|
])
|
||||||
|
|
||||||
# resolve room IDs for matching room alias regex.
|
# resolve room IDs for matching room alias regex.
|
||||||
room_alias_mappings = yield self.get_all_associations()
|
room_alias_mappings = yield self.get_all_associations()
|
||||||
matching_alias_list = [
|
matching_room_list |= set([
|
||||||
r.room_id for r in room_alias_mappings if
|
r.room_id for r in room_alias_mappings if
|
||||||
service.is_interested_in_alias(r.room_alias)
|
service.is_interested_in_alias(r.room_alias)
|
||||||
]
|
])
|
||||||
room_ids_matching_alias_or_id = set(
|
|
||||||
matching_room_id_list + matching_alias_list
|
|
||||||
)
|
|
||||||
|
|
||||||
# get all rooms for every user for this AS. This is scoped to users on
|
# get all rooms for every user for this AS. This is scoped to users on
|
||||||
# this HS only.
|
# this HS only.
|
||||||
@ -241,11 +238,10 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||||||
u["name"] for u in user_list if
|
u["name"] for u in user_list if
|
||||||
service.is_interested_in_user(u["name"])
|
service.is_interested_in_user(u["name"])
|
||||||
]
|
]
|
||||||
rooms_for_user_matching_user_id = [] # RoomsForUser list
|
rooms_for_user_matching_user_id = set() # RoomsForUser list
|
||||||
for user_id in user_list:
|
for user_id in user_list:
|
||||||
rooms_for_user = yield self.get_rooms_for_user(user_id)
|
rooms_for_user = yield self.get_rooms_for_user(user_id)
|
||||||
rooms_for_user_matching_user_id += rooms_for_user
|
rooms_for_user_matching_user_id |= set(rooms_for_user)
|
||||||
rooms_for_user_matching_user_id = set(rooms_for_user_matching_user_id)
|
|
||||||
|
|
||||||
# make RoomsForUser tuples for room ids and aliases which are not in the
|
# make RoomsForUser tuples for room ids and aliases which are not in the
|
||||||
# main rooms_for_user_list - e.g. they are rooms which do not have AS
|
# main rooms_for_user_list - e.g. they are rooms which do not have AS
|
||||||
@ -253,7 +249,7 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||||||
known_room_ids = [r.room_id for r in rooms_for_user_matching_user_id]
|
known_room_ids = [r.room_id for r in rooms_for_user_matching_user_id]
|
||||||
missing_rooms_for_user = [
|
missing_rooms_for_user = [
|
||||||
RoomsForUser(r, service.sender, "join") for r in
|
RoomsForUser(r, service.sender, "join") for r in
|
||||||
room_ids_matching_alias_or_id if r not in known_room_ids
|
matching_room_list if r not in known_room_ids
|
||||||
]
|
]
|
||||||
rooms_for_user_matching_user_id |= set(missing_rooms_for_user)
|
rooms_for_user_matching_user_id |= set(missing_rooms_for_user)
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_all_users(self):
|
def get_all_users(self):
|
||||||
query = ("SELECT users.name FROM users")
|
query = "SELECT users.name FROM users"
|
||||||
return self._execute(
|
return self._execute(
|
||||||
self.cursor_to_dict,
|
self.cursor_to_dict,
|
||||||
query
|
query
|
||||||
|
@ -43,7 +43,7 @@ from synapse.util.logutils import log_function
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import simplejson
|
import simplejson as json
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -178,7 +178,7 @@ class StreamStore(SQLBaseStore):
|
|||||||
# interested in was invited to a room. We'll be passing this
|
# interested in was invited to a room. We'll be passing this
|
||||||
# through _get_events_txn later, so ignore the fact that this
|
# through _get_events_txn later, so ignore the fact that this
|
||||||
# may be a redacted event.
|
# may be a redacted event.
|
||||||
event_content = simplejson.loads(row["unrecognized_keys"])
|
event_content = json.loads(row["unrecognized_keys"])
|
||||||
if (service.is_interested_in_user(
|
if (service.is_interested_in_user(
|
||||||
event_content.get("state_key"))):
|
event_content.get("state_key"))):
|
||||||
return True
|
return True
|
||||||
@ -202,7 +202,7 @@ class StreamStore(SQLBaseStore):
|
|||||||
self._set_before_and_after(ret, rows)
|
self._set_before_and_after(ret, rows)
|
||||||
|
|
||||||
if rows:
|
if rows:
|
||||||
key = "s%d" % max([r["stream_ordering"] for r in rows])
|
key = "s%d" % max(r["stream_ordering"] for r in rows)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Assume we didn't get anything because there was nothing to
|
# Assume we didn't get anything because there was nothing to
|
||||||
@ -271,7 +271,7 @@ class StreamStore(SQLBaseStore):
|
|||||||
self._set_before_and_after(ret, rows)
|
self._set_before_and_after(ret, rows)
|
||||||
|
|
||||||
if rows:
|
if rows:
|
||||||
key = "s%d" % max([r["stream_ordering"] for r in rows])
|
key = "s%d" % max(r["stream_ordering"] for r in rows)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Assume we didn't get anything because there was nothing to
|
# Assume we didn't get anything because there was nothing to
|
||||||
|
Loading…
Reference in New Issue
Block a user