diff --git a/interface.c b/interface.c index 82fded1..61705c2 100644 --- a/interface.c +++ b/interface.c @@ -255,6 +255,7 @@ char *commands[] = { "visualize_key", "create_secret_chat", "suggested_contacts", + "global_search", 0 }; int commands_flags[] = { @@ -285,6 +286,7 @@ int commands_flags[] = { 075, 071, 07, + 07, }; int get_complete_mode (void) { @@ -745,6 +747,17 @@ void interpreter (char *line UU) { RET; } do_msg_search (id, from, to, limit, s); + } else if (IS_WORD ("global_search")) { + int from = 0; + int to = 0; + int limit = 40; + int t; + char *s = next_token (&t); + if (!s) { + printf ("Empty message\n"); + RET; + } + do_msg_search (PEER_NOT_FOUND, from, to, limit, s); } else if (IS_WORD ("mark_read")) { GET_PEER; do_mark_read (id); @@ -916,9 +929,11 @@ void print_user_name (peer_id_t id, peer_t *U) { if (U->flags & (FLAG_USER_SELF | FLAG_USER_CONTACT)) { push_color (COLOR_REDB); } - if (!U->user.first_name) { + if ((U->flags & FLAG_DELETED) || (U->flags & FLAG_EMPTY)) { + printf ("deleted user#%d", get_peer_id (id)); + } else if (!U->user.first_name || !strlen (U->user.first_name)) { printf ("%s", U->user.last_name); - } else if (!U->user.last_name) { + } else if (!U->user.last_name || !strlen (U->user.last_name)) { printf ("%s", U->user.first_name); } else { printf ("%s %s", U->user.first_name, U->user.last_name); diff --git a/queries.c b/queries.c index a4acb6a..6bf88a3 100644 --- a/queries.c +++ b/queries.c @@ -1971,9 +1971,17 @@ struct query_methods msg_search_methods = { }; void do_msg_search (peer_id_t id, int from, int to, int limit, const char *s) { + if (get_peer_type (id) == PEER_ENCR_CHAT) { + rprintf ("Can not search in secure chat\n"); + return; + } clear_packet (); out_int (CODE_messages_search); - out_peer_id (id); + if (get_peer_type (id) == PEER_UNKNOWN) { + out_int (CODE_input_peer_empty); + } else { + out_peer_id (id); + } out_string (s); out_int (CODE_input_messages_filter_empty); out_int (from);