From 12109be1a7362938dd0bea87a2a800e380f18c3e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 12 Apr 2019 12:40:10 -0700 Subject: [PATCH] modules/s_fetch: Use m::event:prev parsing here. --- modules/s_fetch.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/s_fetch.cc b/modules/s_fetch.cc index 02dee6225..0c46e6f7d 100644 --- a/modules/s_fetch.cc +++ b/modules/s_fetch.cc @@ -217,21 +217,26 @@ try if(result.eptr) std::rethrow_exception(result.eptr); - const json::array &prev_events + const m::event::prev prev { - json::object(result.object["event"]).get("prev_events") + result.object["event"] + }; + + const size_t count + { + prev.prev_events_count() }; log::debug { log, "Got %zu heads for %s from '%s'", - prev_events.size(), + count, string_view{room.room_id}, string_view{result.origin}, }; - for(const json::string &event_id : prev_events) - fetch::prefetch(room.room_id, event_id); + for(size_t i(0); i < count; ++i) + fetch::prefetch(room.room_id, prev.prev_event(i)); } catch(const std::exception &e) {