14 months agoDo not re-use message IDs
B Tasker []
Do not re-use message IDs

Without this, polling breaks as we look for IDs > our last. When key re-use is permitted the latest ID may well be less than the most recent one we've seen

14 months agoImplement ability to leave room
B Tasker []
Implement ability to leave room

Room will get a message to note the user left

Command is /leave

14 months agoDon't repeatedly spam server went away messages
B Tasker []
Don't repeatedly spam server went away messages

14 months agoFix colouring.
B Tasker []
Fix colouring.

Messages sent by the local user should appear blue, whilst from other users should be green.

Had left the check using a global though, so the deciding factor for blue was - is the upstream user called "ben2"?

14 months agoOnly allow a user to poll for messages, or send messages for a room after they've actually joined it
B Tasker []
Only allow a user to poll for messages, or send messages for a room after they've actually joined it

14 months agoOlder messages will now be purged when a user joins the room
B Tasker []
Older messages will now be purged when a user joins the room

The aim of this is to prevent the new user from dumping out the entire stored history of a chat. Although the client will honour "last" they could conceivably override it to 0 and grab everything.

So, when they join, we now remove any messages older than 10 seconds.

At the moment, it's a little meaningless as you don't need to join in order to do pollMsg. That will obviously need to change.

14 months agoClient is no longer in a room by default, and must join by supplying username, roomname and room password
B Tasker []
Client is no longer in a room by default, and must join by supplying username, roomname and room password

Command format is

/join [user] [roomname] [password]

The password isn't currently used at all on either the front-end or the backend.

Backend component will, however, ensure that the user given is permitted to connect to the specified room.

If the user joins successfully a system message will be pushed into the room.

14 months agoSending a message from the client now works.
B Tasker []
Sending a message from the client now works.

Own messages will appear blue, whilst messages from other users are green.

Next step is probably to look at building in the join room functionality

14 months agoRegular poll now prints the messages as they should appear.
B Tasker []
Regular poll now prints the messages as they should appear.

What's missing at the moment is upstream user data - it's not in the current test payloads I'm using, so haven't put anything in to extract it yet. Once I've built the send message functionality into the interface I'll look at updating

14 months agoInterface now polls for new messages in the background
B Tasker []
Interface now polls for new messages in the background

With it running, if the following are run (in a seperate terminal) it correctly displays the expected output

curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"sendMsg","payload":"{\"roomName\":\"BenTest\", \"msg\":\"ENCRYPTED-DATA3\",\"user\":\"ben2\"}"}'
curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"sendMsg","payload":"{\"roomName\":\"BenTest\", \"msg\":\"ENCRYPTED-DATA4\",\"user\":\"ben2\"}"}'
curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"sendMsg","payload":"{\"roomName\":\"BenTest\", \"msg\":\"ENCRYPTED-DATA5\",\"user\":\"ben2\"}"}'

However, the caveat is that the test curls do not contain a JSON structure within the msg payload, so there's currently no functionality implemented to show time and sending user.

14 months agoAdding a poached urwid template to create the client interface
B Tasker []
Adding a poached urwid template to create the client interface

14 months agoImplemented ability to fetch all messages since last check.
B Tasker []
Implemented ability to fetch all messages since last check.

If you setup a room and stage some messages with the following:

# Create Room
curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"createRoom","payload":"{\"roomName\":\"BenTest\",\"owner\":\"ben\",\"passhash\":\"abcdefg\"}"}'

# Subscribe User
curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"inviteUser","payload":"{\"roomName\":\"BenTest\",\"user\":\"ben2\"}"}'

# Send a message
curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"sendMsg","payload":"{\"roomName\":\"BenTest\", \"msg\":\"ENCRYPTED-DATA\",\"user\":\"ben2\"}"}'

# Send another
curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"sendMsg","payload":"{\"roomName\":\"BenTest\", \"msg\":\"ENCRYPTED-DATA2\",\"user\":\"ben2\"}"}'

You can then fetch those messages with the following call

curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"pollMsg","payload":"{\"roomName\":\"BenTest\", \"mylast\":0,\"user\":\"ben2\"}"}'

This means we now have the basic components in place:

* Rooms can be created
* Users can be subscribed to the room
* Messages can be sent
* Clients can check for updated messages

Course, there's no auth yet, but it's probably better to try and build a working client first (as debugging is easier without a complex auth system in the way)

14 months agoImplemented ability to push messages into room.
B Tasker []
Implemented ability to push messages into room.

So the following flow will now create a room, add a user to it and then push a message by that user into the rooms table

curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"createRoom","payload":"{\"roomName\":\"BenTest\",\"owner\":\"ben\",\"passhash\":\"abcdefg\"}"}'

curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"inviteUser","payload":"{\"roomName\":\"BenTest\",\"user\":\"ben2\"}"}'

curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"sendMsg","payload":"{\"roomName\":\"BenTest\", \"msg\":\"ENCRYPTED-DATA\",\"user\":\"ben2\"}"}'

14 months agoOwner is now automatically subscribed into the room
B Tasker []
Owner is now automatically subscribed into the room

14 months agoImplemented the ability to link a user into a room
B Tasker []
Implemented the ability to link a user into a room

Means you can essentially do the following

curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"createRoom","payload":"{\"roomName\":\"BenTest\",\"owner\":\"ben\",\"passhash\":\"abcdefg\"}"}'
curl -v -X POST http://127.0.0.1:8090/ -H "Content-Type: application/json" --data '{"action":"inviteUser","payload":"{\"roomName\":\"BenTest\",\"user\":\"ben2\"}"}'

Which would allow user "ben2" to enter the room "BenTest"

What is missing, at the moment, is automatically linking the owner into the room at creation time. Will add that next

14 months agoImplemented basic schema for creating a room
B Tasker []
Implemented basic schema for creating a room

14 months agoCreating basic flask template as a starting point
B Tasker []
Creating basic flask template as a starting point