web-next: /restore-character y /restore-items con todas las condiciones

- /restore-character: recupera personajes borrados por BD (como .character deleted
  restore). Condiciones: nivel>60, borrado <30 días, DK no si ya hay DK activo,
  nombre libre, cooldown 12h/personaje. Gratis. Tabla home_restorehistory.
- /restore-items: recupera ítems borrados vía SOAP del core (.item restore list /
  .item restore); el core aplica calidad/equipable/BoP/<7días. Cada ítem 100 PD
  (reembolso si SOAP falla), consulta con cooldown 8h/personaje + Turnstile.
  Tabla home_itemsearchhistory.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-14 13:09:11 +00:00
parent d95fa932f9
commit 03f75e189c
11 changed files with 671 additions and 0 deletions
@@ -0,0 +1,17 @@
import { getSession } from '@/lib/session'
import { restoreItem } from '@/lib/restore-items'
/** Restaura un ítem borrado (cuesta 100 PD). */
export async function POST(request: Request) {
const session = await getSession()
if (!session.accountId || !session.username) {
return Response.json({ success: false, error: 'notAuthenticated' }, { status: 401 })
}
let body: Record<string, unknown> = {}
try {
body = await request.json()
} catch {
return Response.json({ success: false, error: 'invalidRequest' }, { status: 400 })
}
return Response.json(await restoreItem(session.accountId, String(body.character ?? '').trim(), Number(body.recoverId)))
}
@@ -0,0 +1,22 @@
import { getSession } from '@/lib/session'
import { verifyTurnstile } from '@/lib/turnstile'
import { listDeletedItems } from '@/lib/restore-items'
/** Lista los ítems borrados recuperables de un personaje (cooldown 8 h). */
export async function POST(request: Request) {
const session = await getSession()
if (!session.accountId || !session.username) {
return Response.json({ success: false, error: 'notAuthenticated' }, { status: 401 })
}
let body: Record<string, unknown> = {}
try {
body = await request.json()
} catch {
return Response.json({ success: false, error: 'invalidRequest' }, { status: 400 })
}
const ip = (request.headers.get('x-forwarded-for') || '').split(',')[0].trim() || undefined
if (!(await verifyTurnstile(String(body.turnstile ?? ''), ip))) {
return Response.json({ success: false, error: 'captcha' })
}
return Response.json(await listDeletedItems(session.accountId, String(body.character ?? '').trim()))
}
@@ -0,0 +1,17 @@
import { getSession } from '@/lib/session'
import { restoreCharacter } from '@/lib/restore-character'
/** Recupera un personaje borrado de la cuenta en sesión (si cumple las condiciones). */
export async function POST(request: Request) {
const session = await getSession()
if (!session.accountId || !session.username) {
return Response.json({ success: false, error: 'notAuthenticated' }, { status: 401 })
}
let body: Record<string, unknown> = {}
try {
body = await request.json()
} catch {
return Response.json({ success: false, error: 'invalidRequest' }, { status: 400 })
}
return Response.json(await restoreCharacter(session.accountId, Number(body.guid)))
}