Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TIT8 committed Nov 12, 2023
1 parent 5151698 commit 06dd1b9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

Go api for Triennale-elettronica-polimi "e-mail us" [section](https://triennale-elettronica-polimi.netlify.app/contact/#e-mail-us) with [friendly captcha](https://friendlycaptcha.com/) protection.

It sends message to a Telegram-bot and it's hosted on [flyio](https://fly.io/), automatically deployed on master changes via [Github Actions](https://github.com/TIT8/go-api/actions/workflows/fly.yml).
## How it works

1.   It receives the form data submitted via [javascript POST request](https://github.com/valerionew/triennale-elettronica-polimi/blob/master/layouts/shortcodes/contact.html#L58) from the website.
2.   Check if the data body isn't too big and malformed.
3.   Check if the captcha submission was successful. If not, send back to the client the captcha error and jump to step 6.
4.   It sends message to a Telegram BOT which will write to a private channel ([here](https://stackoverflow.com/questions/33858927/how-to-obtain-the-chat-id-of-a-private-telegram-channel) how).
5.   Check if the communication with the Telegram API was successful.
6.   Write the result on the HTTP header (200 or 406) and on the responsse to the javascript client.
7.   The Javascript client will [handle the response](https://github.com/valerionew/triennale-elettronica-polimi/blob/master/layouts/shortcodes/contact.html#L73) and inform the user about the operation (inserting text on HTML).

It's hosted on **[flyio](https://fly.io/)**, automatically deployed on master changes via [Github Actions](https://github.com/TIT8/go-api/actions/workflows/fly.yml). Try it sending a GET request to _https://formapi.fly.dev_.

## Thanks

I would like to express my gratitude to [Marius](https://medium.com/geekculture/how-to-use-go-to-send-telegram-messages-to-your-phone-a819bdf7f35c) for his well-explained blog post, which served as an inspiration for my API.

0 comments on commit 06dd1b9

Please sign in to comment.