2020-10-04 15:17:04 +02:00
|
|
|
#include "identifiers.h"
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
const UserId UserId::invalid = UserId(0);
|
|
|
|
const ChatId ChatId::invalid = ChatId(0);
|
|
|
|
const BasicGroupId BasicGroupId::invalid = BasicGroupId(0);
|
|
|
|
const SupergroupId SupergroupId::invalid = SupergroupId(0);
|
|
|
|
const SecretChatId SecretChatId::invalid = SecretChatId(0);
|
2020-10-11 10:55:42 +02:00
|
|
|
const MessageId MessageId::invalid = MessageId(0);
|
2020-10-04 15:17:04 +02:00
|
|
|
|
|
|
|
UserId getId(const td::td_api::user &user)
|
|
|
|
{
|
|
|
|
return UserId(user.id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatId getId(const td::td_api::chat &chat)
|
|
|
|
{
|
|
|
|
return ChatId(chat.id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
BasicGroupId getId(const td::td_api::basicGroup &group)
|
|
|
|
{
|
|
|
|
return BasicGroupId(group.id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
SupergroupId getId(const td::td_api::supergroup &group)
|
|
|
|
{
|
|
|
|
return SupergroupId(group.id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
SecretChatId getId(const td::td_api::secretChat &secretChat)
|
|
|
|
{
|
|
|
|
return SecretChatId(secretChat.id_);
|
|
|
|
}
|
|
|
|
|
2020-10-10 15:51:16 +02:00
|
|
|
MessageId getId(const td::td_api::message &message)
|
|
|
|
{
|
|
|
|
return MessageId(message.id_);
|
|
|
|
}
|
|
|
|
|
2020-10-04 15:17:04 +02:00
|
|
|
UserId getUserId(const td::td_api::chatTypePrivate &privType)
|
|
|
|
{
|
|
|
|
return UserId(privType.user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId getUserId(const td::td_api::chatMember &member)
|
|
|
|
{
|
2021-12-06 19:56:53 +01:00
|
|
|
if (member.member_id_ && (member.member_id_->get_id() == td::td_api::messageSenderUser::ID)) {
|
|
|
|
const td::td_api::messageSenderUser &userInfo = static_cast<const td::td_api::messageSenderUser &>(*member.member_id_);
|
|
|
|
return UserId(userInfo.user_id_);
|
|
|
|
}
|
|
|
|
return UserId::invalid;
|
2020-10-04 15:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UserId getUserId(const td::td_api::call &call)
|
|
|
|
{
|
|
|
|
return UserId(call.user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId getSenderUserId(const td::td_api::message &message)
|
|
|
|
{
|
2021-12-06 19:56:53 +01:00
|
|
|
if (message.sender_ && (message.sender_->get_id() == td::td_api::messageSenderUser::ID))
|
|
|
|
return UserId(static_cast<const td::td_api::messageSenderUser &>(*message.sender_).user_id_);
|
|
|
|
else
|
|
|
|
return UserId::invalid;
|
2020-10-04 15:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UserId getSenderUserId(const td::td_api::messageForwardOriginUser &forwardOrigin)
|
|
|
|
{
|
|
|
|
return UserId(forwardOrigin.sender_user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId getUserId(const td::td_api::secretChat &secretChat)
|
|
|
|
{
|
|
|
|
return UserId(secretChat.user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId getUserId(const td::td_api::updateUserStatus &update)
|
|
|
|
{
|
|
|
|
return UserId(update.user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId getUserId(const td::td_api::updateUserChatAction &update)
|
|
|
|
{
|
|
|
|
return UserId(update.user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId getUserId(const td::td_api::importedContacts &contacts, unsigned index)
|
|
|
|
{
|
|
|
|
return UserId(contacts.user_ids_[index]);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId getUserId(const td::td_api::users &users, unsigned index)
|
|
|
|
{
|
|
|
|
return UserId(users.user_ids_[index]);
|
|
|
|
}
|
|
|
|
|
2021-12-06 19:56:53 +01:00
|
|
|
ChatId getChatId(const td::td_api::updateChatPosition &update)
|
2020-10-04 15:17:04 +02:00
|
|
|
{
|
|
|
|
return ChatId(update.chat_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatId getChatId(const td::td_api::updateChatTitle &update)
|
|
|
|
{
|
|
|
|
return ChatId(update.chat_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatId getChatId(const td::td_api::messageForwardOriginChannel &forwardOrigin)
|
|
|
|
{
|
|
|
|
return ChatId(forwardOrigin.chat_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatId getChatId(const td::td_api::message &message)
|
|
|
|
{
|
|
|
|
return ChatId(message.chat_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatId getChatId(const td::td_api::updateUserChatAction &update)
|
|
|
|
{
|
|
|
|
return ChatId(update.chat_id_);
|
|
|
|
}
|
|
|
|
|
2021-01-02 19:27:47 +01:00
|
|
|
ChatId getChatId(const td::td_api::updateChatLastMessage &update)
|
|
|
|
{
|
|
|
|
return ChatId(update.chat_id_);
|
|
|
|
}
|
|
|
|
|
2020-10-04 15:17:04 +02:00
|
|
|
BasicGroupId getBasicGroupId(const td::td_api::updateBasicGroupFullInfo &update)
|
|
|
|
{
|
|
|
|
return BasicGroupId(update.basic_group_id_);
|
|
|
|
}
|
|
|
|
|
2020-10-04 16:46:38 +02:00
|
|
|
BasicGroupId getBasicGroupId(const td::td_api::chatTypeBasicGroup &chatType)
|
2020-10-04 15:17:04 +02:00
|
|
|
{
|
2020-10-04 16:46:38 +02:00
|
|
|
return BasicGroupId(chatType.basic_group_id_);
|
2020-10-04 15:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SupergroupId getSupergroupId(const td::td_api::updateSupergroupFullInfo &update)
|
|
|
|
{
|
|
|
|
return SupergroupId(update.supergroup_id_);
|
|
|
|
}
|
|
|
|
|
2020-10-04 16:46:38 +02:00
|
|
|
SupergroupId getSupergroupId(const td::td_api::chatTypeSupergroup &chatType)
|
2020-10-04 15:17:04 +02:00
|
|
|
{
|
2020-10-04 16:46:38 +02:00
|
|
|
return SupergroupId(chatType.supergroup_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
SecretChatId getSecretChatId(const td::td_api::chatTypeSecret &chatType)
|
|
|
|
{
|
|
|
|
return SecretChatId(chatType.secret_chat_id_);
|
2020-10-04 15:17:04 +02:00
|
|
|
}
|
2020-10-10 15:51:16 +02:00
|
|
|
|
|
|
|
MessageId getReplyMessageId(const td::td_api::message &message)
|
|
|
|
{
|
|
|
|
return MessageId(message.reply_to_message_id_);
|
|
|
|
}
|