Skip to content

Commit

Permalink
Merge pull request #133 from jadolg/add-chat.getStarredMessages
Browse files Browse the repository at this point in the history
Add method to get starred messages on a chat (chat.getStarredMessages)
  • Loading branch information
jadolg authored Sep 3, 2021
2 parents 8f772d5 + eb03dd2 commit 8c941d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions rocketchat_API/APISections/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ def chat_get_message_read_receipts(self, message_id, **kwargs):
return self.call_api_get(
"chat.getMessageReadReceipts", messageId=message_id, kwargs=kwargs
)

def chat_get_starred_messages(self, room_id, **kwargs):
"""Retrieve starred messages."""
return self.call_api_get(
"chat.getStarredMessages", roomId=room_id, kwargs=kwargs
)
17 changes: 16 additions & 1 deletion tests/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,31 @@ def test_post_pin_unpin(logged_rocket):
assert chat_unpin_message.get("success")


def test_post_star_unstar(logged_rocket):
def test_post_star_unstar_get_starred_messages(logged_rocket):
message_id = (
logged_rocket.chat_post_message("hello", channel="GENERAL")
.json()
.get("message")
.get("_id")
)

chat_get_starred_messages = logged_rocket.chat_get_starred_messages(
room_id="GENERAL"
).json()
assert chat_get_starred_messages.get("success")
assert chat_get_starred_messages.get("count") == 0
assert chat_get_starred_messages.get("messages") == []

chat_star_message = logged_rocket.chat_star_message(message_id).json()
assert chat_star_message.get("success")

chat_get_starred_messages = logged_rocket.chat_get_starred_messages(
room_id="GENERAL"
).json()
assert chat_get_starred_messages.get("success")
assert chat_get_starred_messages.get("count") == 1
assert chat_get_starred_messages.get("messages") != []

chat_unstar_message = logged_rocket.chat_unstar_message(message_id).json()
assert chat_unstar_message.get("success")

Expand Down

0 comments on commit 8c941d9

Please sign in to comment.