-
Notifications
You must be signed in to change notification settings - Fork 1
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
baseapp-chats [BA-2236]: Change message subscription to not publish to sender #245
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Some context: I changed the new message subscription so that the sender of the message is not getting an update through the new message subscription. Before, the sender of the message received the new message both as payload to the mutation they send and through the subscription. This was no problem since relay automatically took care of "merging" the two (in this case, just ignoring the one that arrived later). Using optimistic updates when committing the send message mutation on the frontend, these updates are only rolled back when the mutation for this payload is received, but not when the new message subscription triggers. So if the subscription reached the client before the payload, then there was a UI spike of the message showing up twice (once through the optimistic update and once through the subscription, which could not be "merged" by relay as the optimistic update has no id set) until the payload arrived (which rolled back the optimistic update and could be merged with the subscription response). The PR fixes this behavior by not publishing the new message to its sender in the subscription. |
baseapp-chats/baseapp_chats/tests/test_graphql_subscriptions.py
Outdated
Show resolved
Hide resolved
45db7c4
to
1fd82f8
Compare
|
): | ||
return [] | ||
|
||
if not database_sync_to_async(room.participants.filter(profile=profile).exists)(): |
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.
please lets change this to be like before:
if not database_sync_to_async(room.participants.filter(profile=profile).exists)(): | |
if not database_sync_to_async(user.has_perm)( | |
"baseapp_chats.view_chatroom", room | |
) |
it not only checks if the person is a member but also if he is blocked or not
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.
@nossila: I am not sure whether we necessarily need to check this again since it is only for real-time updates about sent messages. When a message is sent, we check for permission (including blocks), so I think it'd be reasonable to assume that we can always synchronize messages sent on the server with the client without checking again. Also user.has_perm
only checks whether some profile accessible to user
is in the chatroom, but not the given profile
. I'll switch to
if not database_sync_to_async(room.participants.filter(profile=profile).exists)()
or not database_sync_to_async(user.has_perm)("baseapp_chats.view_chatroom", room):
...
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 think it would be good to rethink some of these permissions. E.g. all chat features are related to profiles, not users. So permissions like view_chatroom
should use the profile
, not just user
. Also, I am currently not allowed to view a chat if there is any user blocked by me on a chat. For large chat groups, this might not make much sense; I might even lose access to all previous messages from a chat if such a user joins the group.
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.
@tsl-ps2 you are completely right! We should rethink those permissions.
8727981
to
3553905
Compare
Acceptance Criteria
Context
Loom: https://www.loom.com/share/9bcd130aa70f476fa3cebbb53ba338e0
Business Rules
Given I input text into the message box, when I send the message, then the message box should become empty immediately
Given I have sent a message, the message should be displayed in the chat history quickly.
If a message fails to be send, just remove the message from the chat history.
Disable the send button until we know the message sending request was resolved, either successful or failed,
Approvd
https://app.approvd.io/silverlogic/BA/stories/38918