-
Notifications
You must be signed in to change notification settings - Fork 4
Internals: Forum
We use Google's Firebase to handle user authentication, and post storage for the forum.
Firebase Auth handles sigining in with Google and GitHub. We store registration codes in the Firebase Realtime Database. Forum posts are stored in Cloud Firestore.
When a user logs in for the first time, they are asked to provide a registration code which is used to verify that they are a competitor of HR Robocon. When a user submits a code it is checked against codes stored in the Realtime Database.
NOTE: This check happens on the client side but it really shouldn't. Perhaps make this a Firebase/Netlify Function?
| Code Value | What Happens? | User Verified? |
|---|---|---|
| > 0 | 1 subtracted from value | Yes |
| = 0 | Code expired | No |
| = -10 | Code never expires | Yes |
When a user posts something on the forum, we receive a notification in our Discord server. This is done through a Netlify Lambda Function. These are basically HTTP endpoints that run server side JavaScript code when invoked. The source code for this function can be found in .vuepress/functions/src.
After cloning this repository locally, and installing npm dependencies, you can run npm run dev:functions to start a lambda server locally for development.
If the user has posted an answer/reply, an email notification is also sent to everyone else whose ever posted in the thread. This is done through Mailjet.
In a similar way to the blog, there's a README.md file using ForumLayout.vue for the thread list page. Because individual threads and their contents are not known before hand, they cannot be easilly server rendered with VuePress. The .vuepress/enhanceApp.js file solves this problem by registering a thread route with the UID of the post in the URL. When a user requests this route, the app fetches the data for that thread from Firebase and renders the page on the client side.