fix: remove captcha retry - exactly 1 captcha request per coupon to prevent TOO FREQUENT
All checks were successful
Build and Deploy / deploy-front (push) Successful in 8s
Build and Deploy / deploy-back (push) Successful in 20s

This commit is contained in:
hyoseung 2026-05-19 18:13:58 +09:00
parent ae3bd8b72a
commit 72478bc3cb

View File

@ -112,24 +112,12 @@ export class WosService {
private async redeemOne(
fid: string,
code: string,
maxRetries = 5,
): Promise<{ success: boolean; message: string; err_code?: number }> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
if (attempt > 1) {
await new Promise((r) => setTimeout(r, 3000));
}
let captchaCode: string;
try {
captchaCode = await this.solveCaptcha(fid);
} catch (err: any) {
const msg: string = err.message || '';
if (msg.includes('TOO FREQUENT') && attempt < maxRetries) {
this.logger.warn(`[${fid}] 캡차 TOO FREQUENT (${attempt}회), 10초 대기 후 재시도`);
await new Promise((r) => setTimeout(r, 10000));
continue;
}
return { success: false, message: `캡차 오류: ${msg}` };
return { success: false, message: `캡차 오류: ${err.message}` };
}
const ts = this.now();
@ -141,21 +129,13 @@ export class WosService {
);
const data = response.data;
this.logger.log(`[${fid}] ${code} attempt=${attempt} captcha=${captchaCode} → code=${data.code} err=${data.err_code} msg=${data.msg}`);
this.logger.log(`[${fid}] ${code} 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) {
if (attempt < maxRetries) continue;
return { success: false, message: `캡차 인식 실패 (${maxRetries}회 시도)`, err_code: data.err_code };
}
if (data.code !== 0 && (data.err_code === 0 || data.msg === 'Sign Error')) {
if (attempt < maxRetries) continue;
return { success: false, message: 'Sign Error (캡차 오인식)', err_code: data.err_code };
}
return { success: false, message: data.msg || `실패 (${data.err_code})`, err_code: data.err_code };
}
return { success: false, message: '알 수 없는 오류' };
return {
success: data.code === 0,
message: data.code === 0 ? SUCCESS_MSG : (data.msg || `실패 (${data.err_code})`),
err_code: data.err_code,
};
}
async redeemAll(fid: string) {
@ -291,7 +271,7 @@ export class WosService {
this.logger.error(`[${user.fid}] ${code} 지급 실패: ${err.message}`);
}
await new Promise((r) => setTimeout(r, 1500));
await new Promise((r) => setTimeout(r, 5000));
}
}