From 08753dc2545813caf714c9252a7873ab84af5bed Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 10 Feb 2023 19:51:16 -0800 Subject: [PATCH] ircd::m: Add dbs::opts passed to room::purge and event::purge interfaces. --- include/ircd/m/event/purge.h | 9 ++++++++ include/ircd/m/room/purge.h | 3 +++ matrix/event_purge.cc | 41 +++++++++++++++++++++++++++++++++--- matrix/room_purge.cc | 4 ++-- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/include/ircd/m/event/purge.h b/include/ircd/m/event/purge.h index c49b60be3..4a7e55f1f 100644 --- a/include/ircd/m/event/purge.h +++ b/include/ircd/m/event/purge.h @@ -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 { + 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 &); }; diff --git a/include/ircd/m/room/purge.h b/include/ircd/m/room/purge.h index c0f7efe3d..878be7707 100644 --- a/include/ircd/m/room/purge.h +++ b/include/ircd/m/room/purge.h @@ -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 idx { diff --git a/matrix/event_purge.cc b/matrix/event_purge.cc index 9a0832906..ba25ccb13 100644 --- a/matrix/event_purge.cc +++ b/matrix/event_purge.cc @@ -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); diff --git a/matrix/room_purge.cc b/matrix/room_purge.cc index 27afd450c..80e31f2b1 100644 --- a/matrix/room_purge.cc +++ b/matrix/room_purge.cc @@ -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;