mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 07:20:55 +01:00
ircd:Ⓜ️:dbs: Add present state queries on delete operations; move branches for clarity.
This commit is contained in:
parent
0fdeda3743
commit
ccfc05709f
5 changed files with 35 additions and 18 deletions
|
@ -315,8 +315,6 @@ ircd::m::dbs::_index_room(db::txn &txn,
|
||||||
if(opts.appendix.test(appendix::ROOM_HEAD_RESOLVE))
|
if(opts.appendix.test(appendix::ROOM_HEAD_RESOLVE))
|
||||||
_index_room_head_resolve(txn, event, opts);
|
_index_room_head_resolve(txn, event, opts);
|
||||||
|
|
||||||
if(defined(json::get<"state_key"_>(event)))
|
|
||||||
{
|
|
||||||
if(opts.appendix.test(appendix::ROOM_STATE))
|
if(opts.appendix.test(appendix::ROOM_STATE))
|
||||||
_index_room_state(txn, event, opts);
|
_index_room_state(txn, event, opts);
|
||||||
|
|
||||||
|
@ -325,7 +323,6 @@ ircd::m::dbs::_index_room(db::txn &txn,
|
||||||
|
|
||||||
if(opts.appendix.test(appendix::ROOM_JOINED) && at<"type"_>(event) == "m.room.member")
|
if(opts.appendix.test(appendix::ROOM_JOINED) && at<"type"_>(event) == "m.room.member")
|
||||||
_index_room_joined(txn, event, opts);
|
_index_room_joined(txn, event, opts);
|
||||||
}
|
|
||||||
|
|
||||||
if(opts.appendix.test(appendix::ROOM_REDACT) && json::get<"type"_>(event) == "m.room.redaction")
|
if(opts.appendix.test(appendix::ROOM_REDACT) && json::get<"type"_>(event) == "m.room.redaction")
|
||||||
_index_room_redact(txn, event, opts);
|
_index_room_redact(txn, event, opts);
|
||||||
|
@ -350,8 +347,6 @@ ircd::m::dbs::_prefetch_room(const event &event,
|
||||||
if(opts.appendix.test(appendix::ROOM_HEAD_RESOLVE))
|
if(opts.appendix.test(appendix::ROOM_HEAD_RESOLVE))
|
||||||
;//ret += _prefetch_room_head_resolve(event, opts);
|
;//ret += _prefetch_room_head_resolve(event, opts);
|
||||||
|
|
||||||
if(defined(json::get<"state_key"_>(event)))
|
|
||||||
{
|
|
||||||
if(opts.appendix.test(appendix::ROOM_STATE))
|
if(opts.appendix.test(appendix::ROOM_STATE))
|
||||||
;//ret += _prefetch_room_state(event, opts);
|
;//ret += _prefetch_room_state(event, opts);
|
||||||
|
|
||||||
|
@ -360,7 +355,6 @@ ircd::m::dbs::_prefetch_room(const event &event,
|
||||||
|
|
||||||
if(opts.appendix.test(appendix::ROOM_JOINED) && at<"type"_>(event) == "m.room.member")
|
if(opts.appendix.test(appendix::ROOM_JOINED) && at<"type"_>(event) == "m.room.member")
|
||||||
;//ret += _prefetch_room_joined(event, opts);
|
;//ret += _prefetch_room_joined(event, opts);
|
||||||
}
|
|
||||||
|
|
||||||
if(opts.appendix.test(appendix::ROOM_REDACT) && json::get<"type"_>(event) == "m.room.redaction")
|
if(opts.appendix.test(appendix::ROOM_REDACT) && json::get<"type"_>(event) == "m.room.redaction")
|
||||||
ret += _prefetch_room_redact(event, opts);
|
ret += _prefetch_room_redact(event, opts);
|
||||||
|
|
|
@ -113,6 +113,7 @@ ircd::m::dbs::_index_event_state(db::txn &txn,
|
||||||
assert(json::get<"type"_>(event));
|
assert(json::get<"type"_>(event));
|
||||||
assert(opts.event_idx);
|
assert(opts.event_idx);
|
||||||
|
|
||||||
|
// Ignore non-state
|
||||||
if(!defined(json::get<"state_key"_>(event)))
|
if(!defined(json::get<"state_key"_>(event)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,15 @@ ircd::m::dbs::_index_room_joined(db::txn &txn,
|
||||||
assert(opts.appendix.test(appendix::ROOM_JOINED));
|
assert(opts.appendix.test(appendix::ROOM_JOINED));
|
||||||
assert(at<"type"_>(event) == "m.room.member");
|
assert(at<"type"_>(event) == "m.room.member");
|
||||||
|
|
||||||
|
// Ignore non-state
|
||||||
|
if(!defined(json::get<"state_key"_>(event)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Ignore non-present state (similar to room_state)
|
||||||
|
if(opts.op == db::op::DELETE)
|
||||||
|
if(!room::state::present(opts.event_idx))
|
||||||
|
return;
|
||||||
|
|
||||||
thread_local char buf[ROOM_JOINED_KEY_MAX_SIZE];
|
thread_local char buf[ROOM_JOINED_KEY_MAX_SIZE];
|
||||||
const ctx::critical_assertion ca;
|
const ctx::critical_assertion ca;
|
||||||
const string_view &key
|
const string_view &key
|
||||||
|
|
|
@ -161,6 +161,15 @@ ircd::m::dbs::_index_room_state(db::txn &txn,
|
||||||
{
|
{
|
||||||
assert(opts.appendix.test(appendix::ROOM_STATE));
|
assert(opts.appendix.test(appendix::ROOM_STATE));
|
||||||
|
|
||||||
|
// Ignore non-state
|
||||||
|
if(!defined(json::get<"state_key"_>(event)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Ignore non-present state (likely coming from an event purge)
|
||||||
|
if(opts.op == db::op::DELETE)
|
||||||
|
if(!room::state::present(opts.event_idx))
|
||||||
|
return;
|
||||||
|
|
||||||
const ctx::critical_assertion ca;
|
const ctx::critical_assertion ca;
|
||||||
thread_local char buf[ROOM_STATE_KEY_MAX_SIZE];
|
thread_local char buf[ROOM_STATE_KEY_MAX_SIZE];
|
||||||
const string_view &key
|
const string_view &key
|
||||||
|
|
|
@ -161,6 +161,10 @@ ircd::m::dbs::_index_room_state_space(db::txn &txn,
|
||||||
{
|
{
|
||||||
assert(opts.appendix.test(appendix::ROOM_STATE_SPACE));
|
assert(opts.appendix.test(appendix::ROOM_STATE_SPACE));
|
||||||
|
|
||||||
|
// Ignore non-state
|
||||||
|
if(!defined(json::get<"state_key"_>(event)))
|
||||||
|
return;
|
||||||
|
|
||||||
const ctx::critical_assertion ca;
|
const ctx::critical_assertion ca;
|
||||||
thread_local char buf[ROOM_STATE_SPACE_KEY_MAX_SIZE];
|
thread_local char buf[ROOM_STATE_SPACE_KEY_MAX_SIZE];
|
||||||
const string_view &key
|
const string_view &key
|
||||||
|
|
Loading…
Reference in a new issue