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

[WIP] Notify when a message with alert word is received #1301

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Subhasish-Behera
Copy link
Contributor

model/test_model/conftest : Notify when a message with alert word is received

What does this PR do?

Partial fix for #588

Tested?

  • Manually
  • Existing tests (adapted, if necessary)
  • New tests added (for any new behavior)
  • Passed linting & tests (each commit)

Commit flow

Notes & Questions

->No changes have been made to for private messages(not required as alert_words would be a subset case for this)
and in stream added the condition not is_muted_topic and not is_muted_stream when a message has flag:'has_alert_word'
-> Added tests specifically for stream with 3 parameters visual_notification_status,is_stream_muted,is_topic_muted
-> Added a new stream_msg_fixture in conftest.py as msg_fixture was present for private messages but not for stream. And the same fixture has been used in added tests.

@zulipbot zulipbot added the size: XL [Automatic label added by zulipbot] label Feb 20, 2023
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Subhasish-Behera Thanks for looking at this 👍

I left some feedback inline, which I think mostly matches the feedback I gave in the stream, but of course more specific in nature :)

Certainly while this is under development it's fine to keep it as a separate test. As the PR develops you may find it's increasingly similar to what the other test does and can be combined - or not. Regarding specific points:

  • I'm aware the muted aspect is distinct from the other test right now, but it's possible that we need to incorporate handling muted streams/topics there too, as a separate improvement.
  • As with this PR, it's good to focus on the specific change rather than 'in the future' - unless you're going to include it in a commit straight after! So considering muted users to be an obstacle right now is not important.

As I noted, you should be able to simply use the stream_msg_template fixture. I'd also be interested as to what happened with using the general fixture; the similar test function has logic in the test that translates from types_when_notify_called to a variable, to enable testing the title, but I don't think that should affect the logic - and should probably be in another test.

tests/conftest.py Outdated Show resolved Hide resolved
Comment on lines 2053 to 2089
"user_id",
"flags",
"visual_notification_status",
"display_recipient",
"subject",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_id, flags, display_recipient and subject are the same through all the test cases you have, at least so far. For that reason it's easier to omit them from the parametrize and focus on the variables that do change - that makes it easier to identify why each test case relates to specific values. The constant values you can leave as defaults based on the fixture, or if they don't work for you for some reason, set them explicitly (and say why).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included user_id by seeing the model.user_id = user_id of test_notify_users_calling_msg_type but I will be removing user_id totally(as it is not used).
And set the rest of them as you suggested.

tests/model/test_model.py Outdated Show resolved Hide resolved
tests/model/test_model.py Outdated Show resolved Hide resolved
tests/model/test_model.py Outdated Show resolved Hide resolved
zulipterminal/model.py Outdated Show resolved Hide resolved
zulipterminal/model.py Outdated Show resolved Hide resolved
@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback area: notifications labels Mar 8, 2023
@zulipbot
Copy link
Member

zulipbot commented Mar 8, 2023

Hello @zulip/server-notifications members, this pull request was labeled with the "area: notifications" label, so you may want to check it out!

@neiljp neiljp changed the title model/test_model/conftest : Notify when a message with alert word is received Notify when a message with alert word is received Mar 8, 2023
@Subhasish-Behera Subhasish-Behera changed the title Notify when a message with alert word is received [WIP] Notify when a message with alert word is received Mar 16, 2023
Copy link
Collaborator

@mounilKshah mounilKshah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works just as per expectations on my local machine. I haven't gone through the automated tests yet, but upon manually testing it, everything seemed to work fine 👍

Copy link
Member

@theViz343 theViz343 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! @Subhasish-Behera I've tested it manually and it seems to work great :)

tests/model/test_model.py Outdated Show resolved Hide resolved
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: XL [Automatic label added by zulipbot] labels Sep 8, 2023
In the notify_user function a condition of "has_alert_word" is added
which also checks if stream/topic is muted(unlike
mentions,wild-card_mentions).

Changed the existing test function test_notify_users_calling_msg_type.
Added the case for notificaiton for all private messages. Apart from
that added two parameters is_topic_muted and is_stream_muted.
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Subhasish-Behera Thanks for updating this - I left some feedback now you have extended/combined the tests 👍

tests/model/test_model.py Show resolved Hide resolved
tests/model/test_model.py Show resolved Hide resolved
tests/model/test_model.py Show resolved Hide resolved
tests/model/test_model.py Show resolved Hide resolved
zulipterminal/model.py Show resolved Hide resolved
@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Oct 4, 2023
Copy link
Collaborator

@mounilKshah mounilKshah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this on my local machine and it worked as per expectations. Looks good to me. I have left feedback for the code written to assign value to recipient variable. Apart from Neil's comments, this is something that can be looked into.

zulipterminal/model.py Show resolved Hide resolved
@mounilKshah mounilKshah added enhancement New feature or request and removed PR needs mentor review labels Oct 24, 2023
@neiljp neiljp added missing feature: user A missing feature for all users, present in another Zulip client and removed enhancement New feature or request labels Apr 22, 2024
@neiljp neiljp added PR completion candidate PR with reviews that may unblock merging and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels May 11, 2024
@neiljp
Copy link
Collaborator

neiljp commented May 13, 2024

I'm following up on this now.

@neiljp neiljp removed the PR completion candidate PR with reviews that may unblock merging label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: notifications missing feature: user A missing feature for all users, present in another Zulip client PR replaced by another PR size: L [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants