Skip to content

Commit

Permalink
Fix im.list call
Browse files Browse the repository at this point in the history
Fix #62
  • Loading branch information
pipozzz committed May 25, 2022
1 parent e731703 commit 785bd09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
26 changes: 1 addition & 25 deletions rocketchat/calls/im/get_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,4 @@ def build_endpoint(self):
return self.endpoint

def post_response(self, result):
rooms = []

try:
_rooms = result.get("ims")

for room in _rooms:
if not room.get("usernames"):
continue

for username in room.get("usernames"):
if username != self.settings["username"]:
break

room_dict = {}
room_dict["username"] = username
room_dict["id"] = room.get("_id")
rooms.append(room_dict)

except Exception as e:
logger.error(
"Exception in fetching im rooms {e}".format(e=e),
exc_info=True,
)

return rooms
return result['ims']
6 changes: 2 additions & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,8 @@ def test_get_im_rooms(self, mock_request, set_auth_headers_mock, set_auth_mock):

rooms = self.api.get_im_rooms()

self.assertEqual(rooms[0]['id'], 'RtycPC29hqLJfT9xjew28FnZqipDpvKw3R')
self.assertEqual(rooms[0]['username'], 'chat.user')
self.assertEqual(rooms[1]['id'], 'ew28FnZqipDpvKw3Rf2CAhYGtjS9iNZ7nd')
self.assertEqual(rooms[1]['username'], 'chat.user2')
self.assertEqual(rooms[0]['_id'], 'ew28FnZqipDpvKw3Rrocket.cat')
self.assertEqual(rooms[1]['_id'], 'RtycPC29hqLJfT9xjew28FnZqipDpvKw3R')


class GetImHistoryTestCase(APITestCase, unittest.TestCase):
Expand Down

0 comments on commit 785bd09

Please sign in to comment.