diff options
author | David Baker <dave@matrix.org> | 2015-01-15 16:56:18 +0000 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2015-01-15 16:56:18 +0000 |
commit | 2ca2dbc82183f7dbe8c01694bf1c32a8c4c4b9de (patch) | |
tree | 52cb35fcc73f76fe727cf62cb69c81d2f7b24734 /synapse/storage | |
parent | Don't make the pushers' event streams cause people to appear online (diff) | |
download | synapse-2ca2dbc82183f7dbe8c01694bf1c32a8c4c4b9de.tar.xz |
Send room name and first alias in notification poke.
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/__init__.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index fa7ad0eea8..191fe462a5 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -385,6 +385,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, |