mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 23:10:54 +01:00
modules/client/sync: Add some default fopts.
This commit is contained in:
parent
7707d0edd1
commit
53ba8dafcc
1 changed files with 73 additions and 5 deletions
|
@ -860,6 +860,29 @@ polylog_sync_room_state(shortpoll &sp,
|
||||||
json::stack::object &out,
|
json::stack::object &out,
|
||||||
const m::room &room)
|
const m::room &room)
|
||||||
{
|
{
|
||||||
|
static const m::event::fetch::opts fopts
|
||||||
|
{
|
||||||
|
m::event::keys::include
|
||||||
|
{
|
||||||
|
"content",
|
||||||
|
"depth",
|
||||||
|
"event_id",
|
||||||
|
"membership",
|
||||||
|
"origin_server_ts",
|
||||||
|
"prev_events",
|
||||||
|
"redacts",
|
||||||
|
"room_id",
|
||||||
|
"sender",
|
||||||
|
"state_key",
|
||||||
|
"type",
|
||||||
|
},
|
||||||
|
|
||||||
|
db::gopts
|
||||||
|
{
|
||||||
|
db::get::NO_CACHE | db::get::NO_CHECKSUM
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
json::stack::member member
|
json::stack::member member
|
||||||
{
|
{
|
||||||
out, "events"
|
out, "events"
|
||||||
|
@ -870,12 +893,13 @@ polylog_sync_room_state(shortpoll &sp,
|
||||||
member
|
member
|
||||||
};
|
};
|
||||||
|
|
||||||
const m::room::state state
|
m::room::state state
|
||||||
{
|
{
|
||||||
room
|
room, &fopts
|
||||||
};
|
};
|
||||||
|
|
||||||
state.for_each([&](const m::event &event)
|
state.for_each([&]
|
||||||
|
(const m::event &event)
|
||||||
{
|
{
|
||||||
if(at<"depth"_>(event) >= int64_t(sp.state_at))
|
if(at<"depth"_>(event) >= int64_t(sp.state_at))
|
||||||
return;
|
return;
|
||||||
|
@ -936,6 +960,29 @@ polylog_sync_room_timeline_events(shortpoll &sp,
|
||||||
const m::room &room,
|
const m::room &room,
|
||||||
bool &limited)
|
bool &limited)
|
||||||
{
|
{
|
||||||
|
static const m::event::fetch::opts fopts
|
||||||
|
{
|
||||||
|
m::event::keys::include
|
||||||
|
{
|
||||||
|
"content",
|
||||||
|
"depth",
|
||||||
|
"event_id",
|
||||||
|
"membership",
|
||||||
|
"origin_server_ts",
|
||||||
|
"prev_events",
|
||||||
|
"redacts",
|
||||||
|
"room_id",
|
||||||
|
"sender",
|
||||||
|
"state_key",
|
||||||
|
"type",
|
||||||
|
},
|
||||||
|
|
||||||
|
db::gopts
|
||||||
|
{
|
||||||
|
db::get::NO_CACHE | db::get::NO_CHECKSUM
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// messages seeks to the newest event, but the client wants the oldest
|
// messages seeks to the newest event, but the client wants the oldest
|
||||||
// event first so we seek down first and then iterate back up. Due to
|
// event first so we seek down first and then iterate back up. Due to
|
||||||
// an issue with rocksdb's prefix-iteration this iterator becomes
|
// an issue with rocksdb's prefix-iteration this iterator becomes
|
||||||
|
@ -944,7 +991,11 @@ polylog_sync_room_timeline_events(shortpoll &sp,
|
||||||
// way back. This is not a big deal but rocksdb should fix their shit.
|
// way back. This is not a big deal but rocksdb should fix their shit.
|
||||||
ssize_t i(0);
|
ssize_t i(0);
|
||||||
m::event::id::buf event_id;
|
m::event::id::buf event_id;
|
||||||
m::room::messages it{room};
|
m::room::messages it
|
||||||
|
{
|
||||||
|
room, &fopts
|
||||||
|
};
|
||||||
|
|
||||||
for(; it && i < 10; --it, ++i)
|
for(; it && i < 10; --it, ++i)
|
||||||
{
|
{
|
||||||
event_id = it.event_id();
|
event_id = it.event_id();
|
||||||
|
@ -1000,7 +1051,24 @@ polylog_sync_room_ephemeral_events(shortpoll &sp,
|
||||||
members.for_each("join", m::room::members::closure{[&]
|
members.for_each("join", m::room::members::closure{[&]
|
||||||
(const m::user &user)
|
(const m::user &user)
|
||||||
{
|
{
|
||||||
const m::user::room user_room{user};
|
static const m::event::fetch::opts fopts
|
||||||
|
{
|
||||||
|
db::gopts
|
||||||
|
{
|
||||||
|
db::get::NO_CACHE | db::get::NO_CHECKSUM
|
||||||
|
},
|
||||||
|
|
||||||
|
m::event::keys::include
|
||||||
|
{
|
||||||
|
"event_id",
|
||||||
|
"content",
|
||||||
|
"sender",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
m::user::room user_room{user};
|
||||||
|
user_room.fopts = &fopts;
|
||||||
|
|
||||||
if(head_idx(std::nothrow, user_room) <= sp.since)
|
if(head_idx(std::nothrow, user_room) <= sp.since)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue