ircd:Ⓜ️ Add dbs::opts passed to room::purge and event::purge interfaces.

This commit is contained in:
Jason Volk 2023-02-10 19:51:16 -08:00
parent 8d634fb901
commit 08753dc254
4 changed files with 52 additions and 5 deletions

View File

@ -11,6 +11,12 @@
#pragma once
#define HAVE_IRCD_M_EVENT_PURGE_H
//XXX fwd decl
namespace ircd::m::dbs
{
struct opts;
}
/// Erase an event from the database.
///
/// Purging an event will erase its data and metadata, including applying
@ -30,7 +36,10 @@
struct ircd::m::event::purge
:returns<bool>
{
purge(db::txn &, const event::idx &, const event &, dbs::opts);
purge(db::txn &, const event::idx &, const event &);
purge(db::txn &, const event::idx &, dbs::opts);
purge(db::txn &, const event::idx &);
purge(const event::idx &, dbs::opts);
purge(const event::idx &);
};

View File

@ -42,6 +42,9 @@ struct ircd::m::room::purge
/// Options for purge
struct ircd::m::room::purge::opts
{
/// Lower-level options passed to event::purge and dbs::
dbs::opts wopts;
/// Limit purge to the index window
pair<event::idx> idx
{

View File

@ -9,6 +9,17 @@
// full license for this software is available in the LICENSE file.
ircd::m::event::purge::purge(const event::idx &event_idx)
:purge
{
event_idx, dbs::opts
{
}
}
{
}
ircd::m::event::purge::purge(const event::idx &event_idx,
dbs::opts opts)
:returns{false}
{
assert(m::dbs::events);
@ -17,7 +28,7 @@ ircd::m::event::purge::purge(const event::idx &event_idx)
*m::dbs::events
};
if(!purge(txn, event_idx))
if(!purge(txn, event_idx, opts))
return;
txn();
@ -26,6 +37,18 @@ ircd::m::event::purge::purge(const event::idx &event_idx)
ircd::m::event::purge::purge(db::txn &txn,
const event::idx &event_idx)
:purge
{
txn, event_idx, dbs::opts
{
}
}
{
}
ircd::m::event::purge::purge(db::txn &txn,
const event::idx &event_idx,
dbs::opts opts)
:returns{false}
{
const m::event::fetch event
@ -36,15 +59,27 @@ ircd::m::event::purge::purge(db::txn &txn,
if(!event.valid)
return;
ret = purge(txn, event_idx, event);
ret = purge(txn, event_idx, event, opts);
}
ircd::m::event::purge::purge(db::txn &txn,
const event::idx &event_idx,
const event &event)
:purge
{
txn, event_idx, event, dbs::opts
{
}
}
{
}
ircd::m::event::purge::purge(db::txn &txn,
const event::idx &event_idx,
const event &event,
dbs::opts opts)
:returns{false}
{
m::dbs::opts opts;
opts.op = db::op::DELETE;
opts.event_idx = event_idx;
m::dbs::write(txn, event, opts);

View File

@ -98,7 +98,7 @@ ircd::m::room::purge::state()
const auto purged
{
event::purge(txn, event_idx, event)
event::purge(txn, event_idx, event, opts.wopts)
};
ret += purged;
@ -133,7 +133,7 @@ ircd::m::room::purge::timeline()
const bool purged
{
event::purge(txn, it.event_idx(), event)
event::purge(txn, it.event_idx(), event, opts.wopts)
};
ret += purged;