Commit ed2be549 authored by Vysheng's avatar Vysheng

Mark read messages from not peers

parent f2734e59
...@@ -1128,6 +1128,12 @@ static int fetch_comb_binlog_msg_seq_update (void *extra) { ...@@ -1128,6 +1128,12 @@ static int fetch_comb_binlog_msg_seq_update (void *extra) {
tgl_state.seq ++; tgl_state.seq ++;
vlogprintf (E_DEBUG - 1 + 2 * in_replay_log, "seq %d=>%d\n", tgl_state.seq - 1, tgl_state.seq); vlogprintf (E_DEBUG - 1 + 2 * in_replay_log, "seq %d=>%d\n", tgl_state.seq - 1, tgl_state.seq);
if (!(M->flags & FLAG_ENCRYPTED)) {
if (tgl_state.max_msg_id < M->id) {
tgl_state.max_msg_id = M->id;
}
}
if (tgl_state.callback.msg_receive) { if (tgl_state.callback.msg_receive) {
tgl_state.callback.msg_receive (M); tgl_state.callback.msg_receive (M);
} }
...@@ -1138,6 +1144,12 @@ static int fetch_comb_binlog_msg_update (void *extra) { ...@@ -1138,6 +1144,12 @@ static int fetch_comb_binlog_msg_update (void *extra) {
struct tgl_message *M = tgl_message_get (fetch_long ()); struct tgl_message *M = tgl_message_get (fetch_long ());
assert (M); assert (M);
if (!(M->flags & FLAG_ENCRYPTED)) {
if (tgl_state.max_msg_id < M->id) {
tgl_state.max_msg_id = M->id;
}
}
if (tgl_state.callback.msg_receive) { if (tgl_state.callback.msg_receive) {
tgl_state.callback.msg_receive (M); tgl_state.callback.msg_receive (M);
} }
......
...@@ -1104,21 +1104,16 @@ void tgl_do_messages_mark_read_encr (tgl_peer_id_t id, long long access_hash, in ...@@ -1104,21 +1104,16 @@ void tgl_do_messages_mark_read_encr (tgl_peer_id_t id, long long access_hash, in
} }
void tgl_do_mark_read (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success), void *callback_extra) { void tgl_do_mark_read (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success), void *callback_extra) {
if (tgl_get_peer_type (id) == TGL_PEER_USER || tgl_get_peer_type (id) == TGL_PEER_CHAT) {
tgl_do_messages_mark_read (id, tgl_state.max_msg_id, callback, callback_extra);
return;
}
tgl_peer_t *P = tgl_peer_get (id); tgl_peer_t *P = tgl_peer_get (id);
if (!P) { if (!P) {
vlogprintf (E_WARNING, "Unknown peer\n"); vlogprintf (E_WARNING, "Unknown peer\n");
callback (callback_extra, 0); callback (callback_extra, 0);
return; return;
} }
if (tgl_get_peer_type (id) == TGL_PEER_USER || tgl_get_peer_type (id) == TGL_PEER_CHAT) {
if (!P->last) {
vlogprintf (E_WARNING, "Unknown last peer message\n");
callback (callback_extra, 0);
return;
}
tgl_do_messages_mark_read (id, P->last->id, callback, callback_extra);
return;
}
assert (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT); assert (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT);
if (P->last) { if (P->last) {
tgl_do_messages_mark_read_encr (id, P->encr_chat.access_hash, P->last->date, callback, callback_extra); tgl_do_messages_mark_read_encr (id, P->encr_chat.access_hash, P->last->date, callback, callback_extra);
......
...@@ -132,6 +132,7 @@ struct tgl_state { ...@@ -132,6 +132,7 @@ struct tgl_state {
int verbosity; int verbosity;
int unread_messages; int unread_messages;
int active_queries; int active_queries;
int max_msg_id;
long long locks; long long locks;
struct tgl_dc *DC_list[TGL_MAX_DC_NUM]; struct tgl_dc *DC_list[TGL_MAX_DC_NUM];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment