Move get_background_url to LinkManager.
This commit is contained in:
parent
a54ddc8830
commit
eecec61fa9
@ -449,23 +449,6 @@ void BackgroundManager::get_backgrounds(bool for_dark_theme,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<string> BackgroundManager::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 link = type.get_link();
|
|
||||||
if (type.has_file()) {
|
|
||||||
url += name;
|
|
||||||
if (!link.empty()) {
|
|
||||||
url += '?';
|
|
||||||
url += link;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
url += link;
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BackgroundManager::reload_background_from_server(
|
void BackgroundManager::reload_background_from_server(
|
||||||
BackgroundId background_id, const string &background_name,
|
BackgroundId background_id, const string &background_name,
|
||||||
telegram_api::object_ptr<telegram_api::InputWallPaper> &&input_wallpaper, Promise<Unit> &&promise) const {
|
telegram_api::object_ptr<telegram_api::InputWallPaper> &&input_wallpaper, Promise<Unit> &&promise) const {
|
||||||
|
@ -35,9 +35,6 @@ class BackgroundManager final : public Actor {
|
|||||||
|
|
||||||
void get_backgrounds(bool for_dark_theme, Promise<td_api::object_ptr<td_api::backgrounds>> &&promise);
|
void get_backgrounds(bool for_dark_theme, Promise<td_api::object_ptr<td_api::backgrounds>> &&promise);
|
||||||
|
|
||||||
static Result<string> get_background_url(const string &name,
|
|
||||||
td_api::object_ptr<td_api::BackgroundType> background_type);
|
|
||||||
|
|
||||||
void reload_background(BackgroundId background_id, int64 access_hash, Promise<Unit> &&promise);
|
void reload_background(BackgroundId background_id, int64 access_hash, Promise<Unit> &&promise);
|
||||||
|
|
||||||
std::pair<BackgroundId, BackgroundType> search_background(const string &name, Promise<Unit> &&promise);
|
std::pair<BackgroundId, BackgroundType> search_background(const string &name, Promise<Unit> &&promise);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "td/telegram/LinkManager.h"
|
#include "td/telegram/LinkManager.h"
|
||||||
|
|
||||||
#include "td/telegram/AccessRights.h"
|
#include "td/telegram/AccessRights.h"
|
||||||
|
#include "td/telegram/BackgroundType.h"
|
||||||
#include "td/telegram/ChannelId.h"
|
#include "td/telegram/ChannelId.h"
|
||||||
#include "td/telegram/ChannelType.h"
|
#include "td/telegram/ChannelType.h"
|
||||||
#include "td/telegram/ConfigManager.h"
|
#include "td/telegram/ConfigManager.h"
|
||||||
@ -1573,6 +1574,23 @@ void LinkManager::get_link_login_url(const string &url, bool allow_write_access,
|
|||||||
td_->create_handler<AcceptUrlAuthQuery>(std::move(promise))->send(url, FullMessageId(), 0, allow_write_access);
|
td_->create_handler<AcceptUrlAuthQuery>(std::move(promise))->send(url, FullMessageId(), 0, 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 link = type.get_link();
|
||||||
|
if (type.has_file()) {
|
||||||
|
url += name;
|
||||||
|
if (!link.empty()) {
|
||||||
|
url += '?';
|
||||||
|
url += link;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
url += link;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
string LinkManager::get_dialog_invite_link_hash(Slice invite_link) {
|
string LinkManager::get_dialog_invite_link_hash(Slice invite_link) {
|
||||||
auto link_info = get_link_info(invite_link);
|
auto link_info = get_link_info(invite_link);
|
||||||
if (link_info.type_ != LinkType::Tg && link_info.type_ != LinkType::TMe) {
|
if (link_info.type_ != LinkType::Tg && link_info.type_ != LinkType::TMe) {
|
||||||
|
@ -75,6 +75,9 @@ class LinkManager final : public Actor {
|
|||||||
void get_link_login_url(const string &url, bool allow_write_access,
|
void get_link_login_url(const string &url, bool allow_write_access,
|
||||||
Promise<td_api::object_ptr<td_api::httpUrl>> &&promise);
|
Promise<td_api::object_ptr<td_api::httpUrl>> &&promise);
|
||||||
|
|
||||||
|
static Result<string> get_background_url(const string &name,
|
||||||
|
td_api::object_ptr<td_api::BackgroundType> background_type);
|
||||||
|
|
||||||
static string get_dialog_invite_link_hash(Slice invite_link);
|
static string get_dialog_invite_link_hash(Slice invite_link);
|
||||||
|
|
||||||
static string get_dialog_invite_link(Slice hash, bool is_internal);
|
static string get_dialog_invite_link(Slice hash, bool is_internal);
|
||||||
|
@ -7761,7 +7761,7 @@ void Td::on_request(uint64 id, const td_api::getBackgrounds &request) {
|
|||||||
void Td::on_request(uint64 id, td_api::getBackgroundUrl &request) {
|
void Td::on_request(uint64 id, td_api::getBackgroundUrl &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CLEAN_INPUT_STRING(request.name_);
|
CLEAN_INPUT_STRING(request.name_);
|
||||||
Result<string> r_url = background_manager_->get_background_url(request.name_, std::move(request.type_));
|
Result<string> r_url = LinkManager::get_background_url(request.name_, std::move(request.type_));
|
||||||
if (r_url.is_error()) {
|
if (r_url.is_error()) {
|
||||||
return send_closure(actor_id(this), &Td::send_error, id, r_url.move_as_error());
|
return send_closure(actor_id(this), &Td::send_error, id, r_url.move_as_error());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user