diff options
author | Erik Johnston <erik@matrix.org> | 2015-01-30 14:08:28 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-01-30 14:08:28 +0000 |
commit | e0b7c521cbe4d9aa4403a8e5394177a51c6d5d8f (patch) | |
tree | f84a3b1845ff2e6df699d69f3fbb99a2c1ed918b /synapse/storage/__init__.py | |
parent | Merge branch 'new_state_resolution' of github.com:matrix-org/synapse into rej... (diff) | |
parent | We do need Twisted 14, not 15: we use internal Twisted things that have been ... (diff) | |
download | synapse-e0b7c521cbe4d9aa4403a8e5394177a51c6d5d8f.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into rejections_storage
Conflicts: synapse/storage/__init__.py synapse/storage/schema/delta/v12.sql
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 015fcc8775..1f1b720e5e 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 .rejections import RejectionsStore @@ -61,6 +63,7 @@ SCHEMAS = [ "state", "event_edges", "event_signatures", + "pusher", "media_repository", ] @@ -84,6 +87,8 @@ class DataStore(RoomMemberStore, RoomStore, EventFederationStore, MediaRepositoryStore, RejectionsStore, + PusherStore, + PushRuleStore ): def __init__(self, hs): @@ -387,6 +392,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, |