mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️:vm: Support client unsigned.transaction_id.
This commit is contained in:
parent
6858ea2bb1
commit
85aef85f61
4 changed files with 44 additions and 17 deletions
|
@ -214,6 +214,9 @@ struct ircd::m::vm::opts
|
|||
struct ircd::m::vm::copts
|
||||
:opts
|
||||
{
|
||||
/// A matrix-spec opaque token from a client identifying this eval.
|
||||
string_view client_txnid;
|
||||
|
||||
/// Hash and include hashes object.
|
||||
bool add_hash {true};
|
||||
|
||||
|
|
|
@ -35,14 +35,17 @@ put__send(client &client,
|
|||
"txnid parameter missing"
|
||||
};
|
||||
|
||||
const string_view &txnid
|
||||
const string_view &transaction_id
|
||||
{
|
||||
request.parv[3]
|
||||
};
|
||||
|
||||
m::vm::copts copts;
|
||||
copts.client_txnid = transaction_id;
|
||||
|
||||
room room
|
||||
{
|
||||
room_id
|
||||
room_id, &copts
|
||||
};
|
||||
|
||||
const json::object &content
|
||||
|
|
|
@ -178,7 +178,7 @@ catch(const ctx::timeout &e)
|
|||
bool
|
||||
ircd::m::sync::longpoll::handle(client &client,
|
||||
const args &args,
|
||||
const m::event &event)
|
||||
const vm::accepted &event)
|
||||
{
|
||||
const auto &room_id
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ ircd::m::sync::longpoll::handle(client &client,
|
|||
bool
|
||||
ircd::m::sync::longpoll::handle(client &client,
|
||||
const args &args,
|
||||
const m::event &event,
|
||||
const vm::accepted &event,
|
||||
const m::room &room)
|
||||
{
|
||||
const m::user::id &user_id
|
||||
|
@ -208,11 +208,6 @@ ircd::m::sync::longpoll::handle(client &client,
|
|||
if(!room.membership(user_id, "join"))
|
||||
return false;
|
||||
|
||||
// if(json::get<"type"_>(event) == "m.room.message")
|
||||
// if(json::get<"sender"_>(event) == user_id)
|
||||
// return false;
|
||||
|
||||
|
||||
const auto rooms
|
||||
{
|
||||
sync_rooms(client, user_id, room, args, event)
|
||||
|
@ -266,7 +261,7 @@ ircd::m::sync::longpoll::sync_rooms(client &client,
|
|||
const m::user::id &user_id,
|
||||
const m::room &room,
|
||||
const args &args,
|
||||
const m::event &event)
|
||||
const vm::accepted &event)
|
||||
{
|
||||
std::vector<std::string> r[3];
|
||||
std::vector<json::member> m[3];
|
||||
|
@ -288,16 +283,30 @@ std::string
|
|||
ircd::m::sync::longpoll::sync_room(client &client,
|
||||
const m::room &room,
|
||||
const args &args,
|
||||
const m::event &event)
|
||||
const vm::accepted &accepted)
|
||||
{
|
||||
const auto &since
|
||||
{
|
||||
args.since
|
||||
};
|
||||
|
||||
const m::event &event{accepted};
|
||||
|
||||
std::vector<std::string> state;
|
||||
if(defined(json::get<"event_id"_>(event)) && defined(json::get<"state_key"_>(event)))
|
||||
state.emplace_back(json::strung(event));
|
||||
{
|
||||
json::strung strung(event);
|
||||
if(accepted.copts && accepted.copts->client_txnid)
|
||||
strung = json::insert(strung, json::member
|
||||
{
|
||||
"unsigned", json::members
|
||||
{
|
||||
{ "transaction_id", accepted.copts->client_txnid }
|
||||
}
|
||||
});
|
||||
|
||||
state.emplace_back(std::move(strung));
|
||||
}
|
||||
|
||||
const json::strung state_serial
|
||||
{
|
||||
|
@ -306,7 +315,19 @@ ircd::m::sync::longpoll::sync_room(client &client,
|
|||
|
||||
std::vector<std::string> timeline;
|
||||
if(defined(json::get<"event_id"_>(event)) && !defined(json::get<"state_key"_>(event)))
|
||||
timeline.emplace_back(json::strung(event));
|
||||
{
|
||||
json::strung strung(event);
|
||||
if(accepted.copts && accepted.copts->client_txnid)
|
||||
strung = json::insert(strung, json::member
|
||||
{
|
||||
"unsigned", json::members
|
||||
{
|
||||
{ "transaction_id", accepted.copts->client_txnid }
|
||||
}
|
||||
});
|
||||
|
||||
timeline.emplace_back(std::move(strung));
|
||||
}
|
||||
|
||||
const json::strung timeline_serial
|
||||
{
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace ircd::m::sync
|
|||
|
||||
namespace ircd::m::sync::longpoll
|
||||
{
|
||||
static std::string sync_room(client &, const m::room &, const args &, const m::event &);
|
||||
static std::string sync_rooms(client &, const m::user::id &, const m::room &, const args &, const m::event &);
|
||||
static bool handle(client &, const args &, const m::event &, const m::room &);
|
||||
static bool handle(client &, const args &, const m::event &);
|
||||
static std::string sync_room(client &, const m::room &, const args &, const vm::accepted &);
|
||||
static std::string sync_rooms(client &, const m::user::id &, const m::room &, const args &, const vm::accepted &);
|
||||
static bool handle(client &, const args &, const vm::accepted &, const m::room &);
|
||||
static bool handle(client &, const args &, const vm::accepted &);
|
||||
static void poll(client &, const args &);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue