2
0
mirror of https://github.com/ars3niy/tdlib-purple synced 2025-08-31 14:05:10 +00:00

Added menu item to start secret chat

This commit is contained in:
Arseniy Lartsev
2020-10-04 16:52:57 +02:00
parent e6b9016a51
commit d5fe929ba9
7 changed files with 63 additions and 1 deletions

View File

@@ -2620,3 +2620,21 @@ bool PurpleTdClient::terminateCall(PurpleConversation *conv)
discardCurrentCall(m_data, m_transceiver);
return true;
}
void PurpleTdClient::createSecretChat(const char* buddyName)
{
std::vector<const td::td_api::user *> users = getUsersByPurpleName(buddyName, m_data, "create secret chat");
if (users.size() != 1) {
// Unlikely error messages not worth translating
const char *reason = users.empty() ? "User not found" :
"More than one user found with this name";
std::string message = formatMessage(_("Cannot kick user: {}"), std::string(reason));
purple_notify_error(purple_account_get_connection(m_account),
_("Failed to create secret chat"),
message.c_str(), NULL);
return;
}
auto request = td::td_api::make_object<td::td_api::createNewSecretChat>(getId(*users[0]).value());
m_transceiver.sendQuery(std::move(request), nullptr);
}