Add and use JsonEmptyObject.

This commit is contained in:
levlam 2022-12-29 17:51:39 +03:00
parent 38df7114f2
commit 3704082f2a
2 changed files with 14 additions and 30 deletions

View File

@ -307,6 +307,13 @@ bool Client::is_local_method(Slice method) {
method == "setwebhook" || method == "deletewebhook" || method == "getwebhookinfo"; method == "setwebhook" || method == "deletewebhook" || method == "getwebhookinfo";
} }
class Client::JsonEmptyObject final : public Jsonable {
public:
void store(JsonValueScope *scope) const {
auto object = scope->enter_object();
}
};
class Client::JsonFile final : public Jsonable { class Client::JsonFile final : public Jsonable {
public: public:
JsonFile(const td_api::file *file, const Client *client, bool with_path) JsonFile(const td_api::file *file, const Client *client, bool with_path)
@ -1423,13 +1430,6 @@ class Client::JsonForumTopicEdited final : public Jsonable {
const td_api::messageForumTopicEdited *forum_topic_edited_; const td_api::messageForumTopicEdited *forum_topic_edited_;
}; };
class Client::JsonForumTopicIsClosedToggled final : public Jsonable {
public:
void store(JsonValueScope *scope) const {
auto object = scope->enter_object();
}
};
class Client::JsonForumTopicInfo final : public Jsonable { class Client::JsonForumTopicInfo final : public Jsonable {
public: public:
explicit JsonForumTopicInfo(const td_api::forumTopicInfo *forum_topic_info) : forum_topic_info_(forum_topic_info) { explicit JsonForumTopicInfo(const td_api::forumTopicInfo *forum_topic_info) : forum_topic_info_(forum_topic_info) {
@ -1666,13 +1666,6 @@ class Client::JsonVideoChatScheduled final : public Jsonable {
const td_api::messageVideoChatScheduled *video_chat_scheduled_; const td_api::messageVideoChatScheduled *video_chat_scheduled_;
}; };
class Client::JsonVideoChatStarted final : public Jsonable {
public:
void store(JsonValueScope *scope) const {
auto object = scope->enter_object();
}
};
class Client::JsonVideoChatEnded final : public Jsonable { class Client::JsonVideoChatEnded final : public Jsonable {
public: public:
explicit JsonVideoChatEnded(const td_api::messageVideoChatEnded *video_chat_ended) explicit JsonVideoChatEnded(const td_api::messageVideoChatEnded *video_chat_ended)
@ -1718,13 +1711,6 @@ class Client::JsonChatSetMessageAutoDeleteTime final : public Jsonable {
const td_api::messageChatSetMessageAutoDeleteTime *chat_set_message_auto_delete_time_; const td_api::messageChatSetMessageAutoDeleteTime *chat_set_message_auto_delete_time_;
}; };
class Client::JsonCallbackGame final : public Jsonable {
public:
void store(JsonValueScope *scope) const {
auto object = scope->enter_object();
}
};
class Client::JsonWebAppInfo final : public Jsonable { class Client::JsonWebAppInfo final : public Jsonable {
public: public:
explicit JsonWebAppInfo(const td::string &url) : url_(url) { explicit JsonWebAppInfo(const td::string &url) : url_(url) {
@ -1767,7 +1753,7 @@ class Client::JsonInlineKeyboardButton final : public Jsonable {
break; break;
} }
case td_api::inlineKeyboardButtonTypeCallbackGame::ID: case td_api::inlineKeyboardButtonTypeCallbackGame::ID:
object("callback_game", JsonCallbackGame()); object("callback_game", JsonEmptyObject());
break; break;
case td_api::inlineKeyboardButtonTypeSwitchInline::ID: { case td_api::inlineKeyboardButtonTypeSwitchInline::ID: {
auto type = static_cast<const td_api::inlineKeyboardButtonTypeSwitchInline *>(button_->type_.get()); auto type = static_cast<const td_api::inlineKeyboardButtonTypeSwitchInline *>(button_->type_.get());
@ -2078,16 +2064,16 @@ void Client::JsonMessage::store(JsonValueScope *scope) const {
case td_api::messageForumTopicIsClosedToggled::ID: { case td_api::messageForumTopicIsClosedToggled::ID: {
auto content = static_cast<const td_api::messageForumTopicIsClosedToggled *>(message_->content.get()); auto content = static_cast<const td_api::messageForumTopicIsClosedToggled *>(message_->content.get());
if (content->is_closed_) { if (content->is_closed_) {
object("forum_topic_closed", JsonForumTopicIsClosedToggled()); object("forum_topic_closed", JsonEmptyObject());
} else { } else {
object("forum_topic_reopened", JsonForumTopicIsClosedToggled()); object("forum_topic_reopened", JsonEmptyObject());
} }
break; break;
} }
case td_api::messageForumTopicIsHiddenToggled::ID: { case td_api::messageForumTopicIsHiddenToggled::ID: {
// auto content = static_cast<const td_api::messageForumTopicIsHiddenToggled *>(message_->content.get()); // auto content = static_cast<const td_api::messageForumTopicIsHiddenToggled *>(message_->content.get());
// temporary; the topic is closed when it is hidden or unhidden // temporary; the topic is closed when it is hidden or unhidden
object("forum_topic_closed", JsonForumTopicIsClosedToggled()); object("forum_topic_closed", JsonEmptyObject());
break; break;
} }
case td_api::messagePinMessage::ID: { case td_api::messagePinMessage::ID: {
@ -2167,8 +2153,8 @@ void Client::JsonMessage::store(JsonValueScope *scope) const {
break; break;
} }
case td_api::messageVideoChatStarted::ID: case td_api::messageVideoChatStarted::ID:
object("video_chat_started", JsonVideoChatStarted()); object("video_chat_started", JsonEmptyObject());
object("voice_chat_started", JsonVideoChatStarted()); object("voice_chat_started", JsonEmptyObject());
break; break;
case td_api::messageVideoChatEnded::ID: { case td_api::messageVideoChatEnded::ID: {
auto content = static_cast<const td_api::messageVideoChatEnded *>(message_->content.get()); auto content = static_cast<const td_api::messageVideoChatEnded *>(message_->content.get());

View File

@ -84,6 +84,7 @@ class Client final : public WebhookActor::Callback {
static constexpr int32 MAX_LENGTH = 10000; // max width or height static constexpr int32 MAX_LENGTH = 10000; // max width or height
static constexpr int32 MAX_DURATION = 24 * 60 * 60; static constexpr int32 MAX_DURATION = 24 * 60 * 60;
class JsonEmptyObject;
class JsonFile; class JsonFile;
class JsonDatedFile; class JsonDatedFile;
class JsonDatedFiles; class JsonDatedFiles;
@ -119,7 +120,6 @@ class Client final : public WebhookActor::Callback {
class JsonPollAnswer; class JsonPollAnswer;
class JsonEntity; class JsonEntity;
class JsonVectorEntities; class JsonVectorEntities;
class JsonCallbackGame;
class JsonWebAppInfo; class JsonWebAppInfo;
class JsonInlineKeyboardButton; class JsonInlineKeyboardButton;
class JsonInlineKeyboard; class JsonInlineKeyboard;
@ -144,7 +144,6 @@ class Client final : public WebhookActor::Callback {
class JsonChatJoinRequest; class JsonChatJoinRequest;
class JsonForumTopicCreated; class JsonForumTopicCreated;
class JsonForumTopicEdited; class JsonForumTopicEdited;
class JsonForumTopicIsClosedToggled;
class JsonForumTopicInfo; class JsonForumTopicInfo;
class JsonGameHighScore; class JsonGameHighScore;
class JsonAddress; class JsonAddress;
@ -156,7 +155,6 @@ class Client final : public WebhookActor::Callback {
class JsonWebAppData; class JsonWebAppData;
class JsonProximityAlertTriggered; class JsonProximityAlertTriggered;
class JsonVideoChatScheduled; class JsonVideoChatScheduled;
class JsonVideoChatStarted;
class JsonVideoChatEnded; class JsonVideoChatEnded;
class JsonInviteVideoChatParticipants; class JsonInviteVideoChatParticipants;
class JsonChatSetMessageAutoDeleteTime; class JsonChatSetMessageAutoDeleteTime;