How can I implement a normal message system but with with the option to invite unlimited members to the conversation?

  doctrine-orm, doctrine-query, mysql, symfony4, symfony5

I already know how how to implement a normal message system but now I need to implement a normal message system but with some specific features, which I will specify in the next paragraph. I need to do it using orm doctrine but I have some doubts and I want to avoid with a spaghetti code

Features I need to implement:

  1. Each participant in the conversation has the ability to invite more new members who will be able to read previous history

  2. Each participant can make a soft delete of one or several messages from the conversation (because it is soft delete, the other/s part/s could read deleted messages)

  3. I need to show a list of received/invited messages and participants

  4. Each participant can exit the conversation which will make to stop him receiving new messages but remaining participants can read past messages.

And my doubts are the following:

In the first place I need to know if I can need one or more entities. If it were a normal message system, I know that I could make only with one entity Message specifying receiver, sender and flags for deletion; retrieving the data through lefjoints. But with the invitation maybe it could be better to create an initial entity called Message related another entity called Chat (OneToMany), if that is the way to go my next doubt is to know how to handle members with access to each chat and if the chat was removed or not (if the main message was deleted, it should show only the new last message) and to handle deleted messages I could save an array of deleted flags (although I do not know if it can affect the performance in a bad way)

I hope that I explained it properly, if there is something missing I will add it. Thanks for taking your time to read it

Source: Symfony4 Questions