2023-08-01 14:17:50 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2023-08-01 14:17:50 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/Location.h"
|
|
|
|
#include "td/telegram/MediaAreaCoordinates.h"
|
2023-12-18 12:40:11 +01:00
|
|
|
#include "td/telegram/MessageFullId.h"
|
2023-08-25 15:37:27 +02:00
|
|
|
#include "td/telegram/ReactionType.h"
|
2023-08-01 14:17:50 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
#include "td/telegram/Venue.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
2023-09-19 20:59:14 +02:00
|
|
|
#include <utility>
|
|
|
|
|
2023-08-01 14:17:50 +02:00
|
|
|
namespace td {
|
|
|
|
|
2023-12-18 12:40:11 +01:00
|
|
|
class Dependencies;
|
2023-08-01 14:17:50 +02:00
|
|
|
class Td;
|
|
|
|
|
|
|
|
class MediaArea {
|
2024-06-07 15:13:58 +02:00
|
|
|
struct GeoPointAddress {
|
|
|
|
string country_iso2_;
|
|
|
|
string state_;
|
|
|
|
string city_;
|
|
|
|
string street_;
|
|
|
|
|
|
|
|
bool is_empty() const {
|
|
|
|
return country_iso2_.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
2024-06-05 14:56:55 +02:00
|
|
|
enum class Type : int32 { None, Location, Venue, Reaction, Message, Url };
|
2023-08-01 14:17:50 +02:00
|
|
|
Type type_ = Type::None;
|
|
|
|
MediaAreaCoordinates coordinates_;
|
|
|
|
Location location_;
|
2024-06-07 15:13:58 +02:00
|
|
|
GeoPointAddress address_;
|
2023-08-01 14:17:50 +02:00
|
|
|
Venue venue_;
|
2023-12-18 12:40:11 +01:00
|
|
|
MessageFullId message_full_id_;
|
2023-08-01 17:11:30 +02:00
|
|
|
int64 input_query_id_ = 0;
|
|
|
|
string input_result_id_;
|
2023-08-25 15:37:27 +02:00
|
|
|
ReactionType reaction_type_;
|
2024-06-05 14:56:55 +02:00
|
|
|
string url_;
|
2023-08-25 15:37:27 +02:00
|
|
|
bool is_dark_ = false;
|
|
|
|
bool is_flipped_ = false;
|
2023-12-18 12:40:11 +01:00
|
|
|
bool is_old_message_ = false;
|
2023-08-01 14:17:50 +02:00
|
|
|
|
|
|
|
friend bool operator==(const MediaArea &lhs, const MediaArea &rhs);
|
|
|
|
friend bool operator!=(const MediaArea &lhs, const MediaArea &rhs);
|
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const MediaArea &media_area);
|
|
|
|
|
2023-12-18 12:40:11 +01:00
|
|
|
telegram_api::object_ptr<telegram_api::MediaArea> get_input_media_area(const Td *td) const;
|
2023-12-18 12:24:07 +01:00
|
|
|
|
2023-08-01 14:17:50 +02:00
|
|
|
public:
|
|
|
|
MediaArea() = default;
|
|
|
|
|
|
|
|
MediaArea(Td *td, telegram_api::object_ptr<telegram_api::MediaArea> &&media_area_ptr);
|
|
|
|
|
2023-08-01 17:11:30 +02:00
|
|
|
MediaArea(Td *td, td_api::object_ptr<td_api::inputStoryArea> &&input_story_area,
|
|
|
|
const vector<MediaArea> &old_media_areas);
|
|
|
|
|
2023-08-25 18:11:24 +02:00
|
|
|
bool has_reaction_type(const ReactionType &reaction_type) const;
|
|
|
|
|
2023-09-19 12:09:59 +02:00
|
|
|
td_api::object_ptr<td_api::storyArea> get_story_area_object(
|
2023-12-18 12:40:11 +01:00
|
|
|
Td *td, const vector<std::pair<ReactionType, int32>> &reaction_counts) const;
|
2023-08-01 14:17:50 +02:00
|
|
|
|
2023-12-18 12:24:07 +01:00
|
|
|
static vector<telegram_api::object_ptr<telegram_api::MediaArea>> get_input_media_areas(
|
2023-12-18 12:40:11 +01:00
|
|
|
const Td *td, const vector<MediaArea> &media_areas);
|
2023-08-01 17:11:30 +02:00
|
|
|
|
2023-08-01 14:17:50 +02:00
|
|
|
bool is_valid() const {
|
|
|
|
return type_ != Type::None;
|
|
|
|
}
|
|
|
|
|
2023-12-18 12:40:11 +01:00
|
|
|
void add_dependencies(Dependencies &dependencies) const;
|
|
|
|
|
2023-08-01 14:17:50 +02:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const MediaArea &lhs, const MediaArea &rhs);
|
|
|
|
bool operator!=(const MediaArea &lhs, const MediaArea &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const MediaArea &media_area);
|
|
|
|
|
|
|
|
} // namespace td
|