A simple chat server for maya's stream.
 
 
 
 
 
Go to file
Luna 69b7259571 Frontend: added more to index.html 2021-07-23 01:05:11 -07:00
frontend Frontend: added more to index.html 2021-07-23 01:05:11 -07:00
src Switch to registering with JSON data 2021-07-22 15:01:41 -04:00
.gitignore Switch to private cookies, and make other cookie improvements 2021-07-22 11:44:31 -04:00
CHANGELOG.md Add token info in changelog 2021-07-22 13:06:22 -04:00
Cargo.lock Fix error in chat.rs 2021-07-22 13:39:24 -04:00
Cargo.toml Use session_token for most actions, fail on NULL token 2021-07-22 13:01:30 -04:00
LICENSE Add Luna to license 2021-07-19 06:39:13 -04:00
README.md Switch to registering with JSON data 2021-07-22 15:01:41 -04:00
message.zsh Store only username in messages.json to not leak data 2021-07-22 11:52:29 -04:00

README.md

Chat Registration System

The basic backend code needed to register & login to a chat system (to be built). Send it the unhashed username and pin, and it'll store it in the database with the pin hashed with SHA1.

API Documentation

POST /api/register {"name":"<username>","pin":"<pin>","pronouns":"<pronouns>"} Register a user if they don't already exist

POST /api/register/<name>/<pin>/<pronouns> Register the username with the pin provided if it doesn't already exist Returns status & reason json.

GET /api/users/<name> Check if the user exists Returns either

{ "status": "fail", "reason": "user not found", }

or

{ "status": "ok", "user": { "name": "<name>", "pronouns": "<pronouns>", }, }

GET /api/token/<name> Check if the current token matches the user provided

GET /api/users/<name>/<pin> Check if the user exists, and if the pin provided matches Returns status & reason json.

POST /api/users/change {"name":"<username>","pin":"<pin>","changed_event":"name/pin/pronouns","new_event":"<new name/pin/pronouns>" Change a users details via a json post.

eg. POST /api/users/change {"name":"example","pin":"10","changed_event":"name","new_event":"test" to change the user "example"'s name to "test"

DEPRECATED POST /api/users/change/<name>/<pin>/<new-name>/<new-pin> Change a users pin/name Returns status & reason json.

POST /api/logout {"name":"<username>"} to logout a user if the token matches

Chat Documentation

POST /api/message/send {"name":"username","body":"message body","date":"yyyy-mm-dd"} Post a json message. Returns status & reason json.

GET /api/message/messages.json Get 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
    • Multiple sets of pronouns
  • Some form of plural support?
  • User management (banning, etc.)
  • Blacklist words from chat/names
  • More advanced chat features
    • Different types of message events? eg. default, announcement, command
    • Emote support?