Add and use LinkManager::get_t_me_url().
This commit is contained in:
parent
b7ad8e8068
commit
319a3f1c39
@ -16,6 +16,7 @@
|
||||
#include "td/telegram/ForumTopicIcon.h"
|
||||
#include "td/telegram/ForumTopicInfo.hpp"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/MessageThreadDb.h"
|
||||
@ -724,7 +725,7 @@ void ForumTopicManager::get_forum_topic_link(DialogId dialog_id, MessageId top_t
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
|
||||
SliceBuilder sb;
|
||||
sb << td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
||||
sb << LinkManager::get_t_me_url();
|
||||
|
||||
bool is_public = false;
|
||||
auto dialog_username = td_->contacts_manager_->get_channel_first_username(channel_id);
|
||||
|
@ -1694,7 +1694,7 @@ void LinkManager::get_link_login_url(const string &url, bool allow_write_access,
|
||||
Result<string> LinkManager::get_background_url(const string &name,
|
||||
td_api::object_ptr<td_api::BackgroundType> background_type) {
|
||||
TRY_RESULT(type, BackgroundType::get_background_type(background_type.get()));
|
||||
auto url = PSTRING() << G()->get_option_string("t_me_url", "https://t.me/") << "bg/";
|
||||
auto url = PSTRING() << get_t_me_url() << "bg/";
|
||||
auto link = type.get_link();
|
||||
if (type.has_file()) {
|
||||
url += name;
|
||||
@ -1728,7 +1728,7 @@ string LinkManager::get_dialog_invite_link(Slice hash, bool is_internal) {
|
||||
if (is_internal) {
|
||||
return PSTRING() << "tg:join?invite=" << hash;
|
||||
} else {
|
||||
return PSTRING() << G()->get_option_string("t_me_url", "https://t.me/") << '+' << hash;
|
||||
return PSTRING() << get_t_me_url() << '+' << hash;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1759,12 +1759,11 @@ string LinkManager::get_instant_view_link_rhash(Slice link) {
|
||||
}
|
||||
|
||||
string LinkManager::get_instant_view_link(Slice url, Slice rhash) {
|
||||
return PSTRING() << G()->get_option_string("t_me_url", "https://t.me/") << "iv?url=" << url_encode(url)
|
||||
<< "&rhash=" << url_encode(rhash);
|
||||
return PSTRING() << get_t_me_url() << "iv?url=" << url_encode(url) << "&rhash=" << url_encode(rhash);
|
||||
}
|
||||
|
||||
string LinkManager::get_public_chat_link(Slice username) {
|
||||
return PSTRING() << G()->get_option_string("t_me_url", "https://t.me/") << url_encode(username);
|
||||
return PSTRING() << get_t_me_url() << url_encode(username);
|
||||
}
|
||||
|
||||
UserId LinkManager::get_link_user_id(Slice url) {
|
||||
@ -1809,6 +1808,14 @@ UserId LinkManager::get_link_user_id(Slice url) {
|
||||
return UserId();
|
||||
}
|
||||
|
||||
string LinkManager::get_t_me_url() {
|
||||
if (Scheduler::context() != nullptr) {
|
||||
return G()->get_option_string("t_me_url", "https://t.me/");
|
||||
} else {
|
||||
return "https://t.me/";
|
||||
}
|
||||
}
|
||||
|
||||
Result<CustomEmojiId> LinkManager::get_link_custom_emoji_id(Slice url) {
|
||||
string lower_cased_url = to_lower(url);
|
||||
url = lower_cased_url;
|
||||
|
@ -94,6 +94,8 @@ class LinkManager final : public Actor {
|
||||
|
||||
static UserId get_link_user_id(Slice url);
|
||||
|
||||
static string get_t_me_url();
|
||||
|
||||
static Result<CustomEmojiId> get_link_custom_emoji_id(Slice url);
|
||||
|
||||
static Result<MessageLinkInfo> get_message_link_info(Slice url);
|
||||
|
@ -19451,7 +19451,7 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId
|
||||
}
|
||||
|
||||
SliceBuilder sb;
|
||||
sb << td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
||||
sb << LinkManager::get_t_me_url();
|
||||
|
||||
if (in_message_thread && !is_forum) {
|
||||
// try to generate a comment link
|
||||
|
@ -177,9 +177,9 @@ td_api::object_ptr<td_api::sponsoredMessage> SponsoredMessageManager::get_sponso
|
||||
case DialogType::Channel:
|
||||
if (sponsored_message.server_message_id.is_valid()) {
|
||||
auto channel_id = sponsored_message.sponsor_dialog_id.get_channel_id();
|
||||
auto t_me = td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
||||
link = td_api::make_object<td_api::internalLinkTypeMessage>(
|
||||
PSTRING() << t_me << "c/" << channel_id.get() << '/' << sponsored_message.server_message_id.get());
|
||||
PSTRING() << LinkManager::get_t_me_url() << "c/" << channel_id.get() << '/'
|
||||
<< sponsored_message.server_message_id.get());
|
||||
}
|
||||
break;
|
||||
case DialogType::None: {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/net/MtprotoHeader.h"
|
||||
@ -233,7 +234,7 @@ void ConnectionCreator::get_proxy_link(int32 proxy_id, Promise<string> promise)
|
||||
}
|
||||
|
||||
auto &proxy = it->second;
|
||||
string url = G()->get_option_string("t_me_url", "https://t.me/");
|
||||
string url = LinkManager::get_t_me_url();
|
||||
bool is_socks = false;
|
||||
switch (proxy.type()) {
|
||||
case Proxy::Type::Socks5:
|
||||
|
Loading…
Reference in New Issue
Block a user