mirror of
https://github.com/matrix-construct/construct
synced 2024-12-31 18:04:06 +01:00
modules/m_event: Unconditionally supply an age when no event_idx.
This commit is contained in:
parent
92ba96cdf1
commit
9f67a146f4
2 changed files with 13 additions and 12 deletions
|
@ -19,6 +19,7 @@ namespace ircd::m
|
||||||
const string_view *client_txnid {nullptr};
|
const string_view *client_txnid {nullptr};
|
||||||
const id::user *user_id {nullptr};
|
const id::user *user_id {nullptr};
|
||||||
const room *user_room {nullptr};
|
const room *user_room {nullptr};
|
||||||
|
long age {std::numeric_limits<long>::min()};
|
||||||
};
|
};
|
||||||
|
|
||||||
void append(json::stack::object &, const event &, const event_append_opts & = {});
|
void append(json::stack::object &, const event &, const event_append_opts & = {});
|
||||||
|
|
|
@ -512,29 +512,29 @@ ircd::m::append(json::stack::object &object,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!has_event_idx && !txnid_idx)
|
|
||||||
return;
|
|
||||||
|
|
||||||
json::stack::object unsigned_
|
json::stack::object unsigned_
|
||||||
{
|
{
|
||||||
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)
|
if(has_client_txnid)
|
||||||
json::stack::member
|
json::stack::member
|
||||||
{
|
{
|
||||||
unsigned_, "transaction_id", *opts.client_txnid
|
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)
|
if(txnid_idx)
|
||||||
m::get(std::nothrow, txnid_idx, "content", [&unsigned_]
|
m::get(std::nothrow, txnid_idx, "content", [&unsigned_]
|
||||||
(const json::object &content)
|
(const json::object &content)
|
||||||
|
|
Loading…
Reference in a new issue