diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-01-29 14:55:27 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-01-29 14:55:27 +0000 |
commit | 9d8f798a3fa0a0a98626218ff1602bf06be0fb82 (patch) | |
tree | 7226008bc691b4599c2c499de63c4bbced486a1b /synapse/storage/__init__.py | |
parent | Move bump schema delta (diff) | |
parent | SYN-252: Supply the stream and topological parts in the correct order to the ... (diff) | |
download | synapse-9d8f798a3fa0a0a98626218ff1602bf06be0fb82.tar.xz |
Merge changes from develop
Diffstat (limited to 'synapse/storage/__init__.py')
-rw-r--r-- | synapse/storage/__init__.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index 00a04f565d..89a1e60c2b 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -29,6 +29,8 @@ from .stream import StreamStore from .transactions import TransactionStore from .keys import KeyStore from .event_federation import EventFederationStore +from .pusher import PusherStore +from .push_rule import PushRuleStore from .media_repository import MediaRepositoryStore from .state import StateStore from .signatures import SignatureStore @@ -60,6 +62,7 @@ SCHEMAS = [ "state", "event_edges", "event_signatures", + "pusher", "media_repository", "filtering", ] @@ -84,6 +87,8 @@ class DataStore(RoomMemberStore, RoomStore, EventFederationStore, MediaRepositoryStore, FilteringStore, + PusherStore, + PushRuleStore ): def __init__(self, hs): @@ -384,6 +389,41 @@ class DataStore(RoomMemberStore, RoomStore, defer.returnValue(events) @defer.inlineCallbacks + def get_room_name_and_aliases(self, room_id): + del_sql = ( + "SELECT event_id FROM redactions WHERE redacts = e.event_id " + "LIMIT 1" + ) + + sql = ( + "SELECT e.*, (%(redacted)s) AS redacted FROM events as e " + "INNER JOIN current_state_events as c ON e.event_id = c.event_id " + "INNER JOIN state_events as s ON e.event_id = s.event_id " + "WHERE c.room_id = ? " + ) % { + "redacted": del_sql, + } + + sql += " AND ((s.type = 'm.room.name' AND s.state_key = '')" + sql += " OR s.type = 'm.room.aliases')" + args = (room_id,) + + results = yield self._execute_and_decode(sql, *args) + + events = yield self._parse_events(results) + + name = None + aliases = [] + + for e in events: + if e.type == 'm.room.name': + name = e.content['name'] + elif e.type == 'm.room.aliases': + aliases.extend(e.content['aliases']) + + defer.returnValue((name, aliases)) + + @defer.inlineCallbacks def _get_min_token(self): row = yield self._execute( None, |