Minor fixes.

GitOrigin-RevId: 49ed5d6671efa92dec7b09fa8e7863e3665ea355
This commit is contained in:
levlam 2019-06-12 16:05:22 +03:00
parent 3a2bdc5031
commit e5f068e47a
8 changed files with 42 additions and 30 deletions

View File

@ -9,10 +9,13 @@
#include "td/telegram/secret_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/files/FileEncryptionKey.h"
#include "td/telegram/files/FileLocation.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/UserId.h"
#include "td/utils/base64.h"
#include "td/utils/common.h"
@ -27,6 +30,30 @@
namespace td {
tl_object_ptr<telegram_api::InputPeer> OfflineInputPeer::get_input_peer() const {
switch (dialog_id.get_type()) {
case DialogType::User: {
UserId user_id = dialog_id.get_user_id();
return make_tl_object<telegram_api::inputPeerUser>(user_id.get(), dialog_access_hash);
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return make_tl_object<telegram_api::inputPeerChat>(chat_id.get());
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return make_tl_object<telegram_api::inputPeerChannel>(channel_id.get(), dialog_access_hash);
}
case DialogType::SecretChat:
return nullptr;
case DialogType::None:
return make_tl_object<telegram_api::inputPeerEmpty>();
default:
UNREACHABLE();
return nullptr;
}
}
static uint16 get_dimension(int32 size) {
if (size < 0 || size > 65535) {
LOG(ERROR) << "Wrong image dimension = " << size;

View File

@ -56,7 +56,7 @@ struct OfflineInputStickerSet {
: sticker_set_id(sticker_set_id), sticker_set_access_hash(sticker_set_access_hash) {
}
tl_object_ptr<telegram_api::InputStickerSet> as_telegram_api() const {
tl_object_ptr<telegram_api::InputStickerSet> get_input_sticker_set() const {
return make_tl_object<telegram_api::inputStickerSetID>(sticker_set_id, sticker_set_access_hash);
}
@ -85,29 +85,7 @@ struct OfflineInputPeer {
: dialog_id(dialog_id), dialog_access_hash(dialog_access_hash) {
}
tl_object_ptr<telegram_api::InputPeer> as_telegram_api() const {
switch (dialog_id.get_type()) {
case DialogType::User: {
UserId user_id = dialog_id.get_user_id();
return make_tl_object<telegram_api::inputPeerUser>(user_id.get(), dialog_access_hash);
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return make_tl_object<telegram_api::inputPeerChat>(chat_id.get());
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return make_tl_object<telegram_api::inputPeerChannel>(channel_id.get(), dialog_access_hash);
}
case DialogType::SecretChat:
return nullptr;
case DialogType::None:
return make_tl_object<telegram_api::inputPeerEmpty>();
default:
UNREACHABLE();
return nullptr;
}
}
tl_object_ptr<telegram_api::InputPeer> get_input_peer() const;
template <class StorerT>
void store(StorerT &storer) const;

View File

@ -6,7 +6,6 @@
//
#pragma once
#include "td/telegram/DialogId.h"
#include "td/telegram/Photo.h"
#include "td/telegram/files/FileId.hpp"

View File

@ -27,6 +27,7 @@
#include "td/telegram/MessagesManager.h"
#include "td/telegram/misc.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/MtprotoHeader.h"
#include "td/telegram/StickersManager.hpp"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
@ -34,6 +35,7 @@
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"
#include "td/db/SqliteKeyValue.h"
#include "td/db/SqliteKeyValueAsync.h"
#include "td/utils/format.h"
@ -43,6 +45,7 @@
#include "td/utils/Slice.h"
#include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/utf8.h"
#include <algorithm>
#include <type_traits>
@ -4792,7 +4795,7 @@ void StickersManager::on_get_language_codes(const string &key, Result<vector<str
if (result.is_error()) {
if (!G()->close_flag()) {
LOG(ERROR) << "Reseive " << result.error() << " from GetEmojiKeywordsLanguageQuery";
LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsLanguageQuery";
}
for (auto &promise : promises) {
promise.set_error(result.error().clone());
@ -4887,7 +4890,7 @@ void StickersManager::on_get_emoji_keywords(
if (result.is_error()) {
if (!G()->close_flag()) {
LOG(ERROR) << "Reseive " << result.error() << " from GetEmojiKeywordsQuery";
LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsQuery";
}
for (auto &promise : promises) {
promise.set_error(result.error().clone());
@ -4969,7 +4972,7 @@ void StickersManager::on_get_emoji_keywords_difference(
Result<telegram_api::object_ptr<telegram_api::emojiKeywordsDifference>> &&result) {
if (result.is_error()) {
if (!G()->close_flag()) {
LOG(ERROR) << "Reseive " << result.error() << " from GetEmojiKeywordsDifferenceQuery";
LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsDifferenceQuery";
}
emoji_language_code_last_difference_times_[language_code] = Time::now_cached() - EMOJI_KEYWORDS_UPDATE_DELAY - 2;
return;

View File

@ -12,6 +12,7 @@
#include "td/telegram/AudiosManager.hpp"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/DocumentsManager.hpp"
#include "td/telegram/files/FileId.h"

View File

@ -15,6 +15,7 @@
#include "td/telegram/files/FileLocation.hpp"
#include "td/telegram/Global.h"
#include "td/telegram/Td.h"
#include "td/telegram/Version.h"
#include "td/utils/common.h"
#include "td/utils/misc.h"

View File

@ -18,6 +18,7 @@
#include "td/utils/common.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/Slice.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/Variant.h"
@ -500,12 +501,12 @@ class FullRemoteFileLocation {
auto &dialog_photo = photo().source_.dialog_photo();
return make_tl_object<telegram_api::inputPeerPhotoFileLocation>(
dialog_photo.is_big * telegram_api::inputPeerPhotoFileLocation::Flags::BIG_MASK, dialog_photo.is_big,
dialog_photo.input_peer.as_telegram_api(), photo().volume_id_, photo().local_id_);
dialog_photo.input_peer.get_input_peer(), photo().volume_id_, photo().local_id_);
}
case PhotoSizeSource::Type::StickerSetThumbnail: {
auto &sticker_set_thumbnail = photo().source_.sticker_set_thumbnail();
return make_tl_object<telegram_api::inputStickerSetThumb>(
sticker_set_thumbnail.input_sticker_set.as_telegram_api(), photo().volume_id_, photo().local_id_);
sticker_set_thumbnail.input_sticker_set.get_input_sticker_set(), photo().volume_id_, photo().local_id_);
}
}
}

View File

@ -20,6 +20,7 @@
#include "td/telegram/misc.h"
#include "td/telegram/SecureStorage.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/Version.h"
#include "td/actor/SleepActor.h"
@ -35,6 +36,7 @@
#include "td/utils/ScopeGuard.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/tl_parsers.h"
#include <algorithm>
#include <cmath>