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

messages: Update metadata handling for message reaction. #1555

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions tests/ui_tools/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,22 @@ def test_transform_content(self, mocker, raw_html, expected_content):
@pytest.mark.parametrize(
"to_vary_in_each_message, expected_text, expected_attributes",
[
case(
{
"reactions": [
{
"emoji_name": "thumbs_up",
"emoji_code": "1f44d",
"user_id": 1001,
"reaction_type": "unicode_emoji",
},
],
},
" :thumbs_up: 1 ",
[
("reaction", 17),
],
),
case(
{
"reactions": [
Expand Down
12 changes: 9 additions & 3 deletions zulipterminal/ui_tools/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,16 @@ def reactions_view(
my_user_id = self.model.user_id
reaction_stats = defaultdict(list)
for reaction in reactions:
user_id = int(reaction["user"].get("id", -1))
user_id = reaction.get("user_id", -1)
if user_id == -1:
user_id = int(reaction["user"]["user_id"])
user_name = reaction["user"]["full_name"]
user_id = int(reaction["user"].get("id", -1))
if user_id == -1:
user_id = int(reaction["user"]["user_id"])
if user_id is None:
user_name = reaction["user"]["full_name"]
user = self.model.get_user_info(user_id)
if user is not None:
user_name = user.get("full_name", None)
if user_id == my_user_id:
user_name = "You"
reaction_stats[reaction["emoji_name"]].append((user_id, user_name))
Expand Down
Loading