Improve Poll.open_period field name.
GitOrigin-RevId: 733b05bbb08cece27ddba88875e9a8493e974081
This commit is contained in:
parent
4e7cd24285
commit
fda0fc0adc
@ -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<pollOption> total_voter_count:int32 recent_voter_user_ids:vector<int32> 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<pollOption> total_voter_count:int32 recent_voter_user_ids:vector<int32> 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<string> is_anonymous:Bool type:PollType close_date:int32 close_period:int32 is_closed:Bool = InputMessageContent;
|
||||
inputMessagePoll question:string options:vector<string> 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
|
||||
|
Binary file not shown.
@ -1778,16 +1778,16 @@ static Result<InputMessageContent> 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<MessagePoll>(
|
||||
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:
|
||||
|
@ -538,23 +538,23 @@ td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, co
|
||||
poll_type = td_api::make_object<td_api::pollTypeRegular>(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<td_api::poll>(
|
||||
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<telegram_api::pollAnswer> PollManager::get_input_poll_option(const PollOption &poll_option) {
|
||||
@ -563,7 +563,7 @@ telegram_api::object_ptr<telegram_api::pollAnswer> PollManager::get_input_poll_o
|
||||
|
||||
PollId PollManager::create_poll(string &&question, vector<string> &&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>();
|
||||
poll->question = std::move(question);
|
||||
int pos = '0';
|
||||
@ -578,8 +578,8 @@ PollId PollManager::create_poll(string &&question, vector<string> &&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<telegram_api::InputMedia> 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<telegram_api::InputMedia> PollManager::get_input_media(PollId poll
|
||||
flags,
|
||||
telegram_api::make_object<telegram_api::poll>(
|
||||
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_ptr<telegram_api::poll
|
||||
}
|
||||
}
|
||||
}
|
||||
int32 close_date = (poll_server->flags_ & 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;
|
||||
|
@ -46,8 +46,8 @@ class PollManager : public Actor {
|
||||
static bool is_local_poll_id(PollId poll_id);
|
||||
|
||||
PollId create_poll(string &&question, vector<string> &&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;
|
||||
|
@ -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<string> 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);
|
||||
|
Reference in New Issue
Block a user