Add unix_time and date_time_format to MessageEntity.

main
levlam 4 months ago
parent bd658d336a
commit d123bcdfe8

@ -580,9 +580,54 @@ class Client::JsonEntity final : public td::Jsonable {
case td_api::textEntityTypeExpandableBlockQuote::ID: case td_api::textEntityTypeExpandableBlockQuote::ID:
object("type", "expandable_blockquote"); object("type", "expandable_blockquote");
break; break;
case td_api::textEntityTypeDateTime::ID: case td_api::textEntityTypeDateTime::ID: {
auto entity = static_cast<const td_api::textEntityTypeDateTime *>(entity_->type_.get());
object("type", "date_time"); object("type", "date_time");
object("unix_time", entity->unix_time_);
td::string format;
if (entity->formatting_type_ != nullptr) {
switch (entity->formatting_type_->get_id()) {
case td_api::dateTimeFormattingTypeRelative::ID:
format = "r";
break;
case td_api::dateTimeFormattingTypeAbsolute::ID: {
auto abs = static_cast<const td_api::dateTimeFormattingTypeAbsolute *>(entity->formatting_type_.get());
if (abs->show_day_of_week_) {
format += 'w';
}
switch (abs->date_precision_->get_id()) {
case td_api::dateTimePartPrecisionNone::ID:
break;
case td_api::dateTimePartPrecisionShort::ID:
format += 'd';
break;
case td_api::dateTimePartPrecisionLong::ID:
format += 'D';
break;
default:
UNREACHABLE();
}
switch (abs->time_precision_->get_id()) {
case td_api::dateTimePartPrecisionNone::ID:
break;
case td_api::dateTimePartPrecisionShort::ID:
format += 't';
break;
case td_api::dateTimePartPrecisionLong::ID:
format += 'T';
break;
default:
UNREACHABLE();
}
break;
}
default:
UNREACHABLE();
}
}
object("date_time_format", format);
break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }

Loading…
Cancel
Save