Opinionated Django Chat
Project description
django-df-chat
Development
Installing dev requirements:
pip install -e .[test]
Installing pre-commit hook:
pre-commit install
Running tests:
pytest
New Design
Model Data
ChatRoom
- title = CharField()
- users = ManyToManyField(through="ChatMember")
- chat_type = Enum: 'private', 'group',
ChatMember
- is_owner = BooleanField(default=False)
- is_admin = BooleanField(default=False)
- user = ForeignKey(ChatUser)
- chat_room = ForeignKey(ChatRoom)
MemberChannel (service table)
- last_alive_at = DateTimeField()
- channel_name = CharField()
- user = ForeignKey(ChatUser)
ChatMessage
- created_by = ForeignKey(ChatUser)
- chat_room = ForeignKey(ChatRoom)
- message = TextField(settings.CHAT_USER_MODEL)
API:
[GET] /api/v1/chat/rooms/
[POST] /api/v1/chat/rooms/
[GET] /api/v1/chat/rooms/{id}/
[PUT] /api/v1/chat/rooms/{id}/
[PATCH] /api/v1/chat/rooms/{id}/
[DELETE] /api/v1/chat/rooms/{id}/
[POST] /api/v1/chat/rooms/{id}/member/
[GET] /api/v1/chat/rooms/{room_id}/messages/
[POST] /api/v1/chat/rooms/{room_id}/messages/
[GET] /api/v1/chat/rooms/{room_id}/messages/{id}/
[PUT] /api/v1/chat/rooms/{room_id}/messages/{id}/
[PATCH] /api/v1/chat/rooms/{room_id}/messages/{id}/
[DELETE] /api/v1/chat/rooms/{room_id}/messages/{id}/
Use cases:
- Create chat room with specific type, and add user. Channel layer should be created if user are online and all online users should to receive messages
- Private chat room (chat between 2 members). Nobody can add new members.
- Group chat (chat between multiple users). Users could be added through API endpoint call
- moderation part is missed at the moment
Flow:
- User connected to WS
- Channel layer stored to DB to use it in a future to dynamically subscribe user with a new chatRooms
- on user disconnected channel layer should be removed from DB
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-df-chat-0.1.7.tar.gz
.
File metadata
- Download URL: django-df-chat-0.1.7.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4edefa25748e8fc75a73b230900355baa0221f896bc0e2c054d8fb6eb494e1b |
|
MD5 | 3c7f8fc2b58e7332ab929d6e7c2187cd |
|
BLAKE2b-256 | dfd74ef7f7e5f3c5963ef8c9cfa0afcdc7769c3587e5e765a9e894fbd835a907 |
File details
Details for the file django_df_chat-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: django_df_chat-0.1.7-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c3f72e25f9f4a9199d90ec1fe8f09e6e88cd073eb2d809fd64c132f27b589e |
|
MD5 | 9f8d0dc17b46d5ba9362f8c14690a1a4 |
|
BLAKE2b-256 | 4827f2b37ee5c8cc037a77da0a925953f4d2a3c089174dc46ad46e44bed6275a |