Commit 5f40cc4e authored by vysheng's avatar vysheng

Merge pull request #121 from vDorst/create_group_chat

Added command create_group_chat <user> <chat topic>.
parents a5b6f93a f0436e61
......@@ -117,6 +117,7 @@ If two or more peers have same name, <sharp>number is appended to the name. (for
* **chat_add_user** \<chat\> \<user\> - add user to chat
* **chat_del_user** \<chat\> \<user\> - remove user from chat
* **rename_chat** \<chat\> \<new-name\>
* **create_group_chat** \<user\> \<chat topic\> - creates a groupchat with user, use chat_add_user to add more users
#### Search
......
......@@ -322,6 +322,7 @@ char *commands[] = {
"chat_with_peer",
"delete_msg",
"restore_msg",
"create_group_chat",
0 };
int commands_flags[] = {
......@@ -371,6 +372,7 @@ int commands_flags[] = {
07,
072,
07,
072,
07
};
......@@ -888,6 +890,7 @@ void interpreter (char *line UU) {
"mark_read <peer> - mark read all received messages with peer\n"
"add_contact <phone-number> <first-name> <last-name> - tries to add contact to contact-list by phone\n"
"create_secret_chat <user> - creates secret chat with this user\n"
"create_group_chat <user> <chat-topic> - creates group chat with this user, add more users with chat_add_user <user>\n"
"rename_contact <user> <first-name> <last-name> - tries to rename contact. If you have another device it will be a fight\n"
"suggested_contacts - print info about contacts, you have max common friends\n"
"visualize_key <secret_chat> - prints visualization of encryption key. You should compare it to your partner's one\n"
......@@ -938,6 +941,15 @@ void interpreter (char *line UU) {
} else if (IS_WORD ("create_secret_chat")) {
GET_PEER;
do_create_secret_chat (id);
} else if (IS_WORD ("create_group_chat")) {
GET_PEER;
int t;
char *s = next_token (&t);
if (!s) {
printf ("Empty chat topic\n");
RET;
}
do_create_group_chat (id, s);
} else if (IS_WORD ("suggested_contacts")) {
do_get_suggested ();
} else if (IS_WORD ("status_online")) {
......
......@@ -2784,6 +2784,36 @@ void do_create_secret_chat (peer_id_t id) {
}
/* }}} */
/* {{{ Create group chat */
struct query_methods create_group_chat_methods = {
.on_answer = fwd_msg_on_answer
};
void do_create_group_chat (peer_id_t id, char *chat_topic) {
assert (get_peer_type (id) == PEER_USER);
peer_t *U = user_chat_get (id);
if (!U) {
rprintf ("Can not create chat with unknown user\n");
return;
}
clear_packet ();
out_int (CODE_messages_create_chat);
out_int (CODE_vector);
out_int (1); // Number of users, currently we support only 1 user.
if (U && U->user.access_hash) {
out_int (CODE_input_user_foreign);
out_int (get_peer_id (id));
out_long (U->user.access_hash);
} else {
out_int (CODE_input_user_contact);
out_int (get_peer_id (id));
}
out_string (chat_topic);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &create_group_chat_methods, 0);
}
/* }}} */
/* {{{ Delete msg */
int delete_msg_on_answer (struct query *q UU) {
......
......@@ -84,6 +84,7 @@ void do_rename_chat (peer_id_t id, char *name);
void do_load_encr_video (struct encr_video *V, int next);
void do_create_encr_chat_request (int user_id);
void do_create_secret_chat (peer_id_t id);
void do_create_group_chat (peer_id_t id, char *chat_topic);
void do_get_suggested (void);
struct photo;
......
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