Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group Chat 1:n #34

Open
chrisdevel opened this issue Jun 1, 2022 · 6 comments
Open

Group Chat 1:n #34

chrisdevel opened this issue Jun 1, 2022 · 6 comments

Comments

@chrisdevel
Copy link

Hi,

I would like to have a 1:n chat (group-chat) additionally to the current 1:1 chat. I was wondering what kind of modifications are needed to do so. Maybe you have same advice as for the starting point.

Many thanks!

@delneg
Copy link
Collaborator

delneg commented Jun 1, 2022

Well, consider the following changes to models:

  1. Make "users" a Many-To-Many field on DialogsModel
  2. Add "group" model with "participants" field (M2M to "User")
  3. Split "recipient" field on MessageField into recipient_user (the same as now) and recipient_group, and ensure they can't be both set simultaneously

It would be a nice idea to create some indexes or auto-updated Materialized views with user's dialogs list .

Then, adjust consumers code to handle the possibility of multiple users when receiving the message, add checks for InvalidGroupPk, and adjust the db saving accordingly.
Don't forget to send updates to all users in the group (await self.channel_layer.group_send(user_pk, becomes await self.channel_layer.group_send(group_pk, or smth like that)

After that with things like administation you want to add "admins" field (subset of participants) to Group and add checks to send MessageTypes.TextMessage / FileMessage to check for banned / unbanned and various other permission-related stuff.

Probably add a few new message updates for user joining a group / leaving a group, and add new message types to request group joining / leaving

Well, probably mostly tedious work to add not only the possilibty of handling >2 user "dialogs" but also new features, such as administration, banning / restricting allowed communication types /joining or leaving the groups, probably forming public and private group links etc.

@chrisdevel
Copy link
Author

Fantastic - many thanks for the quick answer!

I looked into the changes and I would also need to change the main.js file (django_private_chat2-master\example\static\js\main.js) too. However this file is minified and therefore hard to work with. Is there any chance to get the unminified main.js?

Thanks again!

@delneg
Copy link
Collaborator

delneg commented Jun 7, 2022

Hi,
I assumed that if you're up to this task which is relatively hard, that you have you own frontend.
If fact, I recommend you to implement your own because it would probably be easier than adapting the example one.
Nevertheless, answering your question - the example frontend is written partially in F# and partially in JS, you can see all of the files here: https://github.com/Bearle/django_private_chat2/tree/master/example/frontend

Minified main.js file is the result of npm run build in that folder, with Webpack bundling everything together.

@VSofficial
Copy link

VSofficial commented Jan 3, 2023

I wanted to make an PR for chat frontend in repository/example for iOS app (Swift)
would you be interested to merge that

@delneg
Copy link
Collaborator

delneg commented Jan 3, 2023

I wanted to make an PR for chat frontend in repository/example for iOS app (Swift) would you be interested to merge that

Hello,
Yes I think that would be interesting, as long as it has good code quality

@VSofficial
Copy link

VSofficial commented Jan 3, 2023

Okay, cool. Will be shipping the code after completion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants