Skip to content

Commit

Permalink
gitter: Add limit to query room occupants
Browse files Browse the repository at this point in the history
The limit parameter was not used which defaults to 30
and fails to return all the members in the room.

Closes errbotio#38
  • Loading branch information
nvzard committed Oct 28, 2018
1 parent 55b8e48 commit 6d08099
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ class GitterRoom(Room):
def invite(self, *args) -> None:
pass

def __init__(self, backend, idd, uri, name):
def __init__(self, backend, idd, uri, name, user_count):
self._backend = backend
self._name = name
self._uri = uri
self._idd = idd
self._joined = False
self._user_count = user_count

def join(self, username=None, password=None):
log.debug("Joining room %s (%s)" % (self._uri, self._idd))
Expand All @@ -185,6 +186,10 @@ def name(self):
def joined(self):
return self._joined

@property
def user_count(self):
return self._user_count

exists = True # TODO

def destroy(self):
Expand All @@ -208,7 +213,7 @@ def topic(self):
@property
def occupants(self):
occupants = []
json_users = self._backend.readAPIRequest('rooms/%s/users' % self._idd)
json_users = self._backend.readAPIRequest('rooms/%s/users?limit=%s' % (self.idd, self.user_count))
for json_user in json_users:
occupants.append(GitterRoomOccupant.build_from_json(self, json_user['id']))
return occupants
Expand Down Expand Up @@ -369,7 +374,7 @@ def rooms(self):
if not json_room['oneToOne']:
log.debug("found room %s (%s)" % (json_room['name'], json_room['uri']))
rooms.append(GitterRoom(self, json_room['id'], json_room['uri'],
json_room['name']))
json_room['name'], json_room['userCount']))
return rooms

def contacts(self):
Expand Down

0 comments on commit 6d08099

Please sign in to comment.