Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

worker: Flag messages processed by embedded bot.

PieterCKa995510f0c98
diff --git a/zerver/tests/test_service_bot_system.py b/zerver/tests/test_service_bot_system.py
index 1f0ac3f8870..cf2045c4459 100644
--- a/zerver/tests/test_service_bot_system.py
+++ b/zerver/tests/test_service_bot_system.py
@@ -608,13 +608,12 @@ class TestServiceBotEventTriggers(ZulipTestCase):
self.assertFalse(mock_queue_event_on_commit.called)
@responses.activate
- def test_flag_messages_outgoing_webhook_bot_has_processed(self) -> None:
+ @for_all_bot_types
+ def test_flag_messages_service_bots_has_processed(self) -> None:
"""
- Verifies that once an event has been processed by the outgoing webhook
- bot's queue processor, the message is marked as processed (flagged with `read`).
+ Verifies that once an event has been processed by the service bot's
+ queue processor, the message is marked as processed (flagged with `read`).
"""
- self.bot_profile.bot_type = UserProfile.OUTGOING_WEBHOOK_BOT
- self.bot_profile.save()
sender = self.user_profile
recipients = [self.user_profile, self.bot_profile, self.second_bot_profile]
responses.add(
diff --git a/zerver/worker/embedded_bots.py b/zerver/worker/embedded_bots.py
index 7660cc30101..552bad63bd3 100644
--- a/zerver/worker/embedded_bots.py
+++ b/zerver/worker/embedded_bots.py
@@ -6,7 +6,12 @@ from typing import Any
from typing_extensions import override
from zulip_bots.lib import extract_query_without_mention
-from zerver.lib.bot_lib import EmbeddedBotHandler, EmbeddedBotQuitError, get_bot_handler
+from zerver.lib.bot_lib import (
+ EmbeddedBotHandler,
+ EmbeddedBotQuitError,
+ do_flag_service_bots_messages_as_processed,
+ get_bot_handler,
+)
from zerver.models import UserProfile
from zerver.models.bots import get_bot_services
from zerver.models.users import get_user_profile_by_id
@@ -53,3 +58,4 @@ class EmbeddedBotWorker(QueueProcessingWorker):
)
except EmbeddedBotQuitError as e:
logging.warning("%s", e)
+ do_flag_service_bots_messages_as_processed(user_profile, [message["id"]])