fix: captcha retry with 30s delay on OCR failure, max 2 attempts
All checks were successful
Build and Deploy / deploy-front (push) Successful in 7s
Build and Deploy / deploy-back (push) Successful in 20s

This commit is contained in:
hyoseung 2026-05-19 18:18:55 +09:00
parent 72478bc3cb
commit 2227233dde

View File

@ -113,6 +113,12 @@ export class WosService {
fid: string, fid: string,
code: string, code: string,
): Promise<{ success: boolean; message: string; err_code?: number }> { ): Promise<{ success: boolean; message: string; err_code?: number }> {
for (let attempt = 1; attempt <= 2; attempt++) {
if (attempt > 1) {
this.logger.warn(`[${fid}] ${code} 캡차 오인식, 30초 대기 후 재시도`);
await new Promise((r) => setTimeout(r, 30000));
}
let captchaCode: string; let captchaCode: string;
try { try {
captchaCode = await this.solveCaptcha(fid); captchaCode = await this.solveCaptcha(fid);
@ -129,15 +135,20 @@ export class WosService {
); );
const data = response.data; const data = response.data;
this.logger.log(`[${fid}] ${code} captcha=${captchaCode} → code=${data.code} err=${data.err_code} msg=${data.msg}`); this.logger.log(`[${fid}] ${code} attempt=${attempt} captcha=${captchaCode} → code=${data.code} err=${data.err_code} msg=${data.msg}`);
if (data.code === 0) return { success: true, message: SUCCESS_MSG };
if (data.err_code === 40103 && attempt < 2) continue;
return { return {
success: data.code === 0, success: false,
message: data.code === 0 ? SUCCESS_MSG : (data.msg || `실패 (${data.err_code})`), message: data.msg || `실패 (${data.err_code})`,
err_code: data.err_code, err_code: data.err_code,
}; };
} }
return { success: false, message: '알 수 없는 오류' };
}
async redeemAll(fid: string) { async redeemAll(fid: string) {
const activeCoupons = await this.wosCouponRepo.find({ const activeCoupons = await this.wosCouponRepo.find({
where: { is_expired: false }, where: { is_expired: false },