feat(eventsub): use special flag and timestamps from metadata (#5996)

This commit is contained in:
nerix
2025-02-26 15:40:42 +01:00
committed by GitHub
parent b957af4f50
commit 63b5b2ca6a
33 changed files with 159 additions and 107 deletions
@@ -44,6 +44,8 @@ boost::json::result_for<Metadata, boost::json::value>::type tag_invoke(
return messageType.error();
}
static_assert(std::is_trivially_copyable_v<std::remove_reference_t<
decltype(std::declval<Metadata>().messageTimestamp)>>);
const auto *jvmessageTimestamp = root.if_contains("message_timestamp");
if (jvmessageTimestamp == nullptr)
{
@@ -51,7 +53,8 @@ boost::json::result_for<Metadata, boost::json::value>::type tag_invoke(
}
auto messageTimestamp =
boost::json::try_value_to<std::string>(*jvmessageTimestamp);
boost::json::try_value_to<std::chrono::system_clock::time_point>(
*jvmessageTimestamp, AsISO8601());
if (messageTimestamp.has_error())
{
@@ -90,7 +93,7 @@ boost::json::result_for<Metadata, boost::json::value>::type tag_invoke(
return Metadata{
.messageID = std::move(messageID.value()),
.messageType = std::move(messageType.value()),
.messageTimestamp = std::move(messageTimestamp.value()),
.messageTimestamp = messageTimestamp.value(),
.subscriptionType = std::move(subscriptionType),
.subscriptionVersion = std::move(subscriptionVersion),
};