Add td_api::inputStoryAreaTypeLink.
This commit is contained in:
parent
6ec0f4f1db
commit
2c87885379
@ -3882,6 +3882,9 @@ storyAreaTypeSuggestedReaction reaction_type:ReactionType total_count:int32 is_d
|
|||||||
//@description An area pointing to a message @chat_id Identifier of the chat with the message @message_id Identifier of the message
|
//@description An area pointing to a message @chat_id Identifier of the chat with the message @message_id Identifier of the message
|
||||||
storyAreaTypeMessage chat_id:int53 message_id:int53 = StoryAreaType;
|
storyAreaTypeMessage chat_id:int53 message_id:int53 = StoryAreaType;
|
||||||
|
|
||||||
|
//@description An area pointing to a HTTP or tg:// link @url HTTP or tg:// URL to be opened when the area is clicked
|
||||||
|
storyAreaTypeLink url:string = StoryAreaType;
|
||||||
|
|
||||||
|
|
||||||
//@description Describes a clickable rectangle area on a story media @position Position of the area @type Type of the area
|
//@description Describes a clickable rectangle area on a story media @position Position of the area @type Type of the area
|
||||||
storyArea position:storyAreaPosition type:StoryAreaType = StoryArea;
|
storyArea position:storyAreaPosition type:StoryAreaType = StoryArea;
|
||||||
@ -3913,6 +3916,10 @@ inputStoryAreaTypeSuggestedReaction reaction_type:ReactionType is_dark:Bool is_f
|
|||||||
//@message_id Identifier of the message. Only successfully sent non-scheduled messages can be specified
|
//@message_id Identifier of the message. Only successfully sent non-scheduled messages can be specified
|
||||||
inputStoryAreaTypeMessage chat_id:int53 message_id:int53 = InputStoryAreaType;
|
inputStoryAreaTypeMessage chat_id:int53 message_id:int53 = InputStoryAreaType;
|
||||||
|
|
||||||
|
//@description An area pointing to a HTTP or tg:// link
|
||||||
|
//@url HTTP or tg:// URL to be opened when the area is clicked
|
||||||
|
inputStoryAreaTypeLink url:string = InputStoryAreaType;
|
||||||
|
|
||||||
|
|
||||||
//@description Describes a clickable rectangle area on a story media to be added @position Position of the area @type Type of the area
|
//@description Describes a clickable rectangle area on a story media to be added @position Position of the area @type Type of the area
|
||||||
inputStoryArea position:storyAreaPosition type:InputStoryAreaType = InputStoryArea;
|
inputStoryArea position:storyAreaPosition type:InputStoryAreaType = InputStoryArea;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "td/telegram/InlineQueriesManager.h"
|
#include "td/telegram/InlineQueriesManager.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/MessagesManager.h"
|
#include "td/telegram/MessagesManager.h"
|
||||||
|
#include "td/telegram/misc.h"
|
||||||
#include "td/telegram/ServerMessageId.h"
|
#include "td/telegram/ServerMessageId.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
|
|
||||||
@ -73,8 +74,17 @@ MediaArea::MediaArea(Td *td, telegram_api::object_ptr<telegram_api::MediaArea> &
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case telegram_api::mediaAreaUrl::ID:
|
case telegram_api::mediaAreaUrl::ID: {
|
||||||
|
auto area = telegram_api::move_object_as<telegram_api::mediaAreaUrl>(media_area_ptr);
|
||||||
|
coordinates_ = MediaAreaCoordinates(area->coordinates_);
|
||||||
|
if (coordinates_.is_valid()) {
|
||||||
|
type_ = Type::Url;
|
||||||
|
url_ = std::move(area->url_);
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Receive " << to_string(area);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case telegram_api::inputMediaAreaVenue::ID:
|
case telegram_api::inputMediaAreaVenue::ID:
|
||||||
LOG(ERROR) << "Receive " << to_string(media_area_ptr);
|
LOG(ERROR) << "Receive " << to_string(media_area_ptr);
|
||||||
break;
|
break;
|
||||||
@ -169,6 +179,15 @@ MediaArea::MediaArea(Td *td, td_api::object_ptr<td_api::inputStoryArea> &&input_
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case td_api::inputStoryAreaTypeLink::ID: {
|
||||||
|
auto type = td_api::move_object_as<td_api::inputStoryAreaTypeLink>(input_story_area->type_);
|
||||||
|
if (!clean_input_string(type->url_)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
url_ = std::move(type->url_);
|
||||||
|
type_ = Type::Url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -205,6 +224,9 @@ td_api::object_ptr<td_api::storyArea> MediaArea::get_story_area_object(
|
|||||||
td->dialog_manager_->get_chat_id_object(message_full_id_.get_dialog_id(), "storyAreaTypeMessage"),
|
td->dialog_manager_->get_chat_id_object(message_full_id_.get_dialog_id(), "storyAreaTypeMessage"),
|
||||||
message_full_id_.get_message_id().get());
|
message_full_id_.get_message_id().get());
|
||||||
break;
|
break;
|
||||||
|
case Type::Url:
|
||||||
|
type = td_api::make_object<td_api::storyAreaTypeLink>(url_);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -237,20 +259,23 @@ telegram_api::object_ptr<telegram_api::MediaArea> MediaArea::get_input_media_are
|
|||||||
flags, false /*ignored*/, false /*ignored*/, coordinates_.get_input_media_area_coordinates(),
|
flags, false /*ignored*/, false /*ignored*/, coordinates_.get_input_media_area_coordinates(),
|
||||||
reaction_type_.get_input_reaction());
|
reaction_type_.get_input_reaction());
|
||||||
}
|
}
|
||||||
case Type::Message:
|
case Type::Message: {
|
||||||
|
auto channel_id = message_full_id_.get_dialog_id().get_channel_id();
|
||||||
|
auto server_message_id = message_full_id_.get_message_id().get_server_message_id();
|
||||||
if (!is_old_message_) {
|
if (!is_old_message_) {
|
||||||
auto input_channel = td->chat_manager_->get_input_channel(message_full_id_.get_dialog_id().get_channel_id());
|
auto input_channel = td->chat_manager_->get_input_channel(channel_id);
|
||||||
if (input_channel == nullptr) {
|
if (input_channel == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return telegram_api::make_object<telegram_api::inputMediaAreaChannelPost>(
|
return telegram_api::make_object<telegram_api::inputMediaAreaChannelPost>(
|
||||||
coordinates_.get_input_media_area_coordinates(), std::move(input_channel),
|
coordinates_.get_input_media_area_coordinates(), std::move(input_channel), server_message_id.get());
|
||||||
message_full_id_.get_message_id().get_server_message_id().get());
|
|
||||||
}
|
}
|
||||||
return telegram_api::make_object<telegram_api::mediaAreaChannelPost>(
|
return telegram_api::make_object<telegram_api::mediaAreaChannelPost>(
|
||||||
coordinates_.get_input_media_area_coordinates(),
|
coordinates_.get_input_media_area_coordinates(), channel_id.get(), server_message_id.get());
|
||||||
message_full_id_.get_message_id().get_server_message_id().get(),
|
}
|
||||||
message_full_id_.get_message_id().get_server_message_id().get());
|
case Type::Url:
|
||||||
|
return telegram_api::make_object<telegram_api::mediaAreaUrl>(coordinates_.get_input_media_area_coordinates(),
|
||||||
|
url_);
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -25,7 +25,7 @@ class Dependencies;
|
|||||||
class Td;
|
class Td;
|
||||||
|
|
||||||
class MediaArea {
|
class MediaArea {
|
||||||
enum class Type : int32 { None, Location, Venue, Reaction, Message };
|
enum class Type : int32 { None, Location, Venue, Reaction, Message, Url };
|
||||||
Type type_ = Type::None;
|
Type type_ = Type::None;
|
||||||
MediaAreaCoordinates coordinates_;
|
MediaAreaCoordinates coordinates_;
|
||||||
Location location_;
|
Location location_;
|
||||||
@ -34,6 +34,7 @@ class MediaArea {
|
|||||||
int64 input_query_id_ = 0;
|
int64 input_query_id_ = 0;
|
||||||
string input_result_id_;
|
string input_result_id_;
|
||||||
ReactionType reaction_type_;
|
ReactionType reaction_type_;
|
||||||
|
string url_;
|
||||||
bool is_dark_ = false;
|
bool is_dark_ = false;
|
||||||
bool is_flipped_ = false;
|
bool is_flipped_ = false;
|
||||||
bool is_old_message_ = false;
|
bool is_old_message_ = false;
|
||||||
|
@ -42,6 +42,9 @@ void MediaArea::store(StorerT &storer) const {
|
|||||||
case Type::Message:
|
case Type::Message:
|
||||||
store(message_full_id_, storer);
|
store(message_full_id_, storer);
|
||||||
break;
|
break;
|
||||||
|
case Type::Url:
|
||||||
|
store(url_, storer);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -76,6 +79,9 @@ void MediaArea::parse(ParserT &parser) {
|
|||||||
case Type::Message:
|
case Type::Message:
|
||||||
parse(message_full_id_, parser);
|
parse(message_full_id_, parser);
|
||||||
break;
|
break;
|
||||||
|
case Type::Url:
|
||||||
|
parse(url_, parser);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
parser.set_error("Load invalid area type");
|
parser.set_error("Load invalid area type");
|
||||||
}
|
}
|
||||||
|
@ -1379,6 +1379,8 @@ class CliClient final : public Actor {
|
|||||||
std::tie(chat_id, message_id) = split(area.substr(1), ':');
|
std::tie(chat_id, message_id) = split(area.substr(1), ':');
|
||||||
type = td_api::make_object<td_api::inputStoryAreaTypeMessage>(to_integer<int64>(chat_id),
|
type = td_api::make_object<td_api::inputStoryAreaTypeMessage>(to_integer<int64>(chat_id),
|
||||||
as_message_id(message_id));
|
as_message_id(message_id));
|
||||||
|
} else if (area[0] == 'u') {
|
||||||
|
type = td_api::make_object<td_api::inputStoryAreaTypeLink>(area.substr(1));
|
||||||
}
|
}
|
||||||
result->areas_.push_back(td_api::make_object<td_api::inputStoryArea>(std::move(position), std::move(type)));
|
result->areas_.push_back(td_api::make_object<td_api::inputStoryArea>(std::move(position), std::move(type)));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user