Add for_group and for_comment in getMessageLink.
GitOrigin-RevId: 1ca027280f9e1013a1ad0ba20ed54ffbbcad2bb6
This commit is contained in:
parent
e7a835fd55
commit
1da8d859c9
@ -3685,14 +3685,16 @@ removeNotificationGroup notification_group_id:int32 max_notification_id:int32 =
|
|||||||
//@description Returns a public HTTPS link to a message. Available only for messages in supergroups and channels with a username
|
//@description Returns a public HTTPS link to a 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
|
||||||
//@message_id Identifier of the message
|
//@message_id Identifier of the message
|
||||||
//@for_album Pass true to create a link for a 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 a message as a channel post comment. The channel or the discussion supergroup must have a username
|
//@for_comment Pass true to create a link to the message as a channel post comment. The channel or the discussion supergroup must have a username
|
||||||
getPublicMessageLink chat_id:int53 message_id:int53 for_album:Bool for_comment:Bool = PublicMessageLink;
|
getPublicMessageLink chat_id:int53 message_id:int53 for_album:Bool for_comment:Bool = PublicMessageLink;
|
||||||
|
|
||||||
//@description Returns a private HTTPS link to a message in a chat. Available only for already sent messages in supergroups and channels. The link will work only for members of the chat
|
//@description Returns a private HTTPS link to a message in a chat. Available only for already sent messages in supergroups and channels. The link will work only for members of the chat
|
||||||
//@chat_id Identifier of the chat to which the message belongs
|
//@chat_id Identifier of the chat to which the message belongs
|
||||||
//@message_id Identifier of the message
|
//@message_id Identifier of the message
|
||||||
getMessageLink chat_id:int53 message_id:int53 = HttpUrl;
|
//@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
|
||||||
|
getMessageLink chat_id:int53 message_id:int53 for_album:Bool for_comment:Bool = HttpUrl;
|
||||||
|
|
||||||
//@description Returns information about a public or private message link @url The message link in the format "https://t.me/c/...", or "tg://privatepost?...", or "https://t.me/username/...", or "tg://resolve?..."
|
//@description Returns information about a public or private message link @url The message link in the format "https://t.me/c/...", or "tg://privatepost?...", or "https://t.me/username/...", or "tg://resolve?..."
|
||||||
getMessageLinkInfo url:string = MessageLinkInfo;
|
getMessageLinkInfo url:string = MessageLinkInfo;
|
||||||
|
Binary file not shown.
@ -15915,7 +15915,8 @@ void MessagesManager::on_get_public_message_link(FullMessageId full_message_id,
|
|||||||
std::move(url), std::move(html)};
|
std::move(url), std::move(html)};
|
||||||
}
|
}
|
||||||
|
|
||||||
string MessagesManager::get_message_link(FullMessageId full_message_id, Promise<Unit> &&promise) {
|
string MessagesManager::get_message_link(FullMessageId full_message_id, bool for_group, bool for_comment,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
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);
|
auto d = get_dialog_force(dialog_id);
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
@ -15946,12 +15947,33 @@ string MessagesManager::get_message_link(FullMessageId full_message_id, Promise<
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m->media_album_id == 0) {
|
||||||
|
for_group = true; // default is true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m->top_reply_message_id.is_valid() || !m->top_reply_message_id.is_server()) {
|
||||||
|
for_comment = false;
|
||||||
|
}
|
||||||
|
if (d->deleted_message_ids.count(m->top_reply_message_id) != 0) {
|
||||||
|
for_comment = false;
|
||||||
|
}
|
||||||
|
|
||||||
td_->create_handler<ExportChannelMessageLinkQuery>(Promise<Unit>())
|
td_->create_handler<ExportChannelMessageLinkQuery>(Promise<Unit>())
|
||||||
->send(dialog_id.get_channel_id(), m->message_id, false, true);
|
->send(dialog_id.get_channel_id(), m->message_id, for_group, true);
|
||||||
|
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
|
|
||||||
|
string args;
|
||||||
|
if (for_comment) {
|
||||||
|
args = PSTRING() << "?thread=" << m->top_reply_message_id.get_server_message_id().get();
|
||||||
|
}
|
||||||
|
if (!for_group) {
|
||||||
|
args += args.empty() ? '?' : '&';
|
||||||
|
args += "single";
|
||||||
|
}
|
||||||
|
|
||||||
return PSTRING() << G()->shared_config().get_option_string("t_me_url", "https://t.me/") << "c/"
|
return PSTRING() << G()->shared_config().get_option_string("t_me_url", "https://t.me/") << "c/"
|
||||||
<< dialog_id.get_channel_id().get() << "/" << m->message_id.get_server_message_id().get();
|
<< dialog_id.get_channel_id().get() << "/" << m->message_id.get_server_message_id().get() << args;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<MessagesManager::MessageLinkInfo> MessagesManager::get_message_link_info(Slice url) {
|
Result<MessagesManager::MessageLinkInfo> MessagesManager::get_message_link_info(Slice url) {
|
||||||
|
@ -579,7 +579,7 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
void on_get_public_message_link(FullMessageId full_message_id, bool for_group, string url, string html);
|
void on_get_public_message_link(FullMessageId full_message_id, bool for_group, string url, string html);
|
||||||
|
|
||||||
string get_message_link(FullMessageId full_message_id, Promise<Unit> &&promise);
|
string get_message_link(FullMessageId full_message_id, bool for_group, bool for_comment, Promise<Unit> &&promise);
|
||||||
|
|
||||||
struct MessageLinkInfo {
|
struct MessageLinkInfo {
|
||||||
string username;
|
string username;
|
||||||
|
@ -1142,11 +1142,13 @@ class GetPublicMessageLinkRequest : public RequestActor<> {
|
|||||||
|
|
||||||
class GetMessageLinkRequest : public RequestActor<> {
|
class GetMessageLinkRequest : public RequestActor<> {
|
||||||
FullMessageId full_message_id_;
|
FullMessageId full_message_id_;
|
||||||
|
bool for_group_;
|
||||||
|
bool for_comment_;
|
||||||
|
|
||||||
string link_;
|
string link_;
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) override {
|
void do_run(Promise<Unit> &&promise) override {
|
||||||
link_ = td->messages_manager_->get_message_link(full_message_id_, std::move(promise));
|
link_ = td->messages_manager_->get_message_link(full_message_id_, for_group_, for_comment_, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_send_result() override {
|
void do_send_result() override {
|
||||||
@ -1154,8 +1156,12 @@ class GetMessageLinkRequest : public RequestActor<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GetMessageLinkRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id)
|
GetMessageLinkRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id, bool for_group,
|
||||||
: RequestActor(std::move(td), request_id), full_message_id_(DialogId(dialog_id), MessageId(message_id)) {
|
bool for_comment)
|
||||||
|
: RequestActor(std::move(td), request_id)
|
||||||
|
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
||||||
|
, for_group_(for_group)
|
||||||
|
, for_comment_(for_comment) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5137,7 +5143,8 @@ void Td::on_request(uint64 id, const td_api::getPublicMessageLink &request) {
|
|||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::getMessageLink &request) {
|
void Td::on_request(uint64 id, const td_api::getMessageLink &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST(GetMessageLinkRequest, request.chat_id_, request.message_id_);
|
CREATE_REQUEST(GetMessageLinkRequest, request.chat_id_, request.message_id_, request.for_album_,
|
||||||
|
request.for_comment_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::getMessageLinkInfo &request) {
|
void Td::on_request(uint64 id, td_api::getMessageLinkInfo &request) {
|
||||||
|
@ -2630,8 +2630,13 @@ class CliClient final : public Actor {
|
|||||||
} else if (op == "gmlink") {
|
} else if (op == "gmlink") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string message_id;
|
string message_id;
|
||||||
std::tie(chat_id, message_id) = split(args);
|
string for_album;
|
||||||
send_request(td_api::make_object<td_api::getMessageLink>(as_chat_id(chat_id), as_message_id(message_id)));
|
string for_comment;
|
||||||
|
std::tie(chat_id, args) = split(args);
|
||||||
|
std::tie(message_id, args) = split(args);
|
||||||
|
std::tie(for_album, for_comment) = split(args);
|
||||||
|
send_request(td_api::make_object<td_api::getMessageLink>(as_chat_id(chat_id), as_message_id(message_id),
|
||||||
|
as_bool(for_album), as_bool(for_comment)));
|
||||||
} else if (op == "gmli") {
|
} else if (op == "gmli") {
|
||||||
send_request(td_api::make_object<td_api::getMessageLinkInfo>(args));
|
send_request(td_api::make_object<td_api::getMessageLinkInfo>(args));
|
||||||
} else if (op == "gcmbd") {
|
} else if (op == "gcmbd") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user