Improve getForumTopicLink.
This commit is contained in:
parent
a4fc556e5e
commit
0a0387e8f5
@ -4528,12 +4528,12 @@ internalLinkTypeUserToken token:string = InternalLinkType;
|
||||
internalLinkTypeVideoChat chat_username:string invite_hash:string is_live_stream:Bool = InternalLinkType;
|
||||
|
||||
|
||||
//@description Contains an HTTPS link to a message in a supergroup or channel @link Message link @is_public True, if the link will work for non-members of the chat
|
||||
//@description Contains an HTTPS link to a message in a supergroup or channel, or a forum topic @link The link @is_public True, if the link will work for non-members of the chat
|
||||
messageLink link:string is_public:Bool = MessageLink;
|
||||
|
||||
//@description Contains information about a link to a message or a forum topic in a chat
|
||||
//@is_public True, if the link is a public link for a message in a chat
|
||||
//@chat_id If found, identifier of the chat to which the message belongs, 0 otherwise
|
||||
//@is_public True, if the link is a public link for a message or a forum topic in a chat
|
||||
//@chat_id If found, identifier of the chat to which the link points, 0 otherwise
|
||||
//@message_thread_id If found, identifier of the message thread in which to open the message, or a forum topic to open if the message is missing
|
||||
//@message If found, the linked message; may be null
|
||||
//@media_timestamp Timestamp from which the video/audio/video note/voice note playing must start, in seconds; 0 if not specified. The media can be in the message content or in its web page preview
|
||||
@ -6074,7 +6074,7 @@ editForumTopic chat_id:int53 message_thread_id:int53 name:string edit_icon_custo
|
||||
getForumTopic chat_id:int53 message_thread_id:int53 = ForumTopic;
|
||||
|
||||
//@description Returns an HTTPS link to a topic in a forum chat. This is an offline request @chat_id Identifier of the chat @message_thread_id Message thread identifier of the forum topic
|
||||
getForumTopicLink chat_id:int53 message_thread_id:int53 = HttpUrl;
|
||||
getForumTopicLink chat_id:int53 message_thread_id:int53 = MessageLink;
|
||||
|
||||
//@description Returns found forum topics in a forum chat. This is a temporary method for getting information about topic list from the server
|
||||
//@chat_id Identifier of the forum chat
|
||||
|
@ -589,7 +589,7 @@ void ForumTopicManager::on_get_forum_topic(ChannelId channel_id, MessageId expec
|
||||
}
|
||||
|
||||
void ForumTopicManager::get_forum_topic_link(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Promise<string> &&promise) {
|
||||
Promise<td_api::object_ptr<td_api::messageLink>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
|
||||
TRY_STATUS_PROMISE(promise, can_be_message_thread_id(top_thread_message_id));
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
@ -597,15 +597,17 @@ void ForumTopicManager::get_forum_topic_link(DialogId dialog_id, MessageId top_t
|
||||
SliceBuilder sb;
|
||||
sb << td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
||||
|
||||
bool is_public = false;
|
||||
auto dialog_username = td_->contacts_manager_->get_channel_first_username(channel_id);
|
||||
if (!dialog_username.empty()) {
|
||||
sb << dialog_username;
|
||||
is_public = true;
|
||||
} else {
|
||||
sb << "c/" << channel_id.get();
|
||||
}
|
||||
sb << '/' << top_thread_message_id.get_server_message_id().get();
|
||||
|
||||
promise.set_value(sb.as_cslice().str());
|
||||
promise.set_value(td_api::make_object<td_api::messageLink>(sb.as_cslice().str(), is_public));
|
||||
}
|
||||
|
||||
void ForumTopicManager::get_forum_topics(DialogId dialog_id, string query, int32 offset_date,
|
||||
|
@ -59,7 +59,8 @@ class ForumTopicManager final : public Actor {
|
||||
vector<telegram_api::object_ptr<telegram_api::ForumTopic>> &&topics,
|
||||
Promise<td_api::object_ptr<td_api::forumTopics>> &&promise);
|
||||
|
||||
void get_forum_topic_link(DialogId dialog_id, MessageId top_thread_message_id, Promise<string> &&promise);
|
||||
void get_forum_topic_link(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Promise<td_api::object_ptr<td_api::messageLink>> &&promise);
|
||||
|
||||
void get_forum_topics(DialogId dialog_id, string query, int32 offset_date, MessageId offset_message_id,
|
||||
MessageId offset_top_thread_message_id, int32 limit,
|
||||
|
@ -5565,15 +5565,8 @@ void Td::on_request(uint64 id, const td_api::getForumTopic &request) {
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getForumTopicLink &request) {
|
||||
CREATE_REQUEST_PROMISE();
|
||||
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
} else {
|
||||
promise.set_value(td_api::make_object<td_api::httpUrl>(result.move_as_ok()));
|
||||
}
|
||||
});
|
||||
forum_topic_manager_->get_forum_topic_link(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
||||
std::move(query_promise));
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getForumTopics &request) {
|
||||
|
Loading…
Reference in New Issue
Block a user