aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/forms/submit.py
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2020-12-21 04:41:27 +0300
committerGravatar Hassan Abouelela <[email protected]>2020-12-21 04:41:27 +0300
commit9d8ca77b1f18891cef88e9b8235b41172067f9b0 (patch)
tree4f9ba4026002a9e69b916bb73c9aa9fce02cf758 /backend/routes/forms/submit.py
parentAdds Missing Annotation (diff)
Adds and Documents Webhook Message Variables
Adds better parsing and formatting for webhook message variables, and documents them in SCHEMA.md. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'backend/routes/forms/submit.py')
-rw-r--r--backend/routes/forms/submit.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py
index 3b22155..5c0cfdd 100644
--- a/backend/routes/forms/submit.py
+++ b/backend/routes/forms/submit.py
@@ -197,6 +197,18 @@ class SubmitForm(Route):
# Set hook message
message = form.meta.webhook.message
if message:
+ # Available variables, see SCHEMA.md
+ ctx = {
+ "user": mention,
+ "response_id": response.id,
+ "form": form.name,
+ "form_id": form.id,
+ "time": response.timestamp,
+ }
+
+ for key in ctx:
+ message = message.replace(f"{{{key}}}", str(ctx[key]))
+
hook["content"] = message.replace("_USER_MENTION_", mention)
# Post hook