diff --git a/src/PluginEventSifter.h b/src/PluginEventSifter.h index 209b39b..0dcba84 100644 --- a/src/PluginEventSifter.h +++ b/src/PluginEventSifter.h @@ -54,7 +54,7 @@ struct PluginEventSifter { std::unique_ptr running; - PluginEventSifterResult acceptEvent(const std::string &pluginCmd, const tao::json::value &evJson, uint64_t receivedAt, EventSourceType sourceType, std::string_view sourceInfo, std::string &okMsg) { + PluginEventSifterResult acceptEvent(const std::string &pluginCmd, const tao::json::value &evJson, uint64_t receivedAtUs, EventSourceType sourceType, std::string_view sourceInfo, std::string &okMsg) { if (pluginCmd.size() == 0) { running.reset(); return PluginEventSifterResult::Accept; @@ -80,7 +80,7 @@ struct PluginEventSifter { auto request = tao::json::value({ { "type", "new" }, { "event", evJson }, - { "receivedAt", receivedAt / 1000000 }, + { "receivedAt", receivedAtUs / 1'000'000 }, { "sourceType", eventSourceTypeToStr(sourceType) }, { "sourceInfo", sourceType == EventSourceType::IP4 || sourceType == EventSourceType::IP6 ? renderIP(sourceInfo) : sourceInfo }, }); diff --git a/src/apps/mesh/cmd_router.cpp b/src/apps/mesh/cmd_router.cpp index 75d52b2..6d87499 100644 --- a/src/apps/mesh/cmd_router.cpp +++ b/src/apps/mesh/cmd_router.cpp @@ -183,7 +183,7 @@ struct Router { std::string okMsg; - auto res = pluginDown.acceptEvent(pluginDownCmd, evJson, hoytech::curr_time_s(), EventSourceType::Stream, url, okMsg); + auto res = pluginDown.acceptEvent(pluginDownCmd, evJson, hoytech::curr_time_us(), EventSourceType::Stream, url, okMsg); if (res == PluginEventSifterResult::Accept) { router->writer.write({ std::move(evJson), EventSourceType::Stream, url }); } else { @@ -191,7 +191,7 @@ struct Router { } } - void outgoingEvent(lmdb::txn &txn, const defaultDb::environment::View_Event &ev, std::string &responseStr, tao::json::value &evJson) { + void outgoingEvent(lmdb::txn &txn, defaultDb::environment::View_Event &ev, std::string &responseStr, tao::json::value &evJson) { if (dir == "down") return; if (!filterCompiled.doesMatch(ev.flat_nested())) return; @@ -206,7 +206,7 @@ struct Router { std::string okMsg; - auto res = pluginUp.acceptEvent(pluginUpCmd, evJson, hoytech::curr_time_s(), EventSourceType::Stream, "", okMsg); + auto res = pluginUp.acceptEvent(pluginUpCmd, evJson, ev.receivedAt(), (EventSourceType)ev.sourceType(), ev.sourceInfo(), okMsg); if (res == PluginEventSifterResult::Accept) { for (auto &[url, c] : conns) { if (c.ws) c.ws->send(responseStr.data(), responseStr.size(), uWS::OpCode::TEXT, nullptr, nullptr, true); diff --git a/src/apps/mesh/cmd_stream.cpp b/src/apps/mesh/cmd_stream.cpp index cffb80e..f1a3ebf 100644 --- a/src/apps/mesh/cmd_stream.cpp +++ b/src/apps/mesh/cmd_stream.cpp @@ -67,7 +67,7 @@ void cmd_stream(const std::vector &subArgs) { auto &evJson = origJson.at(2); std::string okMsg; - auto res = writePolicyPlugin.acceptEvent(cfg().relay__writePolicy__plugin, evJson, hoytech::curr_time_s(), EventSourceType::Stream, ws.remoteAddr, okMsg); + auto res = writePolicyPlugin.acceptEvent(cfg().relay__writePolicy__plugin, evJson, hoytech::curr_time_us(), EventSourceType::Stream, ws.remoteAddr, okMsg); if (res == PluginEventSifterResult::Accept) { downloadedIds.emplace(from_hex(evJson.at("id").get_string())); writer.write({ std::move(evJson), EventSourceType::Stream, url }); diff --git a/src/apps/mesh/cmd_sync.cpp b/src/apps/mesh/cmd_sync.cpp index 3f9a228..1dd5c14 100644 --- a/src/apps/mesh/cmd_sync.cpp +++ b/src/apps/mesh/cmd_sync.cpp @@ -160,7 +160,7 @@ void cmd_sync(const std::vector &subArgs) { auto &evJson = msg.at(2); std::string okMsg; - auto res = writePolicyPlugin.acceptEvent(cfg().relay__writePolicy__plugin, evJson, hoytech::curr_time_s(), EventSourceType::Sync, ws.remoteAddr, okMsg); + auto res = writePolicyPlugin.acceptEvent(cfg().relay__writePolicy__plugin, evJson, hoytech::curr_time_us(), EventSourceType::Sync, ws.remoteAddr, okMsg); if (res == PluginEventSifterResult::Accept) { writer.write({ std::move(evJson), EventSourceType::Sync, url }); } else {