From 4aeb0ebb2009d43e1420ade1bca6377967709a1e Mon Sep 17 00:00:00 2001 From: vvaltman Date: Sun, 7 Sep 2014 22:44:19 +0400 Subject: [PATCH] Fixed updates --- README-LUA | 3 ++- structures.c | 26 +++++++++++++++++++++++--- updates.c | 8 ++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README-LUA b/README-LUA index 0e71432..dbb7be8 100644 --- a/README-LUA +++ b/README-LUA @@ -21,7 +21,8 @@ These functions may return false immidiately if something is bad with args, or r cb_function would have two or three arguments: first cb_extra, second success (1 or 0), third result (if applicable). If you want to pass msg to function, you should pass it's id. -If you want to pass peer to function, you should pass it's print_name +If you want to pass peer to function, you should pass it's print_name. +Or, you can pass string user#id chat#id and secret_chat#id as peer. It is in some cases better. For example if you want to postpone and you are afraid, that print_name would be changed in the meantime. Function_list (arguments are listed aside from cb_function and cb_extra, : get_contact_list () diff --git a/structures.c b/structures.c index bffbb8f..96fa7af 100644 --- a/structures.c +++ b/structures.c @@ -646,7 +646,7 @@ void tglf_fetch_message_short (struct tgl_message *M) { int l = prefetch_strlen (); char *s = fetch_str (l); - tglu_fetch_pts (); + int pts = fetch_int (); int date = fetch_int (); //tglu_fetch_seq (); @@ -654,6 +654,14 @@ void tglf_fetch_message_short (struct tgl_message *M) { assert (seq == tgl_state.seq + 1); bl_do_create_message_text (id, from_id, TGL_PEER_USER, to_id, date, 1, l, s); + + tgl_peer_t *P = tgl_peer_get (TGL_MK_USER (from_id)); + if (!P || !(P->flags & FLAG_CREATED)) { + tgl_do_get_difference (0, 0, 0); + } else { + bl_do_set_pts (pts); + bl_do_set_date (date); + } //bl_do_msg_seq_update (id); } else { fetch_int (); // id @@ -680,14 +688,26 @@ void tglf_fetch_message_short_chat (struct tgl_message *M) { int l = prefetch_strlen (); char *s = fetch_str (l); - tglu_fetch_pts (); - + int pts = fetch_int (); int date = fetch_int (); //tglu_fetch_seq (); int seq = fetch_int (); assert (seq == tgl_state.seq + 1); bl_do_create_message_text (id, from_id, TGL_PEER_CHAT, to_id, date, 1, l, s); + + tgl_peer_t *P = tgl_peer_get (TGL_MK_CHAT (to_id)); + if (!P || !(P->flags & FLAG_CREATED)) { + tgl_do_get_difference (0, 0, 0); + } else { + P = tgl_peer_get (TGL_MK_USER (from_id)); + if (!P || !(P->flags & FLAG_CREATED)) { + tgl_do_get_difference (0, 0, 0); + } else { + bl_do_set_pts (pts); + bl_do_set_date (date); + } + } //bl_do_msg_seq_update (id); } else { fetch_int (); // id diff --git a/updates.c b/updates.c index 34511e1..128cf52 100644 --- a/updates.c +++ b/updates.c @@ -489,7 +489,9 @@ void tglu_work_update_short_message (struct connection *c, long long msg_id) { assert (M); assert (save_end == in_ptr); - bl_do_msg_seq_update (M->id); + if (!(tgl_state.locks & TGL_LOCK_DIFF)) { + bl_do_msg_seq_update (M->id); + } } void tglu_work_update_short_chat_message (struct connection *c, long long msg_id) { @@ -506,7 +508,9 @@ void tglu_work_update_short_chat_message (struct connection *c, long long msg_id assert (M); assert (save_end == in_ptr); - bl_do_msg_seq_update (M->id); + if (!(tgl_state.locks & TGL_LOCK_DIFF)) { + bl_do_msg_seq_update (M->id); + } } void tglu_work_updates_to_long (struct connection *c, long long msg_id) {