mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Fix dailynote notification for hoyoverse account, block some unsupported operations
This commit is contained in:
@@ -106,8 +106,8 @@ internal sealed class User : ObservableObject
|
||||
User user = new(inner);
|
||||
bool isOk = false;
|
||||
|
||||
// TODO: 这里暂时使用是否存在 stoken 来判断是否为国际服,需要改进
|
||||
if (user.Entity.Stoken != null)
|
||||
// TODO: need a flag to indentify hoyoverse account
|
||||
if (user.Entity.Stoken != null)
|
||||
{
|
||||
isOk = await user.InitializeCoreAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -60,16 +60,15 @@ internal sealed class DailyNoteNotifier
|
||||
BindingClient bindingClient = scope.ServiceProvider.GetRequiredService<BindingClient>();
|
||||
AuthClient authClient = scope.ServiceProvider.GetRequiredService<AuthClient>();
|
||||
|
||||
Response<ActionTicketWrapper> actionTicketResponse = await authClient
|
||||
.GetActionTicketByStokenAsync("game_role", entry.User)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
string? attribution = SH.ServiceDailyNoteNotifierAttribution;
|
||||
if (actionTicketResponse.IsOk())
|
||||
|
||||
// TODO: need a flag to indentify hoyoverse account
|
||||
// For global server, stoken is null
|
||||
if (entry.User.Stoken == null)
|
||||
{
|
||||
Response<ListWrapper<UserGameRole>> rolesResponse = await scope.ServiceProvider
|
||||
.GetRequiredService<BindingClient>()
|
||||
.GetUserGameRolesByActionTicketAsync(actionTicketResponse.Data.Ticket, entry.User)
|
||||
.GetOsUserGameRolesByCookieAsync(entry.User)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (rolesResponse.IsOk())
|
||||
@@ -77,6 +76,27 @@ internal sealed class DailyNoteNotifier
|
||||
List<UserGameRole> roles = rolesResponse.Data.List;
|
||||
attribution = roles.SingleOrDefault(r => r.GameUid == entry.Uid)?.ToString() ?? "Unkonwn";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response<ActionTicketWrapper> actionTicketResponse = await authClient
|
||||
.GetActionTicketByStokenAsync("game_role", entry.User)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (actionTicketResponse.IsOk())
|
||||
{
|
||||
Response<ListWrapper<UserGameRole>> rolesResponse = await scope.ServiceProvider
|
||||
.GetRequiredService<BindingClient>()
|
||||
.GetUserGameRolesByActionTicketAsync(actionTicketResponse.Data.Ticket, entry.User)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (rolesResponse.IsOk())
|
||||
{
|
||||
List<UserGameRole> roles = rolesResponse.Data.List;
|
||||
attribution = roles.SingleOrDefault(r => r.GameUid == entry.Uid)?.ToString() ?? "Unkonwn";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToastContentBuilder builder = new ToastContentBuilder()
|
||||
|
||||
@@ -40,7 +40,7 @@ internal sealed class GachaLogQueryStokenProvider : IGachaLogQueryProvider
|
||||
{
|
||||
if (userAndUid.Uid.Region != "cn_gf01" && userAndUid.Uid.Region != "cn_qd01")
|
||||
{
|
||||
return new(false, "Global server player is unsupported currently");
|
||||
return new(false, "Unsupported for hoyoverse account");
|
||||
}
|
||||
|
||||
GenAuthKeyData data = GenAuthKeyData.CreateForWebViewGacha(userAndUid.Uid);
|
||||
|
||||
@@ -247,9 +247,17 @@ internal sealed class DailyNoteViewModel : Abstraction.ViewModel
|
||||
{
|
||||
if (UserAndUid.TryFromUser(userService.Current, out UserAndUid? userAndUid))
|
||||
{
|
||||
// ContentDialog must be created by main thread.
|
||||
await ThreadHelper.SwitchToMainThreadAsync();
|
||||
await new DailyNoteVerificationDialog(userAndUid).ShowAsync();
|
||||
// TODO: Add verify support for oversea user
|
||||
if (userAndUid.Uid.Region != "cn_gf01" || userAndUid.Uid.Region != "cn_qd01")
|
||||
{
|
||||
serviceProvider.GetRequiredService<IInfoBarService>().Warning("Unsupported for hoyoverse account");
|
||||
}
|
||||
else
|
||||
{
|
||||
// ContentDialog must be created by main thread.
|
||||
await ThreadHelper.SwitchToMainThreadAsync();
|
||||
await new DailyNoteVerificationDialog(userAndUid).ShowAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ internal sealed class CalculateClient
|
||||
public async Task<Response<Consumption>> ComputeAsync(Model.Entity.User user, AvatarPromotionDelta delta, CancellationToken token = default)
|
||||
{
|
||||
Response<Consumption>? resp;
|
||||
// TODO 添加用于判断国际服用户的 flag
|
||||
// TODO: need a flag to indentify hoyoverse account
|
||||
if (user.Stoken == null)
|
||||
{
|
||||
resp = await httpClient
|
||||
|
||||
Reference in New Issue
Block a user