del_contact query
This commit is contained in:
parent
94c27ccc2c
commit
1af0fb8432
@ -379,6 +379,7 @@ struct command commands[] = {
|
|||||||
{"load_document_thumb", {ca_number, ca_none}},
|
{"load_document_thumb", {ca_number, ca_none}},
|
||||||
{"view_document_thumb", {ca_number, ca_none}},
|
{"view_document_thumb", {ca_number, ca_none}},
|
||||||
{"add_contact", {ca_string, ca_string, ca_string, ca_none}},
|
{"add_contact", {ca_string, ca_string, ca_string, ca_none}},
|
||||||
|
{"del_contact", {ca_user, ca_none}},
|
||||||
{"rename_contact", {ca_user, ca_string, ca_string, ca_none}},
|
{"rename_contact", {ca_user, ca_string, ca_string, ca_none}},
|
||||||
{"show_license", {ca_none}},
|
{"show_license", {ca_none}},
|
||||||
{"search", {ca_peer, ca_string_end}},
|
{"search", {ca_peer, ca_string_end}},
|
||||||
@ -1339,6 +1340,9 @@ void interpreter (char *line UU) {
|
|||||||
RET;
|
RET;
|
||||||
}
|
}
|
||||||
tgl_do_add_contact (phone, phone_len, first_name, first_name_len, last_name, last_name_len, 0, print_user_list_gw, 0);
|
tgl_do_add_contact (phone, phone_len, first_name, first_name_len, last_name, last_name_len, 0, print_user_list_gw, 0);
|
||||||
|
} else if (IS_WORD ("del_contact")) {
|
||||||
|
GET_PEER_USER;
|
||||||
|
tgl_do_del_contact (id, 0, 0);
|
||||||
} else if (IS_WORD ("send_contact")) {
|
} else if (IS_WORD ("send_contact")) {
|
||||||
GET_PEER;
|
GET_PEER;
|
||||||
int phone_len, first_name_len, last_name_len;
|
int phone_len, first_name_len, last_name_len;
|
||||||
|
5
lua-tg.c
5
lua-tg.c
@ -474,6 +474,7 @@ enum lua_query_type {
|
|||||||
lq_chat_add_user,
|
lq_chat_add_user,
|
||||||
lq_chat_del_user,
|
lq_chat_del_user,
|
||||||
lq_add_contact,
|
lq_add_contact,
|
||||||
|
lq_del_contact,
|
||||||
lq_rename_contact,
|
lq_rename_contact,
|
||||||
lq_search,
|
lq_search,
|
||||||
lq_global_search,
|
lq_global_search,
|
||||||
@ -968,6 +969,9 @@ void lua_do_all (void) {
|
|||||||
free (s3);
|
free (s3);
|
||||||
p += 4;
|
p += 4;
|
||||||
break;
|
break;
|
||||||
|
case lq_del_contact:
|
||||||
|
tgl_do_del_contact (((tgl_peer_t *)lua_ptr[p + 1])->id, lua_empty_cb, lua_ptr[p]);
|
||||||
|
break;
|
||||||
case lq_rename_contact:
|
case lq_rename_contact:
|
||||||
s1 = lua_ptr[p + 1];
|
s1 = lua_ptr[p + 1];
|
||||||
s2 = lua_ptr[p + 2];
|
s2 = lua_ptr[p + 2];
|
||||||
@ -1108,6 +1112,7 @@ struct lua_function functions[] = {
|
|||||||
{"chat_add_user", lq_chat_add_user, { lfp_chat, lfp_user, lfp_none }},
|
{"chat_add_user", lq_chat_add_user, { lfp_chat, lfp_user, lfp_none }},
|
||||||
{"chat_del_user", lq_chat_del_user, { lfp_chat, lfp_user, lfp_none }},
|
{"chat_del_user", lq_chat_del_user, { lfp_chat, lfp_user, lfp_none }},
|
||||||
{"add_contact", lq_add_contact, { lfp_string, lfp_string, lfp_string, lfp_none }},
|
{"add_contact", lq_add_contact, { lfp_string, lfp_string, lfp_string, lfp_none }},
|
||||||
|
{"del_contact", lq_del_contact, { lfp_user, lfp_none }},
|
||||||
{"rename_contact", lq_rename_contact, { lfp_string, lfp_string, lfp_string, lfp_none }},
|
{"rename_contact", lq_rename_contact, { lfp_string, lfp_string, lfp_string, lfp_none }},
|
||||||
{"msg_search", lq_search, { lfp_peer, lfp_string, lfp_none }},
|
{"msg_search", lq_search, { lfp_peer, lfp_string, lfp_none }},
|
||||||
{"msg_global_search", lq_global_search, { lfp_string, lfp_none }},
|
{"msg_global_search", lq_global_search, { lfp_string, lfp_none }},
|
||||||
|
38
queries.c
38
queries.c
@ -2600,6 +2600,44 @@ void tgl_do_add_contact (const char *phone, int phone_len, const char *first_nam
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ Add contact */
|
||||||
|
static int del_contact_on_answer (struct query *q UU) {
|
||||||
|
assert (skip_type_contacts_link (TYPE_TO_PARAM(contacts_link)) >= 0);
|
||||||
|
|
||||||
|
if (q->callback) {
|
||||||
|
((void (*)(void *, int))q->callback) (q->callback_extra, 1);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct query_methods del_contact_methods = {
|
||||||
|
.on_answer = del_contact_on_answer,
|
||||||
|
.type = TYPE_TO_PARAM(contacts_link)
|
||||||
|
};
|
||||||
|
|
||||||
|
void tgl_do_del_contact (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success), void *callback_extra) {
|
||||||
|
if (tgl_get_peer_type (id) != TGL_PEER_USER) {
|
||||||
|
if (callback) {
|
||||||
|
callback (callback_extra, 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clear_packet ();
|
||||||
|
out_int (CODE_contacts_delete_contact);
|
||||||
|
|
||||||
|
tgl_peer_t *U = tgl_peer_get (id);
|
||||||
|
if (U && U->user.access_hash) {
|
||||||
|
out_int (CODE_input_user_foreign);
|
||||||
|
out_int (tgl_get_peer_id (id));
|
||||||
|
out_long (U->user.access_hash);
|
||||||
|
} else {
|
||||||
|
out_int (CODE_input_user_contact);
|
||||||
|
out_int (tgl_get_peer_id (id));
|
||||||
|
}
|
||||||
|
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &del_contact_methods, 0, callback, callback_extra);
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ Msg search */
|
/* {{{ Msg search */
|
||||||
static int msg_search_on_answer (struct query *q UU) {
|
static int msg_search_on_answer (struct query *q UU) {
|
||||||
return get_history_on_answer (q);
|
return get_history_on_answer (q);
|
||||||
|
1
tgl.h
1
tgl.h
@ -281,6 +281,7 @@ void tgl_do_export_card (void (*callback)(void *callback_extra, int success, int
|
|||||||
void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra);
|
void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra);
|
||||||
void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
||||||
void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
||||||
|
void tgl_do_del_contact (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success), void *callback_extra);
|
||||||
|
|
||||||
|
|
||||||
void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]);
|
void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user