-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Enhance validation and check for bad/no recipients in PMs #937
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prah23 Thanks for the bugfix and looking into the PM validation 👍
Some comments inline, but also feel free to chat in the stream.
d70ea17
to
a2e71fa
Compare
2ee89e1
to
6e66b31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on it.
This looks good and works as expected. 👍
I suppose tests would be added after some more review and feedback?
6e66b31
to
d540143
Compare
6ced44d
to
b38054a
Compare
b38054a
to
02931f4
Compare
96c792c
to
327723d
Compare
@zulipbot remove "PR awaiting update" |
327723d
to
c0b072a
Compare
@zulipbot add "PR needs review" |
Thanks for the review, @neiljp! |
fbac681
to
11a20f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prah23 Thanks for responding to the minor points, and the restructure is a good first step - see if you can identify the others I pointed at 👍
bbe1581
to
70e15f9
Compare
70e15f9
to
dc6eeff
Compare
Thanks for your patience on this, @neiljp! |
dc6eeff
to
a247af1
Compare
Previously, a list of emails were expected as a parameter in the model helper `get_invalid_recipient_emails` which has been refactored to `is_valid_private_recipient` to abstract the processing of the list to `boxes.py` and rely on the model helper to verify each recipient individually. The model helper checks whether a given recipient email exists in the `user_dict` and returns the relevant boolean.
This commit extracts the current private message recipient validation into a helper method, `_validate_recipients_and_notify_invalid_ones`, that returns a bool, indicating whether or not, all of the recipient emails mentioned in the `to_write_box` are valid (returns False even on a single invalid email). The `CYCLE_COMPOSE_FOCUS` keypress now relies on this helper method to specify whether or not to continue with it's flow.
This commit modifies the validation helper method to assist with a more thorough validation of the recipients in the `to_write_box`. The `_tidy_valid_recipients_and_notify_invalid_ones` helper is used to extract individual recipients, discard any unnecessary text after the email and then call the `is_valid_private_recipient` helper from the model. The `is_valid_private_recipient` helper in `model.py` now also ensures that the name of the recipient extracted matches the corresponding name in the `user_dict`. Tests added.
Prior to this commit, private message recipients were only validated on `CYCLE_COMPOSE_FOCUS` keypresses. This commit extends the validation process to `SEND_MESSAGE` and `SAVE_AS_DRAFT` keypresses as well, to ensure valid recipients before any meaningful action occurs in the compose box. Tests added.
a247af1
to
7b75fca
Compare
This commit modifies the `invalid_recipients_error` message to also mention the keys used for autocompleting recipients, so the user is able to quickly reach the valid form of the intended recipients. Tests updated.
7b75fca
to
26743a0
Compare
@prah23 Thanks for the restructure - this has cleaner smaller commits now 👍 I just removed a duplicate assignment in the last commit and pushed to the PR before merging 🎉 |
Thanks for your patience! |
This PR adds a commit that refactors the
get_invalid_recipients_emails()
methodof the model to
check_recipient_validity()
which checks if therecipient's name and email match.
This commit follows this strategy:
The recipients' information is also tidied for all the valid recipients,
by formatting the information to fit the
name <email>
format.