🐛 Fix perk subscription getter
This commit is contained in:
@@ -47,7 +47,7 @@ public class AccountCurrentController(
|
||||
try
|
||||
{
|
||||
var subscription = await remoteSubscription.GetPerkSubscription(account.Id);
|
||||
if (subscription != null)
|
||||
if (subscription is not null)
|
||||
{
|
||||
account.PerkSubscription = SnWalletSubscription.FromProtoValue(subscription).ToReference();
|
||||
}
|
||||
@@ -344,7 +344,7 @@ public class AccountCurrentController(
|
||||
// Check PerkSubscription via RemoteSubscriptionService instead of relying on currentUser.PerkSubscription
|
||||
// which is not populated when currentUser comes from HttpContext.Items
|
||||
var perkSubscription = await remoteSubscription.GetPerkSubscription(currentUser.Id);
|
||||
if (perkSubscription == null)
|
||||
if (perkSubscription is null)
|
||||
return StatusCode(403, ApiError.Unauthorized(
|
||||
message: "You need to have a subscription to check-in backdated.",
|
||||
forbidden: true,
|
||||
@@ -377,7 +377,7 @@ public class AccountCurrentController(
|
||||
true when !await auth.ValidateCaptcha(captchaToken!) => BadRequest(ApiError.Validation(
|
||||
new Dictionary<string, string[]>
|
||||
{
|
||||
["captchaToken"] = new[] { "Invalid captcha token." }
|
||||
["captchaToken"] = ["Invalid captcha token."]
|
||||
}, traceId: HttpContext.TraceIdentifier)),
|
||||
_ => await events.CheckInDaily(currentUser, backdated)
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ public class AccountEventService(
|
||||
RingService.RingServiceClient pusher,
|
||||
Pass.Leveling.ExperienceService experienceService,
|
||||
RemotePaymentService payment,
|
||||
RemoteSubscriptionService subscriptions,
|
||||
INatsConnection nats
|
||||
)
|
||||
{
|
||||
@@ -223,6 +224,9 @@ public class AccountEventService(
|
||||
|
||||
public async Task<bool> CheckInDailyDoAskCaptcha(SnAccount user)
|
||||
{
|
||||
var perkSubscription = await subscriptions.GetPerkSubscription(user.Id);
|
||||
if (perkSubscription is not null) return false;
|
||||
|
||||
var cacheKey = $"{CaptchaCacheKey}{user.Id}";
|
||||
var needsCaptcha = await cache.GetAsync<bool?>(cacheKey);
|
||||
if (needsCaptcha is not null)
|
||||
|
||||
@@ -32,7 +32,7 @@ public class AccountPublicController(
|
||||
try
|
||||
{
|
||||
var subscription = await remoteSubscription.GetPerkSubscription(account.Id);
|
||||
if (subscription != null)
|
||||
if (subscription is not null)
|
||||
{
|
||||
account.PerkSubscription = SnWalletSubscription.FromProtoValue(subscription).ToReference();
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ public class AccountService(
|
||||
try
|
||||
{
|
||||
var subscription = await remoteSubscription.GetPerkSubscription(account.Id);
|
||||
if (subscription != null)
|
||||
if (subscription is not null)
|
||||
{
|
||||
account.PerkSubscription = SnWalletSubscription.FromProtoValue(subscription).ToReference();
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ public class AccountServiceGrpc(
|
||||
try
|
||||
{
|
||||
var subscription = await remoteSubscription.GetPerkSubscription(account.Id);
|
||||
if (subscription != null)
|
||||
if (subscription is not null)
|
||||
{
|
||||
account.PerkSubscription = SnWalletSubscription.FromProtoValue(subscription).ToReference();
|
||||
}
|
||||
@@ -321,7 +321,6 @@ public class AccountServiceGrpc(
|
||||
var subscriptions = await remoteSubscription.GetPerkSubscriptions(accountIds);
|
||||
|
||||
var subscriptionDict = subscriptions
|
||||
.Where(s => s != null)
|
||||
.ToDictionary(
|
||||
s => Guid.Parse(s.AccountId),
|
||||
s => SnWalletSubscription.FromProtoValue(s).ToReference()
|
||||
|
||||
Reference in New Issue
Block a user