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

modules/m_event: Add option to toggle query for txnid; disable query for non-timeline appends.

This commit is contained in:
Jason Volk 2019-03-13 17:03:01 -07:00
parent 9f67a146f4
commit 1f35e9c57e
4 changed files with 9 additions and 6 deletions

View file

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

View file

@ -54,7 +54,8 @@ static void
_append(json::stack::array &,
const m::event &,
const m::event::idx &,
const m::user::room &);
const m::user::room &,
const bool &query_txnid = true);
resource::response
get__context(client &client,
@ -215,7 +216,7 @@ get__context(client &client,
if(!visible(event, request.user_id))
return;
_append(array, event, event_idx, user_room);
_append(array, event, event_idx, user_room, false);
});
}
@ -226,7 +227,8 @@ void
_append(json::stack::array &chunk,
const m::event &event,
const m::event::idx &event_idx,
const m::user::room &user_room)
const m::user::room &user_room,
const bool &query_txnid)
{
m::event_append_opts opts;
opts.event_idx = &event_idx;

View file

@ -204,8 +204,8 @@ ircd::m::sync::room_state_append(data &data,
{
m::event_append_opts opts;
opts.event_idx = &event_idx;
opts.client_txnid = &data.client_txnid;
opts.user_id = &data.user.user_id;
opts.user_room = &data.user_room;
opts.query_txnid = false;
m::append(events, event, opts);
}

View file

@ -478,12 +478,12 @@ ircd::m::append(json::stack::object &object,
const auto txnid_idx
{
!has_client_txnid && sender_is_user?
!has_client_txnid && sender_is_user && opts.query_txnid?
opts.user_room->get(std::nothrow, "ircd.client.txnid", at<"event_id"_>(event)):
0UL
};
if(!has_client_txnid && !txnid_idx && sender_is_user)
if(!has_client_txnid && !txnid_idx && sender_is_user && opts.query_txnid)
log::dwarning
{
log, "Could not find transaction_id for %s from %s in %s",