mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
test_classes: Add functions to get read/unread user IDs for a message.
This commit adds two functions in `zerver/lib/test_classes.py`. The first function returns the `user_ids` of users for whom the message is marked as unread. The second function returns the `user_ids` of users for whom the message is marked read, based on the `message_id`.
This commit is contained in:
committed by
Tim Abbott
parent
934042d47e
commit
3d33a05455
@@ -1264,6 +1264,22 @@ Output:
|
||||
data = self.get_messages_response(anchor, num_before, num_after, use_first_unread_anchor)
|
||||
return data["messages"]
|
||||
|
||||
def get_user_ids_for_whom_message_read(self, message_id: int) -> set[int]:
|
||||
user_ids = set(
|
||||
UserMessage.objects.filter(message_id=message_id)
|
||||
.extra(where=[UserMessage.where_read()]) # noqa: S610
|
||||
.values_list("user_profile_id", flat=True)
|
||||
)
|
||||
return user_ids
|
||||
|
||||
def get_user_ids_for_whom_message_unread(self, message_id: int) -> set[int]:
|
||||
user_ids = set(
|
||||
UserMessage.objects.filter(message_id=message_id)
|
||||
.extra(where=[UserMessage.where_unread()]) # noqa: S610
|
||||
.values_list("user_profile_id", flat=True)
|
||||
)
|
||||
return user_ids
|
||||
|
||||
def users_subscribed_to_stream(self, stream_name: str, realm: Realm) -> list[UserProfile]:
|
||||
stream = Stream.objects.get(name=stream_name, realm=realm)
|
||||
recipient = Recipient.objects.get(type_id=stream.id, type=Recipient.STREAM)
|
||||
|
||||
Reference in New Issue
Block a user