Cloud Functions 도메인 함수 — POP 원장 · 퀘스트 · 이클립스 · 행성 성장 · 캠페인 · 결제 · 알림 · 브리핑 · INSIDE · 추천 · 번역 · 서버 테스트

This commit is contained in:
Sn-Kinos
2026-09-29 17:06:48 +09:00
parent f483e8d94b
commit 316821e7d5
61 changed files with 14660 additions and 60 deletions
+26
View File
@@ -23,3 +23,29 @@ export function bootAdmin(): App {
export async function shutdownAdmin(): Promise<void> {
for (const app of getApps()) await deleteApp(app);
}
/**
* 그 사용자가 남긴 문서를 전부 지운다.
*
* **`users/{uid}` 아래만 지우면 모자란다.** 기여 차감은 팬덤 멤버 문서에도
* 누적되므로, 거기를 남겨 두면 다음 테스트에서 값이 겹쳐 올라간다. 실제로
* 그 때문에 「기여 40」을 기대하는 검증이 회차가 쌓이며 120 을 보았다.
*/
export async function wipeUser(uid: string): Promise<void> {
const db = getFirestore();
for (const sub of [
'popLots', 'popTransactions', 'growthEvents', 'questProgress', 'wallet',
'consents', 'purchases', 'subscription', 'subscriptionEvents', 'adBonuses',
'verifiedCompletions', 'rateLimits',
]) {
const snap = await db.collection(`users/${uid}/${sub}`).get();
await Promise.all(snap.docs.map((d) => d.ref.delete()));
}
await db.doc(`users/${uid}`).delete();
// 이 사용자가 멤버로 올라간 팬덤 문서까지 지운다.
const members = await db.collectionGroup('members').get();
await Promise.all(
members.docs.filter((d) => d.id === uid).map((d) => d.ref.delete()),
);
}