fix: captcha retry with 30s delay on OCR failure, max 2 attempts
This commit is contained in:
parent
72478bc3cb
commit
2227233dde
@ -113,6 +113,12 @@ export class WosService {
|
||||
fid: string,
|
||||
code: string,
|
||||
): 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;
|
||||
try {
|
||||
captchaCode = await this.solveCaptcha(fid);
|
||||
@ -129,15 +135,20 @@ export class WosService {
|
||||
);
|
||||
|
||||
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 {
|
||||
success: data.code === 0,
|
||||
message: data.code === 0 ? SUCCESS_MSG : (data.msg || `실패 (${data.err_code})`),
|
||||
success: false,
|
||||
message: data.msg || `실패 (${data.err_code})`,
|
||||
err_code: data.err_code,
|
||||
};
|
||||
}
|
||||
|
||||
return { success: false, message: '알 수 없는 오류' };
|
||||
}
|
||||
|
||||
async redeemAll(fid: string) {
|
||||
const activeCoupons = await this.wosCouponRepo.find({
|
||||
where: { is_expired: false },
|
||||
|
||||
Loading…
Reference in New Issue
Block a user