A simple chat server for maya's stream.
 
 
 
 
 
Go to file
~erin d5be76624c
Lowercase all incoming names
2021-07-23 13:05:56 -04:00
frontend Frontend: added more to index.html 2021-07-23 01:05:11 -07:00
src Lowercase all incoming names 2021-07-23 13:05:56 -04:00
.gitignore Remove deprecated functions 2021-07-23 09:48:57 -04:00
CHANGELOG.md Improve API docs 2021-07-23 10:35:14 -04:00
Cargo.lock Improve API docs 2021-07-23 10:35:14 -04:00
Cargo.toml Improve API docs 2021-07-23 10:35:14 -04:00
LICENSE Add Luna to license 2021-07-19 06:39:13 -04:00
README.md Fixup readme format? 2021-07-23 11:29:42 -04:00
Rocket.toml Lowercase all incoming names 2021-07-23 13:05:56 -04:00
message.zsh Remove deprecated functions 2021-07-23 09:48:57 -04:00

README.md

Chat Registration System

A simple chat system for built for maya's livestream. Provides a simple API for user authentication, and chat functions. Frontend & backend code stored here.

Auth API Documentation

Most API functions will return JSON in the following format:

status: either ok if action succeeded, or fail otherwise.

reason: More info about why the action failed.

Register & Login:

POST /api/register with JSON body values of: name, pin, pronouns.

Will return JSON with status and reason.

POST /api/login with JSON body values of: name, pin.

Will return JSON with status and reason.

Will set a private cookie named token which is used for authentication.

Change User Information

User information such as name, pin, and pronouns, can be changed currently one at a time.

POST /api/change with JSON body values of: name, changed_event, new_event.

name the user's current username. used for authentication.

changed_event which event to change. value can be one of: Name, Pin, Pronouns.

new_event the new value for the changed event.

User is authenticated via token.

Check if User is Still Logged in

Instead of having to save the pin and re-login every time to check wether they're logged in, you can just check via the token.

GET /api/token/<name> where <name> is the current username.

Will return JSON with status and reason.

Logout

This API will remove the cookie from the client, as well as invalidating the token serverside.

POST /api/logout with JSON body values of: name.

Will use the current token as authentication.

Will return JSON with status and reason.

Get Info About A User

This API will return info about a user on success.

GET /api/users/<name>

On success returns JSON in format:

status: ok
user:
	name: user's name
	pronouns: user's pronouns
	role: the users role, one of either 'Normal', 'Moderator', or 'Admin'

eg:

{
status: "ok",
user: {
	name: "example",
	pronouns: "they/them",
	role: "Normal",
},
}

Chat API Documentation

POST /api/message/send {"name":"username","body":"message body"} Post a message with JSON body values of: name & body

Will return JSON with status and reason.

GET /api/message/messages.json Returns a json file of all the messages

Chat Planning

Clientside js will register & check login of users, if login is correct will ask for a random token. Backend will generate token, store it, and then send it to the client to set as a cookie. Whenever user sends a message, client will send message & token and backend will check if token matches.

To-Do:

  • Basic auth API
  • Return json instead of string
    • "status" shows wether request was succesful or not, either "ok" or "fail"
    • "reason" is for more details, mainly just for debugging?
  • Basic messaging system
    • Finish up chat::create_message()
    • Create chat::fetch_messages()
    • Use unix timestamp for date
    • Create chat::delete_message()
  • Switch to using sled database to store users
    • Error handling
  • Token generation & storage
    • Sets cookie
    • Store token in json
    • Have cookie expire
    • Remove old cookie
    • Use token for most stuff
    • Logout API
    • Fail on NULL token
  • Pronouns
    • Set pronouns
    • Change pronouns
  • make changed_event Enum, use token instead of pin
  • Some form of plural support?
  • User management (banning, etc.)
    • User roles (admin, mod, etc.)
    • Commands to affect users
  • Blacklist words from chat/names
  • More advanced chat features
    • Different types of message events? eg. default, announcement, command
    • Types will display differently? eg. announcements pinned to top?
    • Have different commands?
    • Emote support?