mirror of https://github.com/zulip/zulip.git
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:
parent
6c4343c86d
commit
c0df049a18
|
@ -71,8 +71,13 @@ class GenericOutgoingWebhookService(OutgoingWebhookServiceInterface):
|
|||
return None
|
||||
|
||||
if "response_string" in response_json:
|
||||
content = str(response_json['response_string'])
|
||||
success_data = dict(response_string=content)
|
||||
response_string = str(response_json['response_string'])
|
||||
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 None
|
||||
|
@ -257,11 +262,15 @@ def process_success_response(event: Dict[str, Any],
|
|||
if success_data is None:
|
||||
return
|
||||
|
||||
success_message = success_data.get('response_string')
|
||||
if success_message is None:
|
||||
return
|
||||
response_string = success_data.get('response_string')
|
||||
if response_string:
|
||||
# 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']
|
||||
message_info = event['message']
|
||||
|
|
Loading…
Reference in New Issue