Add DialogLocation, td_api::chatLocation and td_api::chatEventLocationChanged.
GitOrigin-RevId: 5bd47788c58065b0b79119d7d84c1d851a400417
This commit is contained in:
parent
438300b2cf
commit
35b9d56c64
@ -375,6 +375,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/DhCache.cpp
|
td/telegram/DhCache.cpp
|
||||||
td/telegram/DialogDb.cpp
|
td/telegram/DialogDb.cpp
|
||||||
td/telegram/DialogId.cpp
|
td/telegram/DialogId.cpp
|
||||||
|
td/telegram/DialogLocation.cpp
|
||||||
td/telegram/DialogParticipant.cpp
|
td/telegram/DialogParticipant.cpp
|
||||||
td/telegram/Document.cpp
|
td/telegram/Document.cpp
|
||||||
td/telegram/DocumentsManager.cpp
|
td/telegram/DocumentsManager.cpp
|
||||||
@ -519,6 +520,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/DialogDate.h
|
td/telegram/DialogDate.h
|
||||||
td/telegram/DialogDb.h
|
td/telegram/DialogDb.h
|
||||||
td/telegram/DialogId.h
|
td/telegram/DialogId.h
|
||||||
|
td/telegram/DialogLocation.h
|
||||||
td/telegram/DialogParticipant.h
|
td/telegram/DialogParticipant.h
|
||||||
td/telegram/Document.h
|
td/telegram/Document.h
|
||||||
td/telegram/DocumentsManager.h
|
td/telegram/DocumentsManager.h
|
||||||
|
@ -288,6 +288,10 @@ botCommand command:string description:string = BotCommand;
|
|||||||
botInfo description:string commands:vector<botCommand> = BotInfo;
|
botInfo description:string commands:vector<botCommand> = BotInfo;
|
||||||
|
|
||||||
|
|
||||||
|
//@description Represents a location of a chat @location The location @address Location address; as defined by the chat creator
|
||||||
|
chatLocation location:location address:string = ChatLocation;
|
||||||
|
|
||||||
|
|
||||||
//@description Represents a user @id User identifier @first_name First name of the user @last_name Last name of the user @username Username of the user
|
//@description Represents a user @id User identifier @first_name First name of the user @last_name Last name of the user @username Username of the user
|
||||||
//@phone_number Phone number of the user @status Current online status of the user @profile_photo Profile photo of the user; may be null
|
//@phone_number Phone number of the user @status Current online status of the user @profile_photo Profile photo of the user; may be null
|
||||||
//@is_contact The user is a contact of the current user
|
//@is_contact The user is a contact of the current user
|
||||||
@ -1937,6 +1941,9 @@ chatEventSignMessagesToggled sign_messages:Bool = ChatEventAction;
|
|||||||
//@description The supergroup sticker set was changed @old_sticker_set_id Previous identifier of the chat sticker set; 0 if none @new_sticker_set_id New identifier of the chat sticker set; 0 if none
|
//@description The supergroup sticker set was changed @old_sticker_set_id Previous identifier of the chat sticker set; 0 if none @new_sticker_set_id New identifier of the chat sticker set; 0 if none
|
||||||
chatEventStickerSetChanged old_sticker_set_id:int64 new_sticker_set_id:int64 = ChatEventAction;
|
chatEventStickerSetChanged old_sticker_set_id:int64 new_sticker_set_id:int64 = ChatEventAction;
|
||||||
|
|
||||||
|
//@description The supergroup location was changed @old_location Previous location; may be null @new_location New location; may be null
|
||||||
|
chatEventLocationChanged old_location:chatLocation new_location:chatLocation = ChatEventAction;
|
||||||
|
|
||||||
//@description The is_all_history_available setting of a supergroup was toggled @is_all_history_available New value of is_all_history_available
|
//@description The is_all_history_available setting of a supergroup was toggled @is_all_history_available New value of is_all_history_available
|
||||||
chatEventIsAllHistoryAvailableToggled is_all_history_available:Bool = ChatEventAction;
|
chatEventIsAllHistoryAvailableToggled is_all_history_available:Bool = ChatEventAction;
|
||||||
|
|
||||||
|
Binary file not shown.
63
td/telegram/DialogLocation.cpp
Normal file
63
td/telegram/DialogLocation.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//
|
||||||
|
#include "td/telegram/DialogLocation.h"
|
||||||
|
|
||||||
|
#include "td/telegram/misc.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
DialogLocation::DialogLocation(telegram_api::object_ptr<telegram_api::ChannelLocation> &&channel_location_ptr) {
|
||||||
|
if (channel_location_ptr != nullptr && channel_location_ptr->get_id() == telegram_api::channelLocation::ID) {
|
||||||
|
auto channel_location = static_cast<telegram_api::channelLocation *>(channel_location_ptr.get());
|
||||||
|
location_ = Location(channel_location->geo_point_);
|
||||||
|
address_ = std::move(channel_location->address_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogLocation::DialogLocation(td_api::object_ptr<td_api::chatLocation> &&chat_location) {
|
||||||
|
if (chat_location != nullptr) {
|
||||||
|
location_ = Location(chat_location->location_);
|
||||||
|
address_ = std::move(chat_location->address_);
|
||||||
|
if (!clean_input_string(address_)) {
|
||||||
|
address_.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DialogLocation::empty() const {
|
||||||
|
return location_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::chatLocation> DialogLocation::get_chat_location_object() const {
|
||||||
|
if (empty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return td_api::make_object<td_api::chatLocation>(location_.get_location_object(), address_);
|
||||||
|
}
|
||||||
|
|
||||||
|
telegram_api::object_ptr<telegram_api::InputGeoPoint> DialogLocation::get_input_geo_point() const {
|
||||||
|
return location_.get_input_geo_point();
|
||||||
|
}
|
||||||
|
|
||||||
|
const string &DialogLocation::get_address() const {
|
||||||
|
return address_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const DialogLocation &lhs, const DialogLocation &rhs) {
|
||||||
|
return lhs.location_ == rhs.location_ && lhs.address_ == rhs.address_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const DialogLocation &lhs, const DialogLocation &rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const DialogLocation &location) {
|
||||||
|
return string_builder << "DialogLocation[location = " << location.location_ << ", address = " << location.address_
|
||||||
|
<< "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
63
td/telegram/DialogLocation.h
Normal file
63
td/telegram/DialogLocation.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
|
||||||
|
//
|
||||||
|
// 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/td_api.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/StringBuilder.h"
|
||||||
|
#include "td/utils/tl_helpers.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
class DialogLocation {
|
||||||
|
Location location_;
|
||||||
|
string address_;
|
||||||
|
|
||||||
|
friend bool operator==(const DialogLocation &lhs, const DialogLocation &rhs);
|
||||||
|
friend bool operator!=(const DialogLocation &lhs, const DialogLocation &rhs);
|
||||||
|
|
||||||
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogLocation &location);
|
||||||
|
|
||||||
|
public:
|
||||||
|
DialogLocation() = default;
|
||||||
|
|
||||||
|
DialogLocation(telegram_api::object_ptr<telegram_api::ChannelLocation> &&channel_location_ptr);
|
||||||
|
|
||||||
|
explicit DialogLocation(td_api::object_ptr<td_api::chatLocation> &&chat_location);
|
||||||
|
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::chatLocation> get_chat_location_object() const;
|
||||||
|
|
||||||
|
telegram_api::object_ptr<telegram_api::InputGeoPoint> get_input_geo_point() const;
|
||||||
|
|
||||||
|
const string &get_address() const;
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const {
|
||||||
|
using td::store;
|
||||||
|
store(location_, storer);
|
||||||
|
store(address_, storer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void parse(ParserT &parser) {
|
||||||
|
using td::parse;
|
||||||
|
parse(location_, parser);
|
||||||
|
parse(address_, parser);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const DialogLocation &lhs, const DialogLocation &rhs);
|
||||||
|
bool operator!=(const DialogLocation &lhs, const DialogLocation &rhs);
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const DialogLocation &location);
|
||||||
|
|
||||||
|
} // namespace td
|
@ -11,6 +11,7 @@
|
|||||||
#include "td/telegram/ConfigShared.h"
|
#include "td/telegram/ConfigShared.h"
|
||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
#include "td/telegram/DialogDb.h"
|
#include "td/telegram/DialogDb.h"
|
||||||
|
#include "td/telegram/DialogLocation.h"
|
||||||
#include "td/telegram/DraftMessage.h"
|
#include "td/telegram/DraftMessage.h"
|
||||||
#include "td/telegram/DraftMessage.hpp"
|
#include "td/telegram/DraftMessage.hpp"
|
||||||
#include "td/telegram/FileReferenceManager.h"
|
#include "td/telegram/FileReferenceManager.h"
|
||||||
@ -23879,6 +23880,13 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
|
|||||||
}
|
}
|
||||||
return make_tl_object<td_api::chatEventLinkedChatChanged>(old_linked_dialog_id.get(), new_linked_dialog_id.get());
|
return make_tl_object<td_api::chatEventLinkedChatChanged>(old_linked_dialog_id.get(), new_linked_dialog_id.get());
|
||||||
}
|
}
|
||||||
|
case telegram_api::channelAdminLogEventActionChangeLocation::ID: {
|
||||||
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeLocation>(action_ptr);
|
||||||
|
auto old_location = DialogLocation(std::move(action->prev_value_));
|
||||||
|
auto new_location = DialogLocation(std::move(action->new_value_));
|
||||||
|
return make_tl_object<td_api::chatEventLocationChanged>(old_location.get_chat_location_object(),
|
||||||
|
new_location.get_chat_location_object());
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
Reference in New Issue
Block a user