Skip to content

Commit

Permalink
docs: add v1.0 chat docs
Browse files Browse the repository at this point in the history
  • Loading branch information
neuodev authored and mmoehabb committed Dec 12, 2024
1 parent b5ed931 commit d15e1ee
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions architecture/v1.0/chat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Chat

## Chat rooms management

- When the user is connected to the server, we find all his rooms and _join_ his socket to it.
- When the user is disconnected from the server, we find all his rooms and _remove_ his socket from these rooms.
- Notify his room members in these rooms that the user is offline ([related](#onlineoffline))

## Online/Offline

> Depends on (blocked by) [chat rooms management](#chat-rooms-management).
##### Requirements

When the user is connected/disconnected to/from the server

- He should be marked as `online` / `offline`
- All the other users that share a room with the current user should be notified.
- Logic should be tested.

## Mark messages as read

> Depends on (blocked by) [chat rooms management](#chat-rooms-management).
##### Requirements

- When the message first created it should be marked as unread by default.
- Onwership must be verified.
- Ensure the the messages was not already deleted.
- Client can emit an event to mark message as read.
- Upon failure, a revert event should be sent back to the same client to notify that the action was reverted.
- Logic should be tested.

## Delete message

> Depends on (blocked by) [chat rooms management](#chat-rooms-management).
##### Requirements

- Client can emit an event to delete a room message in case he is the owner.
- Event should contain the message id only.
- Onwership must be verified.
- Ensure that messages was not already deleted.
- Messages should be never be deleted from the database but it should be _marked as deleted_ instead.
- Ensure that deleted messages is not included in the the find room messages api handler.
- Upon deletion failure, an event should be sent back to the same client with the revert reason.
```ts
// event emitted by the server to the chat room associated with the deleted messages.
type MessageDeletionReverted = {
messageId: number;
reason: string;
};
```
- Other members in the room should notified that the message was deleted.
```ts
// event emitted by the server to the chat room associated with deleted message.
type MessagedDeleted = { messageId: number };
```

## Tasks

- [ ] Write full-test coverage for the `messages` model. @mmoehabb
- [ ] Chat room management ([info](#chat-rooms-management)). @mmoehabb
- [ ] Online/Offline ([info](#onlineoffline)) @mmoehabb
- [ ] Mark message as read ([info](#mark-messages-as-read)). @mmoehabb
- [ ] Delete messages ([info](#delete-message)). @mmoehabb

0 comments on commit d15e1ee

Please sign in to comment.