Generate new links for topic messages.
This commit is contained in:
parent
54799d0024
commit
ff0c205fe9
@ -5114,8 +5114,8 @@ removeNotificationGroup notification_group_id:int32 max_notification_id:int32 =
|
|||||||
//@message_id Identifier of the message
|
//@message_id Identifier of the message
|
||||||
//@media_timestamp If not 0, timestamp from which the video/audio/video note/voice note playing must start, in seconds. The media can be in the message content or in its web page preview
|
//@media_timestamp If not 0, timestamp from which the video/audio/video note/voice note playing must start, in seconds. The media can be in the message content or in its web page preview
|
||||||
//@for_album Pass true to create a link for the whole media album
|
//@for_album Pass true to create a link for the whole media album
|
||||||
//@for_comment Pass true to create a link to the message as a channel post comment, or from a message thread
|
//@in_message_thread Pass true to create a link to the message as a channel post comment, in a message thread, or a forum topic
|
||||||
getMessageLink chat_id:int53 message_id:int53 media_timestamp:int32 for_album:Bool for_comment:Bool = MessageLink;
|
getMessageLink chat_id:int53 message_id:int53 media_timestamp:int32 for_album:Bool in_message_thread:Bool = MessageLink;
|
||||||
|
|
||||||
//@description Returns an HTML code for embedding the message. Available only for messages in supergroups and channels with a username
|
//@description Returns an HTML code for embedding the message. Available only for messages in supergroups and channels with a username
|
||||||
//@chat_id Identifier of the chat to which the message belongs
|
//@chat_id Identifier of the chat to which the message belongs
|
||||||
|
@ -19212,7 +19212,7 @@ bool MessagesManager::can_report_message_reactions(DialogId dialog_id, const Mes
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId full_message_id, int32 media_timestamp,
|
Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId full_message_id, int32 media_timestamp,
|
||||||
bool for_group, bool for_comment) {
|
bool for_group, bool in_message_thread) {
|
||||||
auto dialog_id = full_message_id.get_dialog_id();
|
auto dialog_id = full_message_id.get_dialog_id();
|
||||||
auto d = get_dialog_force(dialog_id, "get_message_link");
|
auto d = get_dialog_force(dialog_id, "get_message_link");
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
@ -19244,7 +19244,7 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId
|
|||||||
dialog_id = m->forward_info->sender_dialog_id;
|
dialog_id = m->forward_info->sender_dialog_id;
|
||||||
message_id = m->forward_info->message_id;
|
message_id = m->forward_info->message_id;
|
||||||
for_group = false;
|
for_group = false;
|
||||||
for_comment = false;
|
in_message_thread = false;
|
||||||
auto channel_message = get_message({dialog_id, message_id});
|
auto channel_message = get_message({dialog_id, message_id});
|
||||||
if (channel_message != nullptr && channel_message->media_album_id == 0) {
|
if (channel_message != nullptr && channel_message->media_album_id == 0) {
|
||||||
for_group = true; // default is true
|
for_group = true; // default is true
|
||||||
@ -19255,14 +19255,9 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m->top_thread_message_id.is_valid() || !m->top_thread_message_id.is_server()) {
|
if (!m->top_thread_message_id.is_valid() || !m->top_thread_message_id.is_server() ||
|
||||||
for_comment = false;
|
is_deleted_message(d, m->top_thread_message_id) || is_broadcast_channel(dialog_id)) {
|
||||||
}
|
in_message_thread = false;
|
||||||
if (is_deleted_message(d, m->top_thread_message_id)) {
|
|
||||||
for_comment = false;
|
|
||||||
}
|
|
||||||
if (for_comment && is_broadcast_channel(dialog_id)) {
|
|
||||||
for_comment = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!td_->auth_manager_->is_bot()) {
|
if (!td_->auth_manager_->is_bot()) {
|
||||||
@ -19273,7 +19268,8 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId
|
|||||||
SliceBuilder sb;
|
SliceBuilder sb;
|
||||||
sb << td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
sb << td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
||||||
|
|
||||||
if (for_comment) {
|
if (in_message_thread) {
|
||||||
|
// try to generate a comment link
|
||||||
auto *top_m = get_message_force(d, m->top_thread_message_id, "get_public_message_link");
|
auto *top_m = get_message_force(d, m->top_thread_message_id, "get_public_message_link");
|
||||||
if (is_discussion_message(dialog_id, top_m) && is_active_message_reply_info(dialog_id, top_m->reply_info)) {
|
if (is_discussion_message(dialog_id, top_m) && is_active_message_reply_info(dialog_id, top_m->reply_info)) {
|
||||||
auto linked_dialog_id = top_m->forward_info->from_dialog_id;
|
auto linked_dialog_id = top_m->forward_info->from_dialog_id;
|
||||||
@ -19311,10 +19307,16 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId
|
|||||||
} else {
|
} else {
|
||||||
sb << "c/" << dialog_id.get_channel_id().get();
|
sb << "c/" << dialog_id.get_channel_id().get();
|
||||||
}
|
}
|
||||||
|
if (in_message_thread && td_->contacts_manager_->is_forum_channel(dialog_id.get_channel_id())) {
|
||||||
|
if (m->top_thread_message_id != message_id) {
|
||||||
|
sb << '/' << m->top_thread_message_id.get_server_message_id().get();
|
||||||
|
}
|
||||||
|
in_message_thread = false;
|
||||||
|
}
|
||||||
sb << '/' << message_id.get_server_message_id().get();
|
sb << '/' << message_id.get_server_message_id().get();
|
||||||
|
|
||||||
char separator = '?';
|
char separator = '?';
|
||||||
if (for_comment) {
|
if (in_message_thread) {
|
||||||
sb << separator << "thread=" << m->top_thread_message_id.get_server_message_id().get();
|
sb << separator << "thread=" << m->top_thread_message_id.get_server_message_id().get();
|
||||||
separator = '&';
|
separator = '&';
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ class MessagesManager final : public Actor {
|
|||||||
bool is_deleted_secret_chat(DialogId dialog_id) const;
|
bool is_deleted_secret_chat(DialogId dialog_id) const;
|
||||||
|
|
||||||
Result<std::pair<string, bool>> get_message_link(FullMessageId full_message_id, int32 media_timestamp, bool for_group,
|
Result<std::pair<string, bool>> get_message_link(FullMessageId full_message_id, int32 media_timestamp, bool for_group,
|
||||||
bool for_comment);
|
bool in_message_thread);
|
||||||
|
|
||||||
string get_message_embedding_code(FullMessageId full_message_id, bool for_group, Promise<Unit> &&promise);
|
string get_message_embedding_code(FullMessageId full_message_id, bool for_group, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -4668,7 +4668,7 @@ void Td::on_request(uint64 id, const td_api::getMessageViewers &request) {
|
|||||||
void Td::on_request(uint64 id, const td_api::getMessageLink &request) {
|
void Td::on_request(uint64 id, const td_api::getMessageLink &request) {
|
||||||
auto r_message_link =
|
auto r_message_link =
|
||||||
messages_manager_->get_message_link({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
messages_manager_->get_message_link({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
||||||
request.media_timestamp_, request.for_album_, request.for_comment_);
|
request.media_timestamp_, request.for_album_, request.in_message_thread_);
|
||||||
if (r_message_link.is_error()) {
|
if (r_message_link.is_error()) {
|
||||||
send_closure(actor_id(this), &Td::send_error, id, r_message_link.move_as_error());
|
send_closure(actor_id(this), &Td::send_error, id, r_message_link.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user