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

Implemented joining public groups by group link or name

This commit is contained in:
Arseniy Lartsev
2020-08-13 13:34:23 +02:00
parent 3ebf7d69b9
commit 8888e025b6
10 changed files with 305 additions and 41 deletions

View File

@@ -631,25 +631,25 @@ void getNamesFromAlias(const char *alias, std::string &firstName, std::string &l
}
static void findChatsByComponents(PurpleBlistNode *node,
const char *inviteLink, const char *groupName, int groupType,
const char *joinString, const char *groupName, int groupType,
std::vector<PurpleChat *> &result)
{
PurpleBlistNodeType nodeType = purple_blist_node_get_type(node);
if (nodeType == PURPLE_BLIST_CHAT_NODE) {
PurpleChat *chat = PURPLE_CHAT(node);
GHashTable *components = purple_chat_get_components(chat);
const char *nodeName = getChatName(components);
const char *nodeLink = getChatInviteLink(components);
const char *nodeGroupName = getChatGroupName(components);
int nodeGroupType = getChatGroupType(components);
PurpleChat *chat = PURPLE_CHAT(node);
GHashTable *components = purple_chat_get_components(chat);
const char *nodeName = getChatName(components);
const char *nodeJoinString = getChatJoinString(components);
const char *nodeGroupName = getChatGroupName(components);
int nodeGroupType = getChatGroupType(components);
if (!nodeName) nodeName = "";
if (!nodeLink) nodeLink = "";
if (!nodeJoinString) nodeJoinString = "";
if (!nodeGroupName) nodeGroupName = "";
if (!strcmp(nodeName, "") && !strcmp(nodeLink, inviteLink)) {
if ((*inviteLink != '\0') ||
if (!strcmp(nodeName, "") && !strcmp(nodeJoinString, joinString)) {
if ((*joinString != '\0') ||
(!strcmp(nodeGroupName, groupName) && (nodeGroupType == groupType)))
{
result.push_back(chat);
@@ -660,18 +660,18 @@ static void findChatsByComponents(PurpleBlistNode *node,
for (PurpleBlistNode *child = purple_blist_node_get_first_child(node); child;
child = purple_blist_node_get_sibling_next(child))
{
findChatsByComponents(child, inviteLink, groupName, groupType, result);
findChatsByComponents(child, joinString, groupName, groupType, result);
}
}
std::vector<PurpleChat *>findChatsByInviteLink(const std::string &inviteLink)
std::vector<PurpleChat *>findChatsByJoinString(const std::string &joinString)
{
std::vector<PurpleChat *> result;
for (PurpleBlistNode *root = purple_blist_get_root(); root;
root = purple_blist_node_get_sibling_next(root)) // LOL
{
findChatsByComponents(root, inviteLink.c_str(), "", 0, result);
findChatsByComponents(root, joinString.c_str(), "", 0, result);
}
return result;