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

Implemented adding users to groups

This commit is contained in:
Arseniy Lartsev
2020-06-07 14:07:58 +02:00
parent 1e0a45ceb7
commit 648314d106
8 changed files with 153 additions and 35 deletions

View File

@@ -377,6 +377,15 @@ void removeGroupChat(PurpleAccount *purpleAccount, const td::td_api::chat &chat)
purple_blist_remove_chat(purpleChat);
}
static PurpleMessageFlags getNotificationFlags(PurpleMessageFlags extraFlags)
{
unsigned flags = (extraFlags & PURPLE_MESSAGE_ERROR) | (extraFlags & PURPLE_MESSAGE_NO_LOG);
if (flags == 0)
flags = PURPLE_MESSAGE_SYSTEM;
return (PurpleMessageFlags)flags;
}
void showMessageTextIm(TdAccountData &account, const char *purpleUserName, const char *text,
const char *notification, time_t timestamp, PurpleMessageFlags flags)
{
@@ -400,8 +409,7 @@ void showMessageTextIm(TdAccountData &account, const char *purpleUserName, const
if (conv == NULL)
conv = getImConversation(account.purpleAccount, purpleUserName);
purple_conv_im_write(purple_conversation_get_im_data(conv), nullptr, notification,
(flags & PURPLE_MESSAGE_ERROR) ? PURPLE_MESSAGE_ERROR : PURPLE_MESSAGE_SYSTEM,
timestamp);
getNotificationFlags(flags), timestamp);
}
}
@@ -428,8 +436,7 @@ static void showMessageTextChat(TdAccountData &account, const td::td_api::chat &
if (notification) {
if (conv)
purple_conv_chat_write(conv, "", notification,
PURPLE_MESSAGE_SYSTEM, message.timestamp);
purple_conv_chat_write(conv, "", notification, getNotificationFlags(flags), message.timestamp);
}
}
@@ -543,6 +550,16 @@ void showMessageText(TdAccountData &account, const td::td_api::chat &chat, const
showMessageTextChat(account, chat, message, text, notification, flags);
}
void showChatNotification(TdAccountData &account, const td::td_api::chat &chat,
const char *notification, PurpleMessageFlags flags)
{
TgMessageInfo messageInfo;
messageInfo.type = TgMessageInfo::Type::Other;
messageInfo.timestamp = (flags == PURPLE_MESSAGE_NO_LOG) ? 0 : time(NULL);
messageInfo.outgoing = true;
showMessageText(account, chat, messageInfo, NULL, notification, flags);
}
std::string getSenderPurpleName(const td::td_api::chat &chat, const td::td_api::message &message,
TdAccountData &account)
{