Skip to content

Commit

Permalink
Update layer to 133.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Sep 3, 2021
1 parent 0b6d40b commit 41c391f
Show file tree
Hide file tree
Showing 54 changed files with 635 additions and 577 deletions.
4 changes: 2 additions & 2 deletions benchmark/bench_tddb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class MessagesDbBench final : public Benchmark {
void run(int n) final {
auto guard = scheduler_->get_main_guard();
for (int i = 0; i < n; i += 20) {
auto dialog_id = DialogId{UserId{Random::fast(1, 100)}};
auto dialog_id = DialogId(UserId(static_cast<int64>(Random::fast(1, 100))));
auto message_id_raw = Random::fast(1, 100000);
for (int j = 0; j < 20; j++) {
auto message_id = MessageId{ServerMessageId{message_id_raw + j}};
auto unique_message_id = ServerMessageId{i + 1};
auto sender_user_id = UserId{Random::fast(1, 1000)};
auto sender_user_id = UserId(static_cast<int64>(Random::fast(1, 1000)));
auto random_id = i + 1;
auto ttl_expires_at = 0;
auto data = BufferSlice(Random::fast(100, 299));
Expand Down
4 changes: 2 additions & 2 deletions example/cpp/td_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class TdExample {

std::map<std::uint64_t, std::function<void(Object)>> handlers_;

std::map<std::int32_t, td_api::object_ptr<td_api::user>> users_;
std::map<std::int64_t, td_api::object_ptr<td_api::user>> users_;

std::map<std::int64_t, std::string> chat_title_;

Expand Down Expand Up @@ -174,7 +174,7 @@ class TdExample {
}
}

std::string get_user_name(std::int32_t user_id) const {
std::string get_user_name(std::int64_t user_id) const {
auto it = users_.find(user_id);
if (it == users_.end()) {
return "unknown user";
Expand Down
12 changes: 6 additions & 6 deletions example/java/org/drinkless/tdlib/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ public final class Example {
private static final Lock authorizationLock = new ReentrantLock();
private static final Condition gotAuthorization = authorizationLock.newCondition();

private static final ConcurrentMap<Integer, TdApi.User> users = new ConcurrentHashMap<Integer, TdApi.User>();
private static final ConcurrentMap<Integer, TdApi.BasicGroup> basicGroups = new ConcurrentHashMap<Integer, TdApi.BasicGroup>();
private static final ConcurrentMap<Integer, TdApi.Supergroup> supergroups = new ConcurrentHashMap<Integer, TdApi.Supergroup>();
private static final ConcurrentMap<Long, TdApi.User> users = new ConcurrentHashMap<Long, TdApi.User>();
private static final ConcurrentMap<Long, TdApi.BasicGroup> basicGroups = new ConcurrentHashMap<Long, TdApi.BasicGroup>();
private static final ConcurrentMap<Long, TdApi.Supergroup> supergroups = new ConcurrentHashMap<Long, TdApi.Supergroup>();
private static final ConcurrentMap<Integer, TdApi.SecretChat> secretChats = new ConcurrentHashMap<Integer, TdApi.SecretChat>();

private static final ConcurrentMap<Long, TdApi.Chat> chats = new ConcurrentHashMap<Long, TdApi.Chat>();
private static final NavigableSet<OrderedChat> mainChatList = new TreeSet<OrderedChat>();
private static boolean haveFullMainChatList = false;

private static final ConcurrentMap<Integer, TdApi.UserFullInfo> usersFullInfo = new ConcurrentHashMap<Integer, TdApi.UserFullInfo>();
private static final ConcurrentMap<Integer, TdApi.BasicGroupFullInfo> basicGroupsFullInfo = new ConcurrentHashMap<Integer, TdApi.BasicGroupFullInfo>();
private static final ConcurrentMap<Integer, TdApi.SupergroupFullInfo> supergroupsFullInfo = new ConcurrentHashMap<Integer, TdApi.SupergroupFullInfo>();
private static final ConcurrentMap<Long, TdApi.UserFullInfo> usersFullInfo = new ConcurrentHashMap<Long, TdApi.UserFullInfo>();
private static final ConcurrentMap<Long, TdApi.BasicGroupFullInfo> basicGroupsFullInfo = new ConcurrentHashMap<Long, TdApi.BasicGroupFullInfo>();
private static final ConcurrentMap<Long, TdApi.SupergroupFullInfo> supergroupsFullInfo = new ConcurrentHashMap<Long, TdApi.SupergroupFullInfo>();

private static final String newLine = System.getProperty("line.separator");
private static final String commandsLine = "Enter command (gcs - GetChats, gc <chatId> - GetChat, me - GetMe, sm <chatId> <message> - SendMessage, lo - LogOut, q - Quit): ";
Expand Down
225 changes: 111 additions & 114 deletions td/generate/scheme/td_api.tl

Large diffs are not rendered by default.

336 changes: 170 additions & 166 deletions td/generate/scheme/telegram_api.tl

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions td/telegram/AnimationsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GetSavedGifsQuery final : public Td::ResultHandler {
bool is_repair_ = false;

public:
void send(bool is_repair, int32 hash) {
void send(bool is_repair, int64 hash) {
is_repair_ = is_repair;
LOG(INFO) << "Send get saved animations request with hash = " << hash;
send_query(G()->net_query_creator().create(telegram_api::messages_getSavedGifs(hash)));
Expand Down Expand Up @@ -664,9 +664,9 @@ void AnimationsManager::on_get_saved_animations_failed(bool is_repair, Status er
}
}

int32 AnimationsManager::get_saved_animations_hash(const char *source) const {
vector<uint32> numbers;
numbers.reserve(saved_animation_ids_.size() * 2);
int64 AnimationsManager::get_saved_animations_hash(const char *source) const {
vector<uint64> numbers;
numbers.reserve(saved_animation_ids_.size());
for (auto animation_id : saved_animation_ids_) {
auto animation = get_animation(animation_id);
CHECK(animation != nullptr);
Expand All @@ -676,9 +676,7 @@ int32 AnimationsManager::get_saved_animations_hash(const char *source) const {
LOG(ERROR) << "Saved animation remote location is not document: " << source << " " << file_view.remote_location();
continue;
}
auto id = static_cast<uint64>(file_view.remote_location().get_id());
numbers.push_back(static_cast<uint32>(id >> 32));
numbers.push_back(static_cast<uint32>(id & 0xFFFFFFFF));
numbers.push_back(file_view.remote_location().get_id());
}
return get_vector_hash(numbers);
}
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/AnimationsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class AnimationsManager final : public Actor {

FileId on_get_animation(unique_ptr<Animation> new_animation, bool replace);

int32 get_saved_animations_hash(const char *source) const;
int64 get_saved_animations_hash(const char *source) const;

void add_saved_animation_impl(FileId animation_id, bool add_on_server, Promise<Unit> &&promise);

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/CallbackQueriesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void CallbackQueriesManager::on_new_query(int32 flags, int64 callback_query_id,

void CallbackQueriesManager::on_new_inline_query(
int32 flags, int64 callback_query_id, UserId sender_user_id,
tl_object_ptr<telegram_api::inputBotInlineMessageID> &&inline_message_id, BufferSlice &&data, int64 chat_instance,
tl_object_ptr<telegram_api::InputBotInlineMessageID> &&inline_message_id, BufferSlice &&data, int64 chat_instance,
string &&game_short_name) {
if (!sender_user_id.is_valid()) {
LOG(ERROR) << "Receive new callback query from invalid " << sender_user_id;
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/CallbackQueriesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CallbackQueriesManager {
MessageId message_id, BufferSlice &&data, int64 chat_instance, string &&game_short_name);

void on_new_inline_query(int32 flags, int64 callback_query_id, UserId sender_user_id,
tl_object_ptr<telegram_api::inputBotInlineMessageID> &&inline_message_id, BufferSlice &&data,
tl_object_ptr<telegram_api::InputBotInlineMessageID> &&inline_message_id, BufferSlice &&data,
int64 chat_instance, string &&game_short_name);

int64 send_callback_query(FullMessageId full_message_id, tl_object_ptr<td_api::CallbackQueryPayload> &&payload,
Expand Down
18 changes: 11 additions & 7 deletions td/telegram/ChannelId.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
namespace td {

class ChannelId {
int32 id = 0;
int64 id = 0;

public:
ChannelId() = default;

explicit ChannelId(int32 channel_id) : id(channel_id) {
explicit ChannelId(int64 channel_id) : id(channel_id) {
}
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
template <class T, typename = std::enable_if_t<std::is_convertible<T, int64>::value>>
ChannelId(T channel_id) = delete;

bool is_valid() const {
return id > 0; // TODO better is_valid
}

int32 get() const {
int64 get() const {
return id;
}

Expand All @@ -43,18 +43,22 @@ class ChannelId {

template <class StorerT>
void store(StorerT &storer) const {
storer.store_int(id);
storer.store_long(id);
}

template <class ParserT>
void parse(ParserT &parser) {
id = parser.fetch_int();
if (parser.version() >= static_cast<int32>(Version::Support64BitIds)) {
id = parser.fetch_long();
} else {
id = parser.fetch_int();
}
}
};

struct ChannelIdHash {
std::size_t operator()(ChannelId channel_id) const {
return std::hash<int32>()(channel_id.get());
return std::hash<int64>()(channel_id.get());
}
};

Expand Down
18 changes: 11 additions & 7 deletions td/telegram/ChatId.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
namespace td {

class ChatId {
int32 id = 0;
int64 id = 0;

public:
ChatId() = default;

explicit ChatId(int32 chat_id) : id(chat_id) {
explicit ChatId(int64 chat_id) : id(chat_id) {
}
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
template <class T, typename = std::enable_if_t<std::is_convertible<T, int64>::value>>
ChatId(T chat_id) = delete;

bool is_valid() const {
return id > 0;
}

int32 get() const {
int64 get() const {
return id;
}

Expand All @@ -43,18 +43,22 @@ class ChatId {

template <class StorerT>
void store(StorerT &storer) const {
storer.store_int(id);
storer.store_long(id);
}

template <class ParserT>
void parse(ParserT &parser) {
id = parser.fetch_int();
if (parser.version() >= static_cast<int32>(Version::Support64BitIds)) {
id = parser.fetch_long();
} else {
id = parser.fetch_int();
}
}
};

struct ChatIdHash {
std::size_t operator()(ChatId chat_id) const {
return std::hash<int32>()(chat_id.get());
return std::hash<int64>()(chat_id.get());
}
};

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/Contact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tl_object_ptr<telegram_api::inputMediaContact> Contact::get_input_media_contact(

SecretInputMedia Contact::get_secret_input_media_contact() const {
return SecretInputMedia{nullptr, make_tl_object<secret_api::decryptedMessageMediaContact>(
phone_number_, first_name_, last_name_, user_id_.get())};
phone_number_, first_name_, last_name_, static_cast<int32>(0))};
}

tl_object_ptr<telegram_api::inputPhoneContact> Contact::get_input_phone_contact(int64 client_id) const {
Expand Down
Loading

0 comments on commit 41c391f

Please sign in to comment.