-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Use user_id
s as message destinations
#1006
Conversation
eb6f2da
to
55a2920
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 taking this up. This seems to work well and the changes look good to me as well! 👍
With user_id
s in place and given that we could build back recipient_email
s from the user_id
s, should we drop the recipient_email
attribute in boxes.py?
We could potentially squash the changes pre-merge. I have left a few minor in-line comments.
829d629
to
ccd8ef1
Compare
Thanks for the review, and the educative point about the AAA pattern, @preetmishra! |
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 update! The last commit is a good cleanup. We could label it as a refactor:
. Overall, the PR looks good to me! 👍
There are two concerns that I would like to point out:
- When opening a saved draft with an invalid user email, the
To:
field renders empty. - When sending a PM to an invalid recipient, the footer message gets updated to "Cannot send message without specifying recipients." than "Invalid recipient(s) - ...".
This is likely because you're skipping out invalid emails while creating the user_ids from the regex grepped emails in update_recipients()
.
ccd8ef1
to
8826323
Compare
4ef125d
to
39acc15
Compare
This PR is now up-to-date @preetmishra. Thanks to #937, both of your concerns should no longer persist since we restrict the user from sending a message and saving a draft too if the recipients are invalid. Only if the recipients are valid, they will be updated in |
39acc15
to
34ae36b
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.
I've made a couple of changes since the #937 merge, I'm leaving my thoughts on these below, please let me know if you think they need changes.
34ae36b
to
355e526
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.
355e526
to
d1a7418
Compare
Thanks for the reviews, @preetmishra! |
d1a7418
to
7361354
Compare
7361354
to
493eaf2
Compare
493eaf2
to
06ca8cf
Compare
Hello @zulip/server-refactoring members, this pull request was labeled with the "area: refactoring" label, so you may want to check it out! |
Prior to this commit, we updated only `recipient_emails` using the update_recipient_emails() method post changes in the private_box_view header. This was because delivery emails were used as message destinations and needed updating before performing a message-related action. This commit modifies this method to also update the recipients' user_ids, maintaining synchrony between the recipient email and user_id lists. Tests added.
This is a preparatory commit that adds a fixture for model's user_id_email_dict to facilitate using the dict in multiple tests that need to look an email up given the user_id.
This commit migrates from using delivery emails as message destinations to using `user_id`s instead. The abstraction between the narrow model and the Composition API type is maintained by modifying the corresponding connections to the narrow model such that the delivery emails are still in use in the narrow model currently, making this a message-destination-only change. The commit focuses on changing the type of the `recipients` parameter of the PrivateComposition class to List[int] instead of the previous List[str]. `send_private_message` now expects a List of `int`s as well. Tests updated.
Prior to this commit, everytime the private_box_view had to be initiated with recipients, the emails of the recipients was also requested along with their user_ids. This commit removes that parameter and hence makes the private_box_view reliant on only the list of `user_id`s received. Tests updated.
06ca8cf
to
c712469
Compare
@prah23 I made a minor test change and commit text change and am merging this now - thanks! 🎉 Other than the ongoing migration towards ids and improving the narrow structure, I expect we'll want to wrap the access to the user_id_email_dict with a method, but this refactoring is useful to have right now and we can build on this 👍 |
There are 4 commits to this PR:
update_recipient_emails()
toupdate_recipients()
, also updating the recipients'user_id
s now, which is a preparatory step for the third commit. A test has also been added for this method.user_id_email_dict
as a prep commit for the third commit.user_id
s instead. Tests updated.emails
parameter fromprivate_box_view()
. Tests updated.The abstraction between the narrow model and the Composition API type is maintained by modifying the corresponding connections to the narrow model such that the delivery emails are still in use in the narrow model currently, making this a message-destination-only change.
This change also serves as a prelude to the larger scale narrow model refactoring, which needs
Model
and narrow structure abstraction.This would accommodate the first point under #965.