0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

modules/m_event: Unconditionally supply an age when no event_idx.

This commit is contained in:
Jason Volk 2019-03-13 16:58:02 -07:00
parent 92ba96cdf1
commit 9f67a146f4
2 changed files with 13 additions and 12 deletions

View file

@ -19,6 +19,7 @@ namespace ircd::m
const string_view *client_txnid {nullptr};
const id::user *user_id {nullptr};
const room *user_room {nullptr};
long age {std::numeric_limits<long>::min()};
};
void append(json::stack::object &, const event &, const event_append_opts & = {});

View file

@ -512,29 +512,29 @@ ircd::m::append(json::stack::object &object,
});
}
if(!has_event_idx && !txnid_idx)
return;
json::stack::object unsigned_
{
object, "unsigned"
};
json::stack::member
{
unsigned_, "age", json::value
{
has_event_idx && opts.age != std::numeric_limits<long>::min()?
long(vm::current_sequence - *opts.event_idx):
opts.age != std::numeric_limits<long>::min()?
opts.age:
0L
}
};
if(has_client_txnid)
json::stack::member
{
unsigned_, "transaction_id", *opts.client_txnid
};
if(has_event_idx)
json::stack::member
{
unsigned_, "age", json::value
{
long(vm::current_sequence - *opts.event_idx)
}
};
if(txnid_idx)
m::get(std::nothrow, txnid_idx, "content", [&unsigned_]
(const json::object &content)