2018-01-22 19:05:45 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
2020-03-06 04:35:20 +01:00
|
|
|
#define HAVE_IRCD_M_FED_SEND_H
|
2018-01-22 19:05:45 +01:00
|
|
|
|
2020-03-06 04:35:20 +01:00
|
|
|
namespace ircd::m::fed
|
2018-01-22 19:05:45 +01:00
|
|
|
{
|
|
|
|
struct send;
|
|
|
|
};
|
|
|
|
|
2018-01-23 20:43:04 +01:00
|
|
|
/// A federation/v1/send request. This sends the provided transaction and
|
|
|
|
/// receives a response via the server::request ctx::future. This object
|
|
|
|
/// must stay in scope to complete the request until the future is resolved.
|
|
|
|
///
|
2020-03-06 04:35:20 +01:00
|
|
|
struct ircd::m::fed::send
|
2020-03-08 02:15:58 +01:00
|
|
|
:request
|
2018-01-22 19:05:45 +01:00
|
|
|
{
|
2018-01-23 20:43:04 +01:00
|
|
|
struct response;
|
2018-01-22 19:05:45 +01:00
|
|
|
|
2020-03-08 02:15:58 +01:00
|
|
|
explicit operator json::object() const
|
2018-01-23 20:43:04 +01:00
|
|
|
{
|
2020-03-08 02:15:58 +01:00
|
|
|
return json::object
|
|
|
|
{
|
|
|
|
in.content
|
|
|
|
};
|
2018-01-23 20:43:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
send(const string_view &txnid, // transaction ID (goes in URL)
|
|
|
|
const const_buffer &content, // full transaction (HTTP content out)
|
|
|
|
const mutable_buffer &head, // buffer for HTTP head in and out
|
|
|
|
opts); // options structure
|
2018-03-06 13:28:17 +01:00
|
|
|
|
2020-04-02 05:37:51 +02:00
|
|
|
explicit
|
|
|
|
send(const txn::array &pdu,
|
|
|
|
const txn::array &edu,
|
|
|
|
const mutable_buffer &buf,
|
|
|
|
opts);
|
|
|
|
|
2018-03-06 13:28:17 +01:00
|
|
|
send() = default;
|
2018-01-22 19:05:45 +01:00
|
|
|
};
|
|
|
|
|
2018-01-23 20:43:04 +01:00
|
|
|
/// Helper for dealing with response content from a /send/.
|
2020-03-06 04:35:20 +01:00
|
|
|
struct ircd::m::fed::send::response
|
2018-01-23 20:43:04 +01:00
|
|
|
:json::object
|
|
|
|
{
|
|
|
|
/// A member of the response object is "pdus" and this helps iterate that object
|
|
|
|
/// which is used to convey errors keyed by the event_id; value is matrix error obj.
|
|
|
|
using pdus_closure = std::function<void (const id::event &, const json::object &)>;
|
|
|
|
void for_each_pdu(const pdus_closure &) const;
|
|
|
|
|
|
|
|
response(const json::object &object)
|
|
|
|
:json::object{object}
|
|
|
|
{}
|
|
|
|
};
|