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
notifications: Fix leaking of private stream msgs sent before subscribing. #10086
notifications: Fix leaking of private stream msgs sent before subscribing. #10086
Conversation
zerver/models.py
Outdated
@@ -1558,6 +1558,12 @@ def __str__(self) -> str: | |||
class UserMessage(AbstractUserMessage): | |||
message = models.ForeignKey(Message, on_delete=CASCADE) # type: Message | |||
|
|||
def get_usermessage_by_msg_id(user_profile: UserProfile, message_id: int) -> Optional[UserMessage]: |
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'd spell it by_message_id
, but otherwise looks good.
zerver/lib/message.py
Outdated
@@ -492,39 +492,48 @@ def access_message(user_profile: UserProfile, message_id: int) -> Tuple[Message, | |||
|
|||
user_message = get_usermessage_by_msg_id(user_profile, message_id) | |||
|
|||
if has_message_access(user_profile, message, user_message): | |||
return (message, user_message) | |||
else: |
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.
This else is unnecessary
These look reasonable |
da77244
to
301d253
Compare
4d237c2
to
4fc9be7
Compare
@timabbott I've updated the PR up to v1, so only optimization is left. |
4fc9be7
to
8fab5b3
Compare
build failing due to another issue, which is fixed in #10093 |
8fab5b3
to
288ceab
Compare
288ceab
to
fb3eead
Compare
@@ -446,10 +446,14 @@ def handle_missedmessage_emails(user_profile_id: int, | |||
for recipient_subject, msgs in messages_by_recipient_subject.items() | |||
} | |||
|
|||
from zerver.lib.message import bulk_access_messages | |||
|
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.
This import to avoid a circular loop is avoidable with some refactoring. I added 6bbffe0 to do the appropriate refactor to avoid this (I think it's cleaner this way anyway).
Heads up @shubhamdhama, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
I merged this, after adding 6bbffe0 to avoid the circular import workaround. Thanks @shubhamdhama! For working on the optimization piece, I think we can just add a wrapper for
|
Here I've suggested some refactors, feedback about how they sound to other. I'm working on top of it to fix the issue 9834.