Data structure:
chats
id - chat id
hash - md5 hash for chat link
address_id - for order and dispute
type - private/shop/order/dispute/ticket
status
title - title
created_at - datetime of creation date
chat_users
id - record id
user_id - user id
chat_id - chat id
last_readed - last message read
unread_counter - number of unread messages by the user in this chat
role - user/seller/buyer/admin
muted - 1/0 - ability to write in chat
created_at - datetime of the date added to the chat
chat_messages
id - message id
user_id - sender id
chat_id - chat id
message - message text
image - link to image
created_at - datetime of the date added to the chat
General provisions:
/chat/ - link for chats
chat viewing is available only to its participants - the rest are 404
Chat capabilities are determined by the role of a particular user
chat_users.last_readed - updated when the chat is opened or new messages are requested by the script
Every chat action must be checked for the user's role and chat type
The chats page is divided into 3 blocks: list of chats - message block - information
list of chats:
switching filters (persons/orders/disputes/tickets)
search by chats (in headers)
chat list
message block
title
messages
action bar
message sending form
block with information (for orders and disputes)
ordering information
information on the seller and buyer for moderators
Private messages:
when creating a private dialog, user roles are equivalent (user)
user can leave the dialog at any time
Chat with the store:
when you open a chat, all store administrators are added to it
seller - store employees receive this role and can invite other store employees (couriers) to the chat.
user - the one who asks the question. Can leave the chat at any time.
Order chat:
when you open a chat, all store administrators are added to it
seller - store employees receive this role and can invite other store employees (couriers) to the chat.
buyer - the one who bought. may open a dispute.
both participants see order information in the information panel on the right
buyer can open a dispute regarding the order
Dispute:
allows moderators to join the chat
the moderator sees expanded information on the transaction and its participants
the moderator can make a verdict on an order from the chat
Opening a request:
1 open ticket = 1 person. If there is an open ticket from a person, you need an error message
selecting the topic of the appeal (a separate table is needed for the list of available topics)
title
message
Actions with a ticket:
the creator can close the request
the moderator can close the request
the moderator can mark it as important
If 24 hours have passed without any new messages after a moderator's response, the ticket is closed
when a ticket is opened by a moderator, he becomes a participant in the dialogue, new messages in the ticket are dropped into his message counter
when a ticket is closed, all participants except the creator leave the chat, the creator will no longer be able to write to this ticket
in the ticket table, you need to note which moderator joined first, who closed the request (the first moderator, another moderator, a timer, or the user himself)
moderators can view a closed ticket, they will not become participants in the chat
modders can invite other modders to the ticket
List of tickets for moderators:
search by nickname, search by title
filtering "stores only"
filter by topic
filtering only important ones
filtering important + by topic
sort from oldest to newest (default)
sorting from new to old