@@ -6963,8 +6963,8 @@
|
||||
);
|
||||
};
|
||||
|
||||
const rotateCurrentActivation = async (activationCandidate, reason = '', releaseAction = 'cancel') => {
|
||||
const normalizedActivation = normalizeActivation(activationCandidate);
|
||||
const rotateCurrentActivation = async (reason = '', releaseAction = 'cancel') => {
|
||||
const normalizedActivation = normalizeActivation(activation);
|
||||
if (!normalizedActivation || getActivationProviderId(normalizedActivation, state) !== PHONE_SMS_PROVIDER_MADAO) {
|
||||
return { handled: false, nextActivation: null };
|
||||
}
|
||||
@@ -6984,6 +6984,9 @@
|
||||
if (!nextActivation) {
|
||||
return { handled: true, nextActivation: null };
|
||||
}
|
||||
activation = nextActivation;
|
||||
shouldCancelActivation = true;
|
||||
await persistCurrentActivation(nextActivation);
|
||||
await addLog(
|
||||
`步骤 9:MaDao 已通过路由替换切换到新号码 ${nextActivation.phoneNumber}。`,
|
||||
'info'
|
||||
@@ -7001,19 +7004,13 @@
|
||||
`步骤 9:添加手机号失败后正在更换号码(${formatStep9Reason(failureReason)},${usedNumberReplacementAttempts}/${maxNumberReplacementAttempts})。`,
|
||||
'warn'
|
||||
);
|
||||
const failedActivation = activation;
|
||||
const rotated = shouldCancelActivation && failedActivation
|
||||
const rotated = shouldCancelActivation && activation
|
||||
? await rotateCurrentActivation(
|
||||
failedActivation,
|
||||
failureCode || failureReason,
|
||||
getPhoneReplacementReleaseAction(failureCode || failureReason)
|
||||
)
|
||||
: { handled: false, nextActivation: null };
|
||||
if (rotated.nextActivation) {
|
||||
activation = normalizeActivation(rotated.nextActivation);
|
||||
shouldCancelActivation = true;
|
||||
await clearCurrentActivation();
|
||||
await persistCurrentActivation(activation);
|
||||
preferReuseExistingActivationOnAddPhone = false;
|
||||
addPhoneReentryWithSameActivation = 0;
|
||||
pageState = {
|
||||
@@ -7129,14 +7126,9 @@
|
||||
);
|
||||
}
|
||||
const rotated = shouldCancelActivation && activation
|
||||
? await rotateCurrentActivation(activation, 'returned_to_add_phone_loop', 'cancel')
|
||||
? await rotateCurrentActivation('returned_to_add_phone_loop', 'cancel')
|
||||
: { handled: false, nextActivation: null };
|
||||
if (rotated.nextActivation) {
|
||||
activation = normalizeActivation(rotated.nextActivation);
|
||||
shouldCancelActivation = true;
|
||||
await clearCurrentActivation();
|
||||
await persistCurrentActivation(activation);
|
||||
} else {
|
||||
if (!rotated.nextActivation) {
|
||||
if (!rotated.handled && shouldCancelActivation && activation) {
|
||||
await cancelPhoneActivation(state, activation);
|
||||
}
|
||||
@@ -7199,14 +7191,9 @@
|
||||
);
|
||||
}
|
||||
const rotated = shouldCancelActivation && activation
|
||||
? await rotateCurrentActivation(activation, 'phone_number_used', 'ban')
|
||||
? await rotateCurrentActivation('phone_number_used', 'ban')
|
||||
: { handled: false, nextActivation: null };
|
||||
if (rotated.nextActivation) {
|
||||
activation = normalizeActivation(rotated.nextActivation);
|
||||
shouldCancelActivation = true;
|
||||
await clearCurrentActivation();
|
||||
await persistCurrentActivation(activation);
|
||||
} else {
|
||||
if (!rotated.nextActivation) {
|
||||
if (!rotated.handled && shouldCancelActivation && activation) {
|
||||
await banPhoneActivation(state, activation);
|
||||
}
|
||||
@@ -7295,8 +7282,6 @@
|
||||
|
||||
let shouldReplaceNumber = false;
|
||||
let replaceReason = '';
|
||||
let failedActivationForReplacement = null;
|
||||
let replacementPreparedInAdvance = false;
|
||||
|
||||
for (let attempt = 1; attempt <= DEFAULT_PHONE_SUBMIT_ATTEMPTS; attempt += 1) {
|
||||
throwIfStopped();
|
||||
@@ -7306,7 +7291,6 @@
|
||||
await markPreferredActivationExhausted(codeResult.reason || 'sms_timeout');
|
||||
shouldReplaceNumber = true;
|
||||
replaceReason = codeResult.reason || 'sms_not_received';
|
||||
failedActivationForReplacement = activation;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7342,7 +7326,6 @@
|
||||
if (isPhoneNumberUsedError(invalidErrorText)) {
|
||||
shouldReplaceNumber = true;
|
||||
replaceReason = 'phone_number_used';
|
||||
failedActivationForReplacement = activation;
|
||||
await discardPhoneActivationFromReuse(
|
||||
`目标站拒绝该号码(${invalidErrorText})。`,
|
||||
activation,
|
||||
@@ -7353,19 +7336,13 @@
|
||||
`自动白嫖复用号码 ${activation.phoneNumber} 被目标站拒绝。`
|
||||
);
|
||||
}
|
||||
if (shouldCancelActivation && activation) {
|
||||
const rotated = await rotateCurrentActivation(activation, 'phone_number_used', 'ban');
|
||||
if (rotated.nextActivation) {
|
||||
activation = normalizeActivation(rotated.nextActivation);
|
||||
shouldCancelActivation = true;
|
||||
replacementPreparedInAdvance = true;
|
||||
} else if (rotated.handled) {
|
||||
activation = null;
|
||||
shouldCancelActivation = false;
|
||||
} else {
|
||||
await banPhoneActivation(state, activation);
|
||||
shouldCancelActivation = false;
|
||||
}
|
||||
if (
|
||||
shouldCancelActivation
|
||||
&& activation
|
||||
&& getActivationProviderId(activation, state) !== PHONE_SMS_PROVIDER_MADAO
|
||||
) {
|
||||
await banPhoneActivation(state, activation);
|
||||
shouldCancelActivation = false;
|
||||
}
|
||||
await addLog(
|
||||
`步骤 9:手机号被提示已使用(${invalidErrorText}),立即更换新号码。`,
|
||||
@@ -7377,20 +7354,13 @@
|
||||
if (attempt >= DEFAULT_PHONE_SUBMIT_ATTEMPTS) {
|
||||
shouldReplaceNumber = true;
|
||||
replaceReason = 'code_rejected';
|
||||
failedActivationForReplacement = activation;
|
||||
if (shouldCancelActivation && activation) {
|
||||
const rotated = await rotateCurrentActivation(activation, 'code_rejected', 'ban');
|
||||
if (rotated.nextActivation) {
|
||||
activation = normalizeActivation(rotated.nextActivation);
|
||||
shouldCancelActivation = true;
|
||||
replacementPreparedInAdvance = true;
|
||||
} else if (rotated.handled) {
|
||||
activation = null;
|
||||
shouldCancelActivation = false;
|
||||
} else {
|
||||
await banPhoneActivation(state, activation);
|
||||
shouldCancelActivation = false;
|
||||
}
|
||||
if (
|
||||
shouldCancelActivation
|
||||
&& activation
|
||||
&& getActivationProviderId(activation, state) !== PHONE_SMS_PROVIDER_MADAO
|
||||
) {
|
||||
await banPhoneActivation(state, activation);
|
||||
shouldCancelActivation = false;
|
||||
}
|
||||
await addLog(
|
||||
`步骤 9:手机验证码连续 ${DEFAULT_PHONE_SUBMIT_ATTEMPTS} 次被拒(${invalidErrorText}),将更换号码。`,
|
||||
@@ -7496,47 +7466,33 @@
|
||||
throw buildPhoneReplacementLimitError(maxNumberReplacementAttempts, replaceReason || 'unknown');
|
||||
}
|
||||
|
||||
const failedActivation = failedActivationForReplacement || activation;
|
||||
const rotated = replacementPreparedInAdvance
|
||||
? { handled: true, nextActivation: activation }
|
||||
: (
|
||||
shouldCancelActivation && failedActivation
|
||||
? await rotateCurrentActivation(
|
||||
failedActivation,
|
||||
replaceReason || 'replace_number',
|
||||
getPhoneReplacementReleaseAction(replaceReason || 'replace_number')
|
||||
)
|
||||
: { handled: false, nextActivation: null }
|
||||
);
|
||||
if (shouldRetireFreeReusableActivationOnFailure(await getState(), failedActivation)) {
|
||||
const rotated = shouldCancelActivation && activation
|
||||
? await rotateCurrentActivation(
|
||||
replaceReason || 'replace_number',
|
||||
getPhoneReplacementReleaseAction(replaceReason || 'replace_number')
|
||||
)
|
||||
: { handled: false, nextActivation: null };
|
||||
if (shouldRetireFreeReusableActivationOnFailure(await getState(), activation)) {
|
||||
await retireFreeReusableActivation(
|
||||
`自动白嫖复用号码 ${failedActivation.phoneNumber} 在失败后被更换。`
|
||||
`自动白嫖复用号码 ${activation.phoneNumber} 在失败后被更换。`
|
||||
);
|
||||
}
|
||||
if (isPhoneNumberUsedFailureReason(replaceReason) && failedActivation) {
|
||||
if (isPhoneNumberUsedFailureReason(replaceReason)) {
|
||||
await discardPhoneActivationFromReuse(
|
||||
`目标站拒绝该号码(${replaceReason})。`,
|
||||
failedActivation,
|
||||
activation,
|
||||
await getState()
|
||||
);
|
||||
}
|
||||
await clearCurrentActivation();
|
||||
if (rotated.nextActivation) {
|
||||
activation = normalizeActivation(rotated.nextActivation);
|
||||
shouldCancelActivation = Boolean(activation);
|
||||
if (activation) {
|
||||
await persistCurrentActivation(activation);
|
||||
}
|
||||
} else {
|
||||
if (!rotated.handled && shouldCancelActivation && failedActivation) {
|
||||
await cancelPhoneActivation(state, failedActivation);
|
||||
if (!rotated.nextActivation) {
|
||||
if (!rotated.handled && shouldCancelActivation && activation) {
|
||||
await cancelPhoneActivation(state, activation);
|
||||
}
|
||||
await clearCurrentActivation();
|
||||
activation = null;
|
||||
shouldCancelActivation = false;
|
||||
}
|
||||
addPhoneReentryWithSameActivation = 0;
|
||||
failedActivationForReplacement = null;
|
||||
replacementPreparedInAdvance = false;
|
||||
|
||||
let returnResult = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user