M
M
MrOnatsky2018-07-14 19:44:11
MySQL
MrOnatsky, 2018-07-14 19:44:11

How to implement the "viewed" status in the chat (opposite messages)?

Can you tell me how to implement the "read" status in chat messages?
Table 2, managing chats and messages .
PS I think to use a radish so that the base does not pull every time.

// v - viewed
$redis->set('v:' . $chat_id, $message_id . '_' . time());

And with some interval, save the new values ​​to the chats table .

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg, 2018-07-14
@politon

Use WebSocket. Ajax for such functionality is the last century

I
ITOLD, 2018-07-14
@itold_ru

Send current AJAX user status. Those. for example, every second (for example!) - ajax request, like the user reads the current dialog, if he has it open - create the 'is_read' field in the messages table and set the value to 1 (read). If closed, requests are not sent.
Also bringing to the ideal - if the user does not perform actions, disable this system with ajax)

P
Philipp, 2018-07-15
@zoonman

Add a third table - message_status.
Store message_id, user_id and read_at in it as a nullable timestamp.
In the chat interface, control messages that fall into the visible area and track the scroll event.
Store the status of the messages in the model on the client and periodically send these updates to the server in the background and page unload if there is anything left.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question