FEATURE: Allow custom query parameters in Discord webhooks (#236)

This commit is contained in:
Melaine 2024-12-02 16:49:28 +01:00 committed by GitHub
parent 71dcae5365
commit 3450662e68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -79,8 +79,12 @@ module DiscourseChatIntegration
end
def self.trigger_notification(post, channel, rule)
# Splitting the URL in order to support custom query parameters (e.g. thread_id=1234)
splitted_url = channel.data["webhook_url"].split("?")
# Adding ?wait=true means that we actually get a success/failure response, rather than returning asynchronously
webhook_url = "#{channel.data["webhook_url"]}?wait=true"
webhook_url = "#{splitted_url[0]}?wait=true"
webhook_url += "&" + splitted_url[1] if splitted_url.length > 1
message = generate_discord_message(post)
response = send_message(webhook_url, message)