Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #453 from matrix-org/daniel/avatarurls
Browse files Browse the repository at this point in the history
Return room avatar URLs in /publicRooms

Spec: matrix-org/matrix-spec-proposals#244
Tests: matrix-org/sytest#121
  • Loading branch information
illicitonion committed Dec 21, 2015
2 parents bb9c7f2 + 7f31488 commit 2e2eeb4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,20 +816,39 @@ class RoomListHandler(BaseHandler):
@defer.inlineCallbacks
def get_public_room_list(self):
chunk = yield self.store.get_rooms(is_public=True)
results = yield defer.gatherResults(

room_members = yield defer.gatherResults(
[
self.store.get_users_in_room(room["room_id"])
for room in chunk
],
consumeErrors=True,
).addErrback(unwrapFirstError)

avatar_urls = yield defer.gatherResults(
[
self.get_room_avatar_url(room["room_id"])
for room in chunk
],
consumeErrors=True,
).addErrback(unwrapFirstError)

for i, room in enumerate(chunk):
room["num_joined_members"] = len(results[i])
room["num_joined_members"] = len(room_members[i])
if avatar_urls[i]:
room["avatar_url"] = avatar_urls[i]

# FIXME (erikj): START is no longer a valid value
defer.returnValue({"start": "START", "end": "END", "chunk": chunk})

@defer.inlineCallbacks
def get_room_avatar_url(self, room_id):
event = yield self.hs.get_state_handler().get_current_state(
room_id, "m.room.avatar"
)
if event and "url" in event.content:
defer.returnValue(event.content["url"])


class RoomContextHandler(BaseHandler):
@defer.inlineCallbacks
Expand Down

0 comments on commit 2e2eeb4

Please sign in to comment.