0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd:Ⓜ️:fed: Add convenience delegator for send.

This commit is contained in:
Jason Volk 2020-04-01 20:37:51 -07:00
parent c973062086
commit b31b0eb691
3 changed files with 36 additions and 1 deletions

View file

@ -38,6 +38,12 @@ struct ircd::m::fed::send
const mutable_buffer &head, // buffer for HTTP head in and out
opts); // options structure
explicit
send(const txn::array &pdu,
const txn::array &edu,
const mutable_buffer &buf,
opts);
send() = default;
};

View file

@ -65,6 +65,7 @@ namespace ircd
#include "device.h"
#include "push.h"
#include "createroom.h"
#include "txn.h"
#include "room/room.h"
#include "user/user.h"
#include "users.h"
@ -84,7 +85,6 @@ namespace ircd
#include "receipt.h"
#include "direct_to_device.h"
#include "relates.h"
#include "txn.h"
#include "visible.h"
#include "redacted.h"
#include "feds.h"

View file

@ -66,6 +66,35 @@ const
closure(event_id, error);
}
ircd::m::fed::send::send(const txn::array &pdu,
const txn::array &edu,
const mutable_buffer &buf_,
opts opts)
:send{[&]
{
assert(!!opts.remote);
mutable_buffer buf{buf_};
const string_view &content
{
txn::create(buf, pdu, edu)
};
consume(buf, size(content));
const string_view &txnid
{
txn::create_id(buf, content)
};
consume(buf, size(txnid));
return send
{
txnid, content, buf, std::move(opts)
};
}()}
{
}
ircd::m::fed::send::send(const string_view &txnid,
const const_buffer &content,
const mutable_buffer &buf_,