Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add chat.getThreadMessages #233

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions rocketchat_API/APISections/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ def chat_report_message(self, message_id, description, **kwargs):
def chat_follow_message(self, mid, **kwargs):
"""Follows a chat message to the message's channel."""
return self.call_api_post("chat.followMessage", mid=mid, kwargs=kwargs)

def chat_get_thread_messages(self, thread_msg_id, **kwargs):
"""Get thread messages."""
return self.call_api_get(
"chat.getThreadMessages",
tmid=thread_msg_id,
kwargs=kwargs,
)
37 changes: 37 additions & 0 deletions tests/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,40 @@ def test_chat_follow_message(logged_rocket):
mid=message_id
).json()
assert chat_get_message_follow_message.get("success")


def test_chat_get_thread_messages(logged_rocket):
chat_post_message1 = logged_rocket.chat_post_message(
"text1",
channel="GENERAL",
).json()
msg1_id = chat_post_message1.get("message").get("_id")

chat_post_message2 = logged_rocket.chat_post_message(
"text2",
channel="GENERAL",
tmid=msg1_id,
).json()

chat_post_message3 = logged_rocket.chat_post_message(
"text3",
channel="GENERAL",
tmid=msg1_id,
tshow="False",
).json()

chat_get_thread_messages = logged_rocket.chat_get_thread_messages(
thread_msg_id=msg1_id,
).json()

# check that correct number of messages is returned
assert chat_get_thread_messages.get("count") == 2

# check that text of messages are correct and messages are returned in order
assert chat_get_thread_messages.get("messages")[0].get(
"msg"
) == chat_post_message2.get("message").get("msg")
assert chat_get_thread_messages.get("messages")[1].get(
"msg"
) == chat_post_message3.get("message").get("msg")
assert chat_get_thread_messages.get("success")