mirror of https://github.com/zulip/zulip.git
outgoing webhooks: Send additional useful data.
This adds the fields `trigger` and `service_email` to each message event dispatched by outgoing webhook bots. `trigger` will be used by the Botserver to determine if a bot is mentioned in the message. `service_email` will be used by the Botserver to determine by which outgoing webhook bot the message should be handled.
This commit is contained in:
parent
cc0d0b55f1
commit
7a8c1ec9dc
|
@ -58,7 +58,9 @@ class GenericOutgoingWebhookService(OutgoingWebhookServiceInterface):
|
|||
'request_kwargs': {}}
|
||||
request_data = {"data": event['command'],
|
||||
"message": event['message'],
|
||||
"token": self.token}
|
||||
"bot_email": self.user_profile.email,
|
||||
"token": self.token,
|
||||
"trigger": event['trigger']}
|
||||
return rest_operation, json.dumps(request_data)
|
||||
|
||||
def process_success(self, response: Response,
|
||||
|
|
|
@ -8,7 +8,7 @@ from requests.models import Response
|
|||
from zerver.lib.outgoing_webhook import GenericOutgoingWebhookService, \
|
||||
SlackOutgoingWebhookService
|
||||
from zerver.lib.test_classes import ZulipTestCase
|
||||
from zerver.models import Service
|
||||
from zerver.models import Service, get_realm, get_user
|
||||
|
||||
class TestGenericOutgoingWebhookService(ZulipTestCase):
|
||||
|
||||
|
@ -16,13 +16,15 @@ class TestGenericOutgoingWebhookService(ZulipTestCase):
|
|||
self.event = {
|
||||
u'command': '@**test**',
|
||||
u'message': {
|
||||
'content': 'test_content',
|
||||
}
|
||||
'content': '@**test**',
|
||||
},
|
||||
u'trigger': 'mention',
|
||||
}
|
||||
self.bot_user = get_user("outgoing-webhook@zulip.com", get_realm("zulip"))
|
||||
self.handler = GenericOutgoingWebhookService(service_name='test-service',
|
||||
base_url='http://example.domain.com',
|
||||
token='abcdef',
|
||||
user_profile=None)
|
||||
user_profile=self.bot_user)
|
||||
|
||||
def test_process_event(self) -> None:
|
||||
rest_operation, request_data = self.handler.process_event(self.event)
|
||||
|
|
Loading…
Reference in New Issue