This commit is contained in:
Lightczx
2023-09-04 15:46:58 +08:00
parent bf66cf96d8
commit ad10a758bd
5 changed files with 24 additions and 5 deletions

View File

@@ -1851,6 +1851,15 @@ namespace Snap.Hutao.Resource.Localization {
}
}
/// <summary>
/// 查找类似 验证失败,请前往米游社原神签到页面自行领取奖励 的本地化字符串。
/// </summary>
internal static string ServiceSignInRiskVerificationFailed {
get {
return ResourceManager.GetString("ServiceSignInRiskVerificationFailed", resourceCulture);
}
}
/// <summary>
/// 查找类似 签到成功,{0}×{1} 的本地化字符串。
/// </summary>

View File

@@ -770,6 +770,9 @@
<data name="ServiceSignInRewardListRequestFailed" xml:space="preserve">
<value>获取奖励列表失败</value>
</data>
<data name="ServiceSignInRiskVerificationFailed" xml:space="preserve">
<value>验证失败,请前往米游社原神签到页面自行领取奖励</value>
</data>
<data name="ServiceSignInSuccessRewardFormat" xml:space="preserve">
<value>签到成功,{0}×{1}</value>
</data>

View File

@@ -90,6 +90,11 @@ internal sealed partial class SignInClient
.TryCatchPostAsJsonAsync<SignInData, Response<SignInResult>>(ApiEndpoints.SignInRewardSign, new SignInData(userAndUid.Uid), options, logger, token)
.ConfigureAwait(false);
}
else
{
resp.ReturnCode = resp.Data.RiskCode;
resp.Message = SH.ServiceSignInRiskVerificationFailed;
}
}
return Response.Response.DefaultIfNull(resp);

View File

@@ -24,7 +24,7 @@ internal sealed partial class HomaGeetestClient
if (string.IsNullOrEmpty(template))
{
return new() { Code = -1 };
return new() { Code = Response.Response.InternalFailure };
}
GeetestResponse? resp = await httpClient

View File

@@ -13,6 +13,8 @@ namespace Snap.Hutao.Web.Response;
[HighQuality]
internal class Response
{
public const int InternalFailure = 0x26F19335;
/// <summary>
/// 构造一个新的响应
/// </summary>
@@ -54,7 +56,7 @@ internal class Response
public static Response DefaultIfNull(Response? response, [CallerMemberName] string callerName = default!)
{
// 0x26F19335 is a magic number that hashed from "Snap.Hutao"
response ??= new(0x26F19335, SH.WebResponseRequestExceptionFormat.Format(callerName, null));
response ??= new(InternalFailure, SH.WebResponseRequestExceptionFormat.Format(callerName, null));
if (((KnownReturnCode)response.ReturnCode) is KnownReturnCode.PleaseLogin or KnownReturnCode.RET_TOKEN_INVALID)
{
@@ -74,14 +76,14 @@ internal class Response
public static Response<TData> DefaultIfNull<TData>(Response<TData>? response, [CallerMemberName] string callerName = default!)
{
// 0x26F19335 is a magic number that hashed from "Snap.Hutao"
response ??= new(0x26F19335, SH.WebResponseRequestExceptionFormat.Format(callerName, typeof(TData).Name), default);
response ??= new(InternalFailure, SH.WebResponseRequestExceptionFormat.Format(callerName, typeof(TData).Name), default);
if (((KnownReturnCode)response.ReturnCode) is KnownReturnCode.PleaseLogin or KnownReturnCode.RET_TOKEN_INVALID)
{
response.Message = SH.WebResponseRefreshCookieHintFormat.Format(response.Message);
}
return response ?? new(0x26F19335, SH.WebResponseRequestExceptionFormat.Format(callerName, typeof(TData).Name), default);
return response ?? new(InternalFailure, SH.WebResponseRequestExceptionFormat.Format(callerName, typeof(TData).Name), default);
}
/// <summary>
@@ -102,7 +104,7 @@ internal class Response
else
{
// Magic number that hashed from "Snap.Hutao"
return new(0x26F19335, SH.WebResponseRequestExceptionFormat.Format(callerName, typeof(TData).Name), default);
return new(InternalFailure, SH.WebResponseRequestExceptionFormat.Format(callerName, typeof(TData).Name), default);
}
}