Add "deleted_business_messages" updates.

This commit is contained in:
levlam 2024-03-18 13:58:44 +03:00
parent 5bc5297746
commit 538fc78fa6
2 changed files with 34 additions and 0 deletions

View File

@ -3603,6 +3603,24 @@ class Client::JsonBusinessConnection final : public td::Jsonable {
const Client *client_; const Client *client_;
}; };
class Client::JsonBusinessMessagesDeleted final : public td::Jsonable {
public:
JsonBusinessMessagesDeleted(const td_api::updateBusinessMessagesDeleted *update, const Client *client)
: update_(update), client_(client) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("business_connection_id", update_->connection_id_);
object("chat", JsonChat(update_->chat_id_, client_));
object("message_ids",
td::json_array(update_->message_ids_, [](int64 message_id) { return as_client_message_id(message_id); }));
}
private:
const td_api::updateBusinessMessagesDeleted *update_;
const Client *client_;
};
class Client::JsonUpdateTypes final : public td::Jsonable { class Client::JsonUpdateTypes final : public td::Jsonable {
public: public:
explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) { explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) {
@ -6480,6 +6498,9 @@ void Client::on_update(object_ptr<td_api::Object> result) {
case td_api::updateBusinessMessageEdited::ID: case td_api::updateBusinessMessageEdited::ID:
add_business_message_edited(move_object_as<td_api::updateBusinessMessageEdited>(result)); add_business_message_edited(move_object_as<td_api::updateBusinessMessageEdited>(result));
break; break;
case td_api::updateBusinessMessagesDeleted::ID:
add_update_business_messages_deleted(move_object_as<td_api::updateBusinessMessagesDeleted>(result));
break;
case td_api::updateConnectionState::ID: { case td_api::updateConnectionState::ID: {
auto update = move_object_as<td_api::updateConnectionState>(result); auto update = move_object_as<td_api::updateConnectionState>(result);
if (update->state_->get_id() == td_api::connectionStateReady::ID) { if (update->state_->get_id() == td_api::connectionStateReady::ID) {
@ -12186,6 +12207,8 @@ td::Slice Client::get_update_type_name(UpdateType update_type) {
return td::Slice("business_message"); return td::Slice("business_message");
case UpdateType::EditedBusinessMessage: case UpdateType::EditedBusinessMessage:
return td::Slice("edited_business_message"); return td::Slice("edited_business_message");
case UpdateType::BusinessMessagesDeleted:
return td::Slice("deleted_business_messages");
default: default:
UNREACHABLE(); UNREACHABLE();
return td::Slice(); return td::Slice();
@ -12551,6 +12574,13 @@ void Client::add_update_business_connection(object_ptr<td_api::updateBusinessCon
} }
} }
void Client::add_update_business_messages_deleted(object_ptr<td_api::updateBusinessMessagesDeleted> &&update) {
CHECK(update != nullptr);
auto webhook_queue_id = update->chat_id_ + (static_cast<int64>(11) << 33);
add_update(UpdateType::BusinessMessagesDeleted, JsonBusinessMessagesDeleted(update.get(), this), 86400,
webhook_queue_id);
}
void Client::add_new_business_message(object_ptr<td_api::updateNewBusinessMessage> &&update) { void Client::add_new_business_message(object_ptr<td_api::updateNewBusinessMessage> &&update) {
CHECK(update != nullptr); CHECK(update != nullptr);
CHECK(!update->connection_id_.empty()); CHECK(!update->connection_id_.empty());

View File

@ -164,6 +164,7 @@ class Client final : public WebhookActor::Callback {
class JsonMessageReactionUpdated; class JsonMessageReactionUpdated;
class JsonMessageReactionCountUpdated; class JsonMessageReactionCountUpdated;
class JsonBusinessConnection; class JsonBusinessConnection;
class JsonBusinessMessagesDeleted;
class JsonAddress; class JsonAddress;
class JsonOrderInfo; class JsonOrderInfo;
class JsonStory; class JsonStory;
@ -1059,6 +1060,8 @@ class Client final : public WebhookActor::Callback {
void add_update_business_connection(object_ptr<td_api::updateBusinessConnection> &&update); void add_update_business_connection(object_ptr<td_api::updateBusinessConnection> &&update);
void add_update_business_messages_deleted(object_ptr<td_api::updateBusinessMessagesDeleted> &&update);
// append only before Size // append only before Size
enum class UpdateType : int32 { enum class UpdateType : int32 {
Message, Message,
@ -1084,6 +1087,7 @@ class Client final : public WebhookActor::Callback {
BusinessConnection, BusinessConnection,
BusinessMessage, BusinessMessage,
EditedBusinessMessage, EditedBusinessMessage,
BusinessMessagesDeleted,
Size Size
}; };