mirror of
https://github.com/ars3niy/tdlib-purple
synced 2025-08-31 05:55:08 +00:00
Create conversation window when "joining" a chat
This works for groups we are already member of (these will be in the contact list)
This commit is contained in:
@@ -1154,3 +1154,33 @@ void PurpleTdClient::notifyFailedContact(const std::string &phoneNumber, const s
|
||||
purple_notify_error(purple_account_get_connection(m_account),
|
||||
"Failed to add contact", message.c_str(), NULL);
|
||||
}
|
||||
|
||||
bool PurpleTdClient::joinChat(const char *chatName)
|
||||
{
|
||||
int64_t id = getTdlibChatId(chatName);
|
||||
const td::td_api::chat *chat = m_data.getChat(id);
|
||||
int32_t purpleId = m_data.getPurpleChatId(id);
|
||||
PurpleConvChat *conv = NULL;
|
||||
bool isMember = false;
|
||||
|
||||
if (chat) {
|
||||
int groupId = getBasicGroupId(*chat);
|
||||
if (groupId) {
|
||||
const td::td_api::basicGroup *group = m_data.getBasicGroup(groupId);
|
||||
isMember = group && isGroupMember(group->status_);
|
||||
}
|
||||
groupId = getSupergroupId(*chat);
|
||||
if (groupId) {
|
||||
const td::td_api::supergroup *group = m_data.getSupergroup(groupId);
|
||||
isMember = group && isGroupMember(group->status_);
|
||||
}
|
||||
}
|
||||
|
||||
if (isMember) {
|
||||
conv = getChatConversation(m_account, *chat, purpleId);
|
||||
if (conv)
|
||||
purple_conversation_present(purple_conv_chat_get_conversation(conv));
|
||||
}
|
||||
|
||||
return conv ? true : false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user