mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
refactor(server): plan 4 — unify the two user-data-erasure enqueue paths
UserCleanupService.erasePluginUserData (the account-deletion transaction's own UC2/UC3 enqueue) and PluginRuntimeService.enqueueUserErasure (the emitUserDeleted sink's post-commit enqueue) independently walked the identical SELECT id, permissions FROM plugins + JSON.parse + hook:user-data filter + INSERT OR IGNORE — and both genuinely run for every account deletion, since every emitUserDeleted call site (auth.service.ts, admin.service.ts, trip-members.service.ts's guest removal) fires immediately after deleteUserCompletely. Extracted the shared filter into enqueueHookUserDataErasures (nest/plugins/user-erasure-enqueue.ts) and pointed both call sites at it. UC2/UC3 also come off DatabaseService onto PluginsRepository/ PluginUserErasureQueueRepository in the same change (they were the last raw statements standing in the way of sharing one implementation) — this narrows the Plan 3b Task 5 "stays raw, owned by Plan 3j" ruling to UC1 only (plugin_user_config/plugin_oauth_tokens/plugin_oauth_state), which still stays raw, unaffected. UserCleanupService's orphan-data-directory scan (a plugin uninstalled with data retained) has no equivalent on the enqueueUserErasure side and stays there, now via the same repository. Both enqueue calls still run per deletion (INSERT OR IGNORE keeps this idempotent) — this unifies the IMPLEMENTATION, not the call count; not touching the emitUserDeleted event-sink wiring itself was a deliberate, smaller-blast-radius choice for this task.
This commit is contained in:
@@ -111,7 +111,7 @@ import { Settings } from '../../src/db/entities/Settings.entity';
|
||||
import { NotificationChannelPreferences } from '../../src/db/entities/NotificationChannelPreferences.entity';
|
||||
import { createTestTripFilesRepo, createTestFileLinksRepo, createTestBudgetItemsRepo } from './files-repos';
|
||||
import { budgetRepoArgs } from './budget-repos';
|
||||
import { createTestShareTokensRepo } from './share-repos';
|
||||
import { createTestShareTokensRepo, createTestPluginsRepo, createTestPluginUserErasureQueueRepo } from './share-repos';
|
||||
import {
|
||||
createTestCollabMessageReactionsRepo, createTestCollabNotesRepo, createTestCollabPollsRepo,
|
||||
createTestCollabPollVotesRepo, createTestCollabLinksRepo, createTestCollabMessagesRepo,
|
||||
@@ -292,7 +292,7 @@ export async function createPluginRpcHostFactory(dbs: DatabaseService): Promise<
|
||||
// After accommodations: a hotel booking writes the stay's day stop through it.
|
||||
const reservations = new ReservationsService(permissions, budget, realtime, notificationsStub(), new ReservationsReadService(await createTestReservationsRepo(dbs.connection), await createTestReservationEndpointsRepo(dbs.connection), await createTestReservationTravelersRepo(dbs.connection)), accommodations, await createTestUnitOfWork(dbs.connection), await createTestReservationsRepo(dbs.connection), await createTestReservationEndpointsRepo(dbs.connection), await createTestReservationTravelersRepo(dbs.connection), await createTestReservationDayPositionsRepo(dbs.connection), await createTestDayAccommodationsRepo(dbs.connection), await createTestDaysRepo(dbs.connection), await createTestPlacesRepo(dbs.connection), await createTestDayAssignmentsRepo(dbs.connection), await createTestTripMembersRepo(dbs.connection), await createTestUsersRepo(dbs.connection), await createTestTripsRepo(dbs.connection), await createTestBudgetItemsRepo(dbs.connection));
|
||||
const trips = new TripsService(dbs, reservations, days, permissions, budget, vacay, realtime, unsplash, generalStorage, await createTestUnitOfWork(dbs.connection), (await sharedTestOrm(dbs.connection)).em);
|
||||
const members = new TripMembersService(budget, new UserCleanupService(dbs, budget, await createTestUnitOfWork(dbs.connection), usersRepo, await createTestTripMembersRepo(dbs.connection), await createTestBudgetItemsRepo(dbs.connection), await createTestJourneyShareTokensRepo(dbs.connection), await createTestJourneysRepo(dbs.connection), await createTestJourneyEntriesRepo(dbs.connection), await createTestJourneyContributorsRepo(dbs.connection), await createTestShareTokensRepo(dbs.connection)), permissions, realtime, notificationsStub(), await createTestUnitOfWork(dbs.connection), await createTestTripsRepo(dbs.connection), await createTestTripMembersRepo(dbs.connection), usersRepo);
|
||||
const members = new TripMembersService(budget, new UserCleanupService(dbs, budget, await createTestUnitOfWork(dbs.connection), usersRepo, await createTestTripMembersRepo(dbs.connection), await createTestBudgetItemsRepo(dbs.connection), await createTestJourneyShareTokensRepo(dbs.connection), await createTestJourneysRepo(dbs.connection), await createTestJourneyEntriesRepo(dbs.connection), await createTestJourneyContributorsRepo(dbs.connection), await createTestShareTokensRepo(dbs.connection), await createTestPluginsRepo(dbs.connection), await createTestPluginUserErasureQueueRepo(dbs.connection)), permissions, realtime, notificationsStub(), await createTestUnitOfWork(dbs.connection), await createTestTripsRepo(dbs.connection), await createTestTripMembersRepo(dbs.connection), usersRepo);
|
||||
// Plan 3j Task 1 — PluginGuards' own role lookup (PG3/PG4) now goes
|
||||
// through UsersRepository.getRole; `usersRepo` above is the same
|
||||
// sharedTestOrm-backed repository every other service in this file uses.
|
||||
|
||||
Reference in New Issue
Block a user