mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 14:31:11 +01:00
modules/m_event: Add option to toggle query for txnid; disable query for non-timeline appends.
This commit is contained in:
parent
9f67a146f4
commit
1f35e9c57e
4 changed files with 9 additions and 6 deletions
|
@ -20,6 +20,7 @@ namespace ircd::m
|
||||||
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()};
|
long age {std::numeric_limits<long>::min()};
|
||||||
|
bool query_txnid {true};
|
||||||
};
|
};
|
||||||
|
|
||||||
void append(json::stack::object &, const event &, const event_append_opts & = {});
|
void append(json::stack::object &, const event &, const event_append_opts & = {});
|
||||||
|
|
|
@ -54,7 +54,8 @@ static void
|
||||||
_append(json::stack::array &,
|
_append(json::stack::array &,
|
||||||
const m::event &,
|
const m::event &,
|
||||||
const m::event::idx &,
|
const m::event::idx &,
|
||||||
const m::user::room &);
|
const m::user::room &,
|
||||||
|
const bool &query_txnid = true);
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
get__context(client &client,
|
get__context(client &client,
|
||||||
|
@ -215,7 +216,7 @@ get__context(client &client,
|
||||||
if(!visible(event, request.user_id))
|
if(!visible(event, request.user_id))
|
||||||
return;
|
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,
|
_append(json::stack::array &chunk,
|
||||||
const m::event &event,
|
const m::event &event,
|
||||||
const m::event::idx &event_idx,
|
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;
|
m::event_append_opts opts;
|
||||||
opts.event_idx = &event_idx;
|
opts.event_idx = &event_idx;
|
||||||
|
|
|
@ -204,8 +204,8 @@ ircd::m::sync::room_state_append(data &data,
|
||||||
{
|
{
|
||||||
m::event_append_opts opts;
|
m::event_append_opts opts;
|
||||||
opts.event_idx = &event_idx;
|
opts.event_idx = &event_idx;
|
||||||
opts.client_txnid = &data.client_txnid;
|
|
||||||
opts.user_id = &data.user.user_id;
|
opts.user_id = &data.user.user_id;
|
||||||
opts.user_room = &data.user_room;
|
opts.user_room = &data.user_room;
|
||||||
|
opts.query_txnid = false;
|
||||||
m::append(events, event, opts);
|
m::append(events, event, opts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,12 +478,12 @@ ircd::m::append(json::stack::object &object,
|
||||||
|
|
||||||
const auto txnid_idx
|
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)):
|
opts.user_room->get(std::nothrow, "ircd.client.txnid", at<"event_id"_>(event)):
|
||||||
0UL
|
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::dwarning
|
||||||
{
|
{
|
||||||
log, "Could not find transaction_id for %s from %s in %s",
|
log, "Could not find transaction_id for %s from %s in %s",
|
||||||
|
|
Loading…
Reference in a new issue