Skip to content

Adds Discord Embed on Form Submission#39

Merged
jb3 merged 15 commits into
mainfrom
discord-webhook
Dec 21, 2020
Merged

Adds Discord Embed on Form Submission#39
jb3 merged 15 commits into
mainfrom
discord-webhook

Conversation

@HassanAbouelela
Copy link
Copy Markdown
Contributor

@HassanAbouelela HassanAbouelela commented Dec 18, 2020

Closes this notion ticket.

Important to do note

The webhook links to a frontend URL that displays the form response, which is currently not supported. The frontend URL was added to environment variables in preparation, but the actual viewing URL will have to be added in place of the placeholder once available.

Description

Implements discord webhooks for form submission. This allows forms to have an optional webhook, that will contain information about submissions, along with an optional message.

Screenshots

image
Regular authenticated form.


image
User object is unavailable (likely due to the form not requiring login).


image

Message example. Can add mentions for users and roles (See example in schema).

Adds webhook option on form creation, and adds validation. Updates
`SCHEMA.md`.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Fixes a bug that would force you to do a dummy webhook object when
creating a form. Fixes a bug that would force you to add an empty
message for webhooks.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Builds and sends a discord webhook on form submission.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>

# Conflicts:
#	backend/routes/forms/submit.py
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
# Conflicts:
#	backend/routes/forms/submit.py
@HassanAbouelela HassanAbouelela added P2 Medium priority tasks. area: form submission Code relating to the response submission to forms backend. type: feature A new feature that should be added to the application. labels Dec 18, 2020
@ghost ghost added the needs 1 approval label Dec 18, 2020
Copy link
Copy Markdown
Member

@jb3 jb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review pass. Functionality all looks good and is what I was expecting, nice work!

Comment thread SCHEMA.md Outdated
Comment thread backend/models/form.py Outdated
Comment thread backend/routes/forms/submit.py Outdated
Comment thread backend/routes/forms/submit.py Outdated
Comment thread backend/routes/forms/submit.py Outdated
Comment thread backend/routes/forms/submit.py
Co-authored-by: Joe Banks <joseph@josephbanks.me>
Uses builtin user formatting for username and mentions.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Moves the validation code of webhook urls to an async function that is
called by the route, to avoid blocking code.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Adds better parsing and formatting for webhook message variables, and
documents them in SCHEMA.md.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>

# Conflicts:
#	backend/routes/forms/submit.py
Copy link
Copy Markdown
Member

@jb3 jb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work, well done!

Copy link
Copy Markdown
Member

@jb3 jb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving for policy bot!

@jb3 jb3 merged commit 443a322 into main Dec 21, 2020
@jb3 jb3 deleted the discord-webhook branch December 21, 2020 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: form submission Code relating to the response submission to forms backend. P2 Medium priority tasks. type: feature A new feature that should be added to the application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants