mirror of
https://github.com/zulip/zulip.git
synced 2026-07-18 21:04:19 +08:00
message_send: Include service bots as UserMessage eligible.
Previously, service bots don't get UserMessage rows for new messages to optimize performance. This commit adds UserMessage row for service bots so that they behave more similarly to generic bots.
This commit is contained in:
parent
5910bfcaf9
commit
25f64a9a67
@ -443,10 +443,7 @@ def get_recipient_info(
|
||||
lambda r: not r["enable_offline_push_notifications"]
|
||||
)
|
||||
|
||||
# Service bots don't get UserMessage rows.
|
||||
um_eligible_user_ids = get_ids_for(
|
||||
lambda r: not r["is_bot"] or r["bot_type"] not in UserProfile.SERVICE_BOT_TYPES,
|
||||
)
|
||||
um_eligible_user_ids = get_ids_for(lambda r: True)
|
||||
|
||||
long_term_idle_user_ids = get_ids_for(
|
||||
lambda r: r["long_term_idle"],
|
||||
|
||||
@ -1814,6 +1814,12 @@ class MessageAccessTests(ZulipTestCase):
|
||||
)
|
||||
self.assert_length(filtered_messages, 4)
|
||||
|
||||
# Test private message access for service bot
|
||||
service_bot = self.example_user("outgoing_webhook_bot")
|
||||
self.subscribe(service_bot, stream_name)
|
||||
filtered_messages = self.assert_bulk_access(service_bot, more_message_ids, stream, 6, 2)
|
||||
self.assert_length(filtered_messages, 4)
|
||||
|
||||
# Verify an exception is thrown if called where the passed
|
||||
# stream not matching the messages.
|
||||
other_stream = get_stream("Denmark", unsubscribed_user.realm)
|
||||
@ -1855,6 +1861,12 @@ class MessageAccessTests(ZulipTestCase):
|
||||
filtered_messages = self.assert_bulk_access(unsubscribed_user, message_ids, stream, 4, 1)
|
||||
self.assert_length(filtered_messages, 2)
|
||||
|
||||
# Test public message access for service bot
|
||||
service_bot = self.example_user("outgoing_webhook_bot")
|
||||
self.subscribe(service_bot, stream_name)
|
||||
filtered_messages = self.assert_bulk_access(service_bot, message_ids, stream, 4, 1)
|
||||
self.assert_length(filtered_messages, 2)
|
||||
|
||||
|
||||
class PersonalMessagesFlagTest(ZulipTestCase):
|
||||
def test_is_private_flag_not_leaked(self) -> None:
|
||||
|
||||
@ -1382,13 +1382,6 @@ class StreamMessagesTest(ZulipTestCase):
|
||||
realm = get_realm("zulip")
|
||||
subscribers = self.users_subscribed_to_stream(stream_name, realm)
|
||||
|
||||
# Outgoing webhook bots don't store UserMessage rows; they will be processed later.
|
||||
subscribers = [
|
||||
subscriber
|
||||
for subscriber in subscribers
|
||||
if subscriber.bot_type != UserProfile.OUTGOING_WEBHOOK_BOT
|
||||
]
|
||||
|
||||
old_subscriber_messages = list(map(message_stream_count, subscribers))
|
||||
|
||||
non_subscribers = [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user