diff --git a/mtproto-common.h b/mtproto-common.h index ee6cf9d..9aec485 100644 --- a/mtproto-common.h +++ b/mtproto-common.h @@ -76,6 +76,7 @@ #define CODE_input_peer_notify_settings_old 0x3cf4b1be #define CODE_peer_notify_settings_old 0xddbcd4a5 +#define CODE_user_profile_photo_old 0x990d1493 #define CODE_msg_detained_info 0x276d3ec6 /* not really a limit, for struct encrypted_message only */ diff --git a/queries.c b/queries.c index 8c91003..429f04c 100644 --- a/queries.c +++ b/queries.c @@ -303,6 +303,28 @@ void out_random (int n) { out_cstring (buf, n); } +int allow_send_linux_version; +void do_insert_header (void) { + out_int (CODE_invoke_with_layer9); + out_int (CODE_init_connection); + out_int (TG_APP_ID); + if (allow_send_linux_version) { + struct utsname st; + uname (&st); + out_string (st.machine); + static char buf[1000000]; + sprintf (buf, "%s %s %s", st.sysname, st.release, st.version); + out_string (buf); + out_string (TG_VERSION " (build " TG_BUILD ")"); + out_string ("En"); + } else { + out_string ("x86"); + out_string ("Linux"); + out_string (TG_VERSION); + out_string ("en"); + } +} + /* {{{ Get config */ void fetch_dc_option (void) { @@ -413,7 +435,7 @@ void do_send_code (const char *user) { suser = strdup (user); want_dc_num = 0; clear_packet (); - out_int (CODE_invoke_with_layer6); + do_insert_header (); out_int (CODE_auth_send_code); out_string (user); out_int (0); @@ -441,7 +463,7 @@ void do_send_code (const char *user) { logprintf ("send_code: dc_num = %d\n", dc_working_num); want_dc_num = 0; clear_packet (); - out_int (CODE_invoke_with_layer6); + do_insert_header (); out_int (CODE_auth_send_code); out_string (user); out_int (0); @@ -2501,24 +2523,7 @@ struct query_methods get_difference_methods = { void do_get_difference (void) { difference_got = 0; clear_packet (); - out_int (CODE_invoke_with_layer9); - out_int (CODE_init_connection); - out_int (TG_APP_ID); - if (allow_send_linux_version) { - struct utsname st; - uname (&st); - out_string (st.machine); - static char buf[1000000]; - sprintf (buf, "%s %s %s", st.sysname, st.release, st.version); - out_string (buf); - out_string (TG_VERSION " (build " TG_BUILD ")"); - out_string ("En"); - } else { - out_string ("x86"); - out_string ("Linux"); - out_string (TG_VERSION); - out_string ("en"); - } + do_insert_header (); if (seq > 0) { out_int (CODE_updates_get_difference); out_int (pts); diff --git a/structures.c b/structures.c index 334d65b..9a48a42 100644 --- a/structures.c +++ b/structures.c @@ -202,8 +202,10 @@ int fetch_user (struct user *U) { need_update |= set_update_int (&U->photo_small.dc, -2); need_update |= set_update_int (&U->photo_big.dc, -2); } else { - assert (y == CODE_user_profile_photo); - fetch_long (); + assert (y == CODE_user_profile_photo || y == CODE_user_profile_photo_old); + if (y == CODE_user_profile_photo) { + fetch_long (); + } need_update |= fetch_file_location (&U->photo_small); need_update |= fetch_file_location (&U->photo_big); } @@ -396,6 +398,7 @@ void fetch_user_full (struct user *U) { free_photo (&U->photo); } fetch_photo (&U->photo); + U->flags |= FLAG_HAS_PHOTO; fetch_notify_settings (); U->blocked = fetch_int (); if (U->real_first_name) { free (U->real_first_name); }