From fda0fc0adc18e67dd45996a5049a4b4409718411 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 4 Apr 2020 00:05:35 +0300 Subject: [PATCH] Improve Poll.open_period field name. GitOrigin-RevId: 733b05bbb08cece27ddba88875e9a8493e974081 --- td/generate/scheme/td_api.tl | 8 +++--- td/generate/scheme/td_api.tlo | Bin 170904 -> 170896 bytes td/telegram/MessageContent.cpp | 6 ++--- td/telegram/PollManager.cpp | 36 +++++++++++++-------------- td/telegram/PollManager.h | 6 ++--- td/telegram/PollManager.hpp | 44 ++++++++++++++++----------------- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 570e917d..be92505f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -271,8 +271,8 @@ game id:int64 short_name:string title:string text:formattedText description:stri //@description Describes a poll @id Unique poll identifier @question Poll question, 1-255 characters @options List of poll answer options //@total_voter_count Total number of voters, participating in the poll @recent_voter_user_ids User identifiers of recent voters, if the poll is non-anonymous //@is_anonymous True, if the poll is anonymous @type Type of the poll -//@close_date Point in time (Unix timestamp) when the poll will be automatically closed @close_period Amount of time the poll will be active after creation, in seconds @is_closed True, if the poll is closed -poll id:int64 question:string options:vector total_voter_count:int32 recent_voter_user_ids:vector is_anonymous:Bool type:PollType close_date:int32 close_period:int32 is_closed:Bool = Poll; +//@open_period Amount of time the poll will be active after creation, in seconds @close_date Point in time (Unix timestamp) when the poll will be automatically closed @is_closed True, if the poll is closed +poll id:int64 question:string options:vector total_voter_count:int32 recent_voter_user_ids:vector is_anonymous:Bool type:PollType open_period:int32 close_date:int32 is_closed:Bool = Poll; //@description Describes a user profile photo @id Photo identifier; 0 for an empty photo. Can be used to find a photo in a list of userProfilePhotos @@ -1596,10 +1596,10 @@ inputMessageInvoice invoice:invoice title:string description:string photo_url:st //@description A message with a poll. Polls can't be sent to secret chats. Polls can be sent only to a private chat with a bot @question Poll question, 1-255 characters @options List of poll answer options, 2-10 strings 1-100 characters each //@is_anonymous True, if the poll voters are anonymous. Non-anonymous polls can't be sent or forwarded to channels @type Type of the poll +//@open_period Amount of time the poll will be active after creation, in seconds; for bots only //@close_date Point in time (Unix timestamp) when the poll will be automatically closed; for bots only -//@close_period Amount of time the poll will be active after creation, in seconds; for bots only //@is_closed True, if the poll needs to be sent already closed; for bots only -inputMessagePoll question:string options:vector is_anonymous:Bool type:PollType close_date:int32 close_period:int32 is_closed:Bool = InputMessageContent; +inputMessagePoll question:string options:vector is_anonymous:Bool type:PollType open_period:int32 close_date:int32 is_closed:Bool = InputMessageContent; //@description A forwarded message @from_chat_id Identifier for the chat this forwarded message came from @message_id Identifier of the message to forward //@in_game_share True, if a game message should be shared within a launched game; applies only to game messages diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index bbacd9665596567b4d6a1e7733a92b82397921ff..8672a88bb097bc5bbaf76e8e0c72ce88676bd12f 100644 GIT binary patch delta 893 zcmZ`%O=uHQ5cWMbZ4x)IDM(WqnrIff*gZt(F+!j{6iFe69C`@YLZTKz65EQR1tW+> zD6%lp*F%sXITlG+amA=K?Hcn(+CqC!dhk%OLJvJj4-w4nTiw0*PV>z--#0UlSy!Br z;w%;1%;?u2{c_QrcR3D*Dh?)^Nu{7{8OmV3#DabqI!AVf*#Af z1+`y~TM+-IXhA26h)tK!yDa78QYB`o5DCW6(fN4F!T8^{a66%O{R zaoS*fOQ6B*)*%hT+q^?t`%7&g(g%-E_YV942IOFW)yZ5>IboS2DbaHWV?q*Uu zryi%fdOI8J`AjyMzMf4k%x4m7vuFq!oxoZI8LNbMj3BkMtGAQGyQ*l@4imxcUp`s* zJvq(kcbcWfS`4RU4@eUn2%RZ%at+o0-$g4|#0c^}WVDb-FOXkJwNPwCZ%1+i*smP@ zM9(kT^wr4TcjQy@EDj-SqU*vDdcIVV;xI?C(sP)kho@8IIF0Lu_l2JKeg>;!e*ko2 BZJYoA delta 889 zcmbQRoomK+t_=$WS=#-k7j9l6IER;Wi&g9+mVo@6oXHzmr8lR@^W;M$OZp}#f?1O{ z>{i&Uv7v?$!8@^W1`@AjvkDUL%oYJP6+8o`VvcAfMbkCgj6BdE*TA$yW}>KrAphqyb?h9J&KxI2=}iD`uPA zxI}#NjS~WsrySk`kq$Wm)zEOH0wVI~2tot<^o#0@;*%YY{(#8Y97D*lOkemIDA#Zd zrVmMubNWG`+-8U49#CiZoX~)~f@S)|XhvzEGio4)Mw~>Fn;iHHBqcDJ=cLNy8z(&= zN>olkT^VpH0wS{JlnR6~;kN;V!EqWYVsIKNl5$!_0v1jTKv3k&ro&;|b`T^sdBJIf zSC}SmY|x(k!$${VlExW`Nt*-CEMU|DsRro=fva*{F>Cg*^9W?-6_l3vrWO|`rl*2Z z5l{|ns?51Hli!?E;pIur$uCZgFGwxQ%uktYs3$#H;5^g|Hs=xEWu5+!lTm+q!7)bF z$p_DugRS3ebK!^%3n+a~PWY~{S>>;buK+l;7C`I)%Y4` create_input_message_content( UNREACHABLE(); } - int32 close_period = is_bot ? input_poll->close_period_ : 0; + int32 open_period = is_bot ? input_poll->open_period_ : 0; int32 close_date = is_bot ? input_poll->close_date_ : 0; - if (close_period != 0) { + if (open_period != 0) { close_date = 0; } bool is_closed = is_bot ? input_poll->is_closed_ : false; content = make_unique( td->poll_manager_->create_poll(std::move(input_poll->question_), std::move(input_poll->options_), input_poll->is_anonymous_, allow_multiple_answers, is_quiz, correct_option_id, - std::move(explanation), close_date, close_period, is_closed)); + std::move(explanation), open_period, close_date, is_closed)); break; } default: diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index 443d1a6c..bde759d3 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -538,23 +538,23 @@ td_api::object_ptr PollManager::get_poll_object(PollId poll_id, co poll_type = td_api::make_object(poll->allow_multiple_answers); } + auto open_period = poll->open_period; auto close_date = poll->close_date; - auto close_period = poll->close_period; - if (close_period != 0 && close_date == 0) { - close_date = G()->unix_time() + close_period; + if (open_period != 0 && close_date == 0) { + close_date = G()->unix_time() + open_period; } - if (close_period == 0 && close_date != 0) { + if (open_period == 0 && close_date != 0) { auto now = G()->unix_time(); if (close_date < now + 5) { close_date = 0; } else { - close_period = close_date - now; + open_period = close_date - now; } } return td_api::make_object( poll_id.get(), poll->question, std::move(poll_options), total_voter_count, td_->contacts_manager_->get_user_ids_object(poll->recent_voter_user_ids, "get_poll_object"), poll->is_anonymous, - std::move(poll_type), close_date, close_period, poll->is_closed); + std::move(poll_type), open_period, close_date, poll->is_closed); } telegram_api::object_ptr PollManager::get_input_poll_option(const PollOption &poll_option) { @@ -563,7 +563,7 @@ telegram_api::object_ptr PollManager::get_input_poll_o PollId PollManager::create_poll(string &&question, vector &&options, bool is_anonymous, bool allow_multiple_answers, bool is_quiz, int32 correct_option_id, - FormattedText &&explanation, int32 close_date, int32 close_period, bool is_closed) { + FormattedText &&explanation, int32 open_period, int32 close_date, bool is_closed) { auto poll = make_unique(); poll->question = std::move(question); int pos = '0'; @@ -578,8 +578,8 @@ PollId PollManager::create_poll(string &&question, vector &&options, boo poll->is_quiz = is_quiz; poll->correct_option_id = correct_option_id; poll->explanation = std::move(explanation); + poll->open_period = open_period; poll->close_date = close_date; - poll->close_period = close_period; poll->is_closed = is_closed; PollId poll_id(--current_local_poll_id_); @@ -1182,12 +1182,12 @@ tl_object_ptr PollManager::get_input_media(PollId poll if (poll->is_quiz) { poll_flags |= telegram_api::poll::QUIZ_MASK; } + if (poll->open_period != 0) { + poll_flags |= telegram_api::poll::CLOSE_PERIOD_MASK; + } if (poll->close_date != 0) { poll_flags |= telegram_api::poll::CLOSE_DATE_MASK; } - if (poll->close_period != 0) { - poll_flags |= telegram_api::poll::CLOSE_PERIOD_MASK; - } if (poll->is_closed) { poll_flags |= telegram_api::poll::CLOSED_MASK; } @@ -1208,7 +1208,7 @@ tl_object_ptr PollManager::get_input_media(PollId poll flags, telegram_api::make_object( 0, poll_flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, poll->question, - transform(poll->options, get_input_poll_option), poll->close_period, poll->close_date), + transform(poll->options, get_input_poll_option), poll->open_period, poll->close_date), std::move(correct_answers), poll->explanation.text, get_input_message_entities(td_->contacts_manager_.get(), poll->explanation.entities, "get_input_media_poll")); } @@ -1276,19 +1276,19 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptrflags_ & telegram_api::poll::CLOSE_DATE_MASK) != 0 ? poll_server->close_date_ : 0; - int32 close_period = + int32 open_period = (poll_server->flags_ & telegram_api::poll::CLOSE_PERIOD_MASK) != 0 ? poll_server->close_period_ : 0; - if (close_date == 0 || close_period == 0) { + int32 close_date = (poll_server->flags_ & telegram_api::poll::CLOSE_DATE_MASK) != 0 ? poll_server->close_date_ : 0; + if (close_date == 0 || open_period == 0) { close_date = 0; - close_period = 0; + open_period = 0; } if (close_date != poll->close_date) { poll->close_date = close_date; is_changed = true; } - if (close_period != poll->close_period) { - poll->close_period = close_period; + if (open_period != poll->open_period) { + poll->open_period = open_period; is_changed = true; } bool is_closed = (poll_server->flags_ & telegram_api::poll::CLOSED_MASK) != 0; diff --git a/td/telegram/PollManager.h b/td/telegram/PollManager.h index 15569329..b9a821f1 100644 --- a/td/telegram/PollManager.h +++ b/td/telegram/PollManager.h @@ -46,8 +46,8 @@ class PollManager : public Actor { static bool is_local_poll_id(PollId poll_id); PollId create_poll(string &&question, vector &&options, bool is_anonymous, bool allow_multiple_answers, - bool is_quiz, int32 correct_option_id, FormattedText &&explanation, int32 close_date, - int32 close_period, bool is_closed); + bool is_quiz, int32 correct_option_id, FormattedText &&explanation, int32 open_period, + int32 close_date, bool is_closed); void register_poll(PollId poll_id, FullMessageId full_message_id, const char *source); @@ -111,8 +111,8 @@ class PollManager : public Actor { FormattedText explanation; int32 total_voter_count = 0; int32 correct_option_id = -1; + int32 open_period = 0; int32 close_date = 0; - int32 close_period = 0; bool is_anonymous = true; bool allow_multiple_answers = false; bool is_quiz = false; diff --git a/td/telegram/PollManager.hpp b/td/telegram/PollManager.hpp index 850f7c50..b7813703 100644 --- a/td/telegram/PollManager.hpp +++ b/td/telegram/PollManager.hpp @@ -44,8 +44,8 @@ void PollManager::Poll::store(StorerT &storer) const { using ::td::store; bool is_public = !is_anonymous; bool has_recent_voters = !recent_voter_user_ids.empty(); + bool has_open_period = open_period != 0; bool has_close_date = close_date != 0; - bool has_close_period = close_period != 0; bool has_explanation = !explanation.text.empty(); BEGIN_STORE_FLAGS(); STORE_FLAG(is_closed); @@ -53,8 +53,8 @@ void PollManager::Poll::store(StorerT &storer) const { STORE_FLAG(allow_multiple_answers); STORE_FLAG(is_quiz); STORE_FLAG(has_recent_voters); + STORE_FLAG(has_open_period); STORE_FLAG(has_close_date); - STORE_FLAG(has_close_period); STORE_FLAG(has_explanation); END_STORE_FLAGS(); @@ -67,12 +67,12 @@ void PollManager::Poll::store(StorerT &storer) const { if (has_recent_voters) { store(recent_voter_user_ids, storer); } + if (has_open_period) { + store(open_period, storer); + } if (has_close_date) { store(close_date, storer); } - if (has_close_period) { - store(close_period, storer); - } if (has_explanation) { store(explanation, storer); } @@ -83,8 +83,8 @@ void PollManager::Poll::parse(ParserT &parser) { using ::td::parse; bool is_public; bool has_recent_voters; + bool has_open_period; bool has_close_date; - bool has_close_period; bool has_explanation; BEGIN_PARSE_FLAGS(); PARSE_FLAG(is_closed); @@ -92,8 +92,8 @@ void PollManager::Poll::parse(ParserT &parser) { PARSE_FLAG(allow_multiple_answers); PARSE_FLAG(is_quiz); PARSE_FLAG(has_recent_voters); + PARSE_FLAG(has_open_period); PARSE_FLAG(has_close_date); - PARSE_FLAG(has_close_period); PARSE_FLAG(has_explanation); END_PARSE_FLAGS(); is_anonymous = !is_public; @@ -110,12 +110,12 @@ void PollManager::Poll::parse(ParserT &parser) { if (has_recent_voters) { parse(recent_voter_user_ids, parser); } + if (has_open_period) { + parse(open_period, parser); + } if (has_close_date) { parse(close_date, parser); } - if (has_close_period) { - parse(close_period, parser); - } if (has_explanation) { parse(explanation, parser); } @@ -127,16 +127,16 @@ void PollManager::store_poll(PollId poll_id, StorerT &storer) const { if (is_local_poll_id(poll_id)) { auto poll = get_poll(poll_id); CHECK(poll != nullptr); + bool has_open_period = poll->open_period != 0; bool has_close_date = poll->close_date != 0; - bool has_close_period = poll->close_period != 0; bool has_explanation = !poll->explanation.text.empty(); BEGIN_STORE_FLAGS(); STORE_FLAG(poll->is_closed); STORE_FLAG(poll->is_anonymous); STORE_FLAG(poll->allow_multiple_answers); STORE_FLAG(poll->is_quiz); + STORE_FLAG(has_open_period); STORE_FLAG(has_close_date); - STORE_FLAG(has_close_period); STORE_FLAG(has_explanation); END_STORE_FLAGS(); store(poll->question, storer); @@ -145,12 +145,12 @@ void PollManager::store_poll(PollId poll_id, StorerT &storer) const { if (poll->is_quiz) { store(poll->correct_option_id, storer); } + if (has_open_period) { + store(poll->open_period, storer); + } if (has_close_date) { store(poll->close_date, storer); } - if (has_close_period) { - store(poll->close_period, storer); - } if (has_explanation) { store(poll->explanation, storer); } @@ -166,14 +166,14 @@ PollId PollManager::parse_poll(ParserT &parser) { string question; vector options; FormattedText explanation; + int32 open_period = 0; int32 close_date = 0; - int32 close_period = 0; bool is_closed = false; bool is_anonymous = true; bool allow_multiple_answers = false; bool is_quiz = false; + bool has_open_period = false; bool has_close_date = false; - bool has_close_period = false; bool has_explanation = false; int32 correct_option_id = -1; @@ -183,8 +183,8 @@ PollId PollManager::parse_poll(ParserT &parser) { PARSE_FLAG(is_anonymous); PARSE_FLAG(allow_multiple_answers); PARSE_FLAG(is_quiz); + PARSE_FLAG(has_open_period); PARSE_FLAG(has_close_date); - PARSE_FLAG(has_close_period); PARSE_FLAG(has_explanation); END_PARSE_FLAGS(); } @@ -196,12 +196,12 @@ PollId PollManager::parse_poll(ParserT &parser) { parser.set_error("Wrong correct_option_id"); } } + if (has_open_period) { + parse(open_period, parser); + } if (has_close_date) { parse(close_date, parser); } - if (has_close_period) { - parse(close_period, parser); - } if (has_explanation) { parse(explanation, parser); } @@ -209,7 +209,7 @@ PollId PollManager::parse_poll(ParserT &parser) { return PollId(); } return create_poll(std::move(question), std::move(options), is_anonymous, allow_multiple_answers, is_quiz, - correct_option_id, std::move(explanation), close_date, close_period, is_closed); + correct_option_id, std::move(explanation), open_period, close_date, is_closed); } auto poll = get_poll_force(poll_id);