diff --git a/docs/api/admin.md b/docs/api/admin.md index 2eb2ed2..a713342 100644 --- a/docs/api/admin.md +++ b/docs/api/admin.md @@ -96,10 +96,11 @@ Use this to unlock all features for one user for a specified duration. ### request -request properties: ``purchaseToken`` and ``purchaseId`` +request properties: ``purchaseToken``, ``purchaseId`` and ``dryRun`` - ``purchasetoken`` is a string which the client shows at the purchase screen - ``purchaseId`` is the ID that is used at the bill +- ``dryRun`` is a boolean; setting true will skip the actual unlocking ### response diff --git a/src/api/admin.ts b/src/api/admin.ts index 22ebf23..1724c07 100644 --- a/src/api/admin.ts +++ b/src/api/admin.ts @@ -140,13 +140,15 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: { if ( typeof req.body !== 'object' || typeof req.body.purchaseToken !== 'string' || - typeof req.body.purchaseId !== 'string' + typeof req.body.purchaseId !== 'string' || + typeof req.body.dryRun !== 'boolean' ) { throw new BadRequest() } const purchaseToken: string = req.body.purchaseToken const purchaseId: string = req.body.purchaseId + const dryRun: boolean = req.body.dryRun const tokenContent = await verifyIdentitifyToken(purchaseToken) @@ -250,15 +252,17 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: { } } - await addPurchase({ - database, - familyId: tokenContent.familyId, - type: 'year', - service: 'directpurchase', - transactionId: purchaseId, - websocket, - transaction - }) + if (!dryRun) { + await addPurchase({ + database, + familyId: tokenContent.familyId, + type: 'year', + service: 'directpurchase', + transactionId: purchaseId, + websocket, + transaction + }) + } } return {