mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 14:08:23 +00:00
Allow "content" from outgoing webhooks.
We now allow outgoing webhooks to provide us a "content" field, which is probably a more guessable name than "response_string", particularly for folks that use our other bot-related APIs. And we don't modify content as we do response_string, i.e. no "Success!" prefix. If we're not too concerned about backward compatibility, we can do a subsequent commit that makes "content" and "response_string" true synonyms and get rid of the "Success!" prefix, which was probably accidental to begin with.
This commit is contained in:
@@ -71,8 +71,13 @@ class GenericOutgoingWebhookService(OutgoingWebhookServiceInterface):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if "response_string" in response_json:
|
if "response_string" in response_json:
|
||||||
content = str(response_json['response_string'])
|
response_string = str(response_json['response_string'])
|
||||||
success_data = dict(response_string=content)
|
success_data = dict(response_string=response_string)
|
||||||
|
return success_data
|
||||||
|
|
||||||
|
if "content" in response_json:
|
||||||
|
content = str(response_json['content'])
|
||||||
|
success_data = dict(content=content)
|
||||||
return success_data
|
return success_data
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -257,11 +262,15 @@ def process_success_response(event: Dict[str, Any],
|
|||||||
if success_data is None:
|
if success_data is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
success_message = success_data.get('response_string')
|
response_string = success_data.get('response_string')
|
||||||
if success_message is None:
|
if response_string:
|
||||||
return
|
# For legacy reasons, we prepend "Success!"
|
||||||
|
content = "Success! " + response_string
|
||||||
|
else:
|
||||||
|
content = success_data.get('content')
|
||||||
|
|
||||||
content = "Success! " + success_message
|
if content is None:
|
||||||
|
return
|
||||||
|
|
||||||
bot_id = event['user_profile_id']
|
bot_id = event['user_profile_id']
|
||||||
message_info = event['message']
|
message_info = event['message']
|
||||||
|
|||||||
Reference in New Issue
Block a user