From dc93610914a2d207eb5be9b0e0a575fbcdbc42a4 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 12 Apr 2019 00:16:27 -0700 Subject: [PATCH] ircd::m::feds: Add feds::event to interface. --- include/ircd/m/feds.h | 1 + ircd/m.cc | 14 ++++++++++++++ modules/federation/federation.cc | 29 +++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/ircd/m/feds.h b/include/ircd/m/feds.h index 2349add4d..e0ed54c5a 100644 --- a/include/ircd/m/feds.h +++ b/include/ircd/m/feds.h @@ -18,6 +18,7 @@ namespace ircd::m::feds using closure = std::function; bool head(const opts &, const closure &); + bool event(const opts &, const closure &); bool state(const opts &, const closure &); bool version(const opts &, const closure &); }; diff --git a/ircd/m.cc b/ircd/m.cc index 54694e2a5..03f44bc57 100644 --- a/ircd/m.cc +++ b/ircd/m.cc @@ -1073,6 +1073,20 @@ ircd::m::feds::version(const opts &o, return call(o, c); } +bool +ircd::m::feds::event(const opts &o, + const closure &c) +{ + using prototype = bool (const opts &, const closure &); + + static mods::import call + { + "federation_federation", "ircd::m::feds::event" + }; + + return call(o, c); +} + bool ircd::m::feds::head(const opts &o, const closure &c) diff --git a/modules/federation/federation.cc b/modules/federation/federation.cc index db86d7e77..26436526b 100644 --- a/modules/federation/federation.cc +++ b/modules/federation/federation.cc @@ -186,6 +186,35 @@ ircd::m::feds::state(const opts &opts, return handler(opts, closure, requests); } +bool +IRCD_MODULE_EXPORT +ircd::m::feds::event(const opts &opts, + const closure &closure) +{ + const auto make_request{[&opts] + (auto &request, const auto &origin) + { + m::v1::event::opts v1opts; + v1opts.dynamic = true; + v1opts.remote = string_view + { + request.origin, strlcpy{request.origin, origin} + }; + + return m::v1::event + { + opts.event_id, request.buf, std::move(v1opts) + }; + }}; + + auto requests + { + creator(opts, make_request) + }; + + return handler(opts, closure, requests); +} + bool IRCD_MODULE_EXPORT ircd::m::feds::head(const opts &opts,