♻️ Updated steam presence update logic

This commit is contained in:
2025-11-06 23:47:35 +08:00
parent 3e98ac29b7
commit 1351db5482
3 changed files with 27 additions and 39 deletions

View File

@@ -106,12 +106,12 @@ public class SteamPresenceService(
"steam", "steam",
account.Id, account.Id,
UpdateActivityWithPresenceData, UpdateActivityWithPresenceData,
5 10
); );
// If update failed (no existing activity), create a new one // If update failed (no existing activity), create a new one
if (updatedActivity == null) if (updatedActivity == null)
await accountEventService.SetActivity(presenceActivity, 5); await accountEventService.SetActivity(presenceActivity, 10);
// Local function to avoid capturing external variables in lambda // Local function to avoid capturing external variables in lambda
void UpdateActivityWithPresenceData(SnPresenceActivity activity) void UpdateActivityWithPresenceData(SnPresenceActivity activity)
@@ -167,12 +167,12 @@ public class SteamPresenceService(
"steam", "steam",
account.Id, account.Id,
UpdateActivityWithPresenceData, UpdateActivityWithPresenceData,
5 10
); );
// If update failed (no existing activity), create a new one // If update failed (no existing activity), create a new one
if (updatedActivity == null) if (updatedActivity == null)
await accountEventService.SetActivity(presenceActivity, 5); await accountEventService.SetActivity(presenceActivity, 10);
// Local function to avoid capturing external variables in lambda // Local function to avoid capturing external variables in lambda
void UpdateActivityWithPresenceData(SnPresenceActivity activity) void UpdateActivityWithPresenceData(SnPresenceActivity activity)

View File

@@ -1,5 +1,4 @@
using DysonNetwork.Shared.Cache; using DysonNetwork.Shared.Cache;
using System.Web;
namespace DysonNetwork.Pass.Auth.OpenId; namespace DysonNetwork.Pass.Auth.OpenId;

View File

@@ -13,82 +13,73 @@ public static class ScheduledJobsConfiguration
{ {
services.AddQuartz(q => services.AddQuartz(q =>
{ {
var appDatabaseRecyclingJob = new JobKey("AppDatabaseRecycling"); q.AddJob<AppDatabaseRecyclingJob>(opts => opts.WithIdentity("AppDatabaseRecycling"));
q.AddJob<AppDatabaseRecyclingJob>(opts => opts.WithIdentity(appDatabaseRecyclingJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(appDatabaseRecyclingJob) .ForJob("AppDatabaseRecycling")
.WithIdentity("AppDatabaseRecyclingTrigger") .WithIdentity("AppDatabaseRecyclingTrigger")
.WithCronSchedule("0 0 0 * * ?")); .WithCronSchedule("0 0 0 * * ?"));
var actionLogFlushJob = new JobKey("ActionLogFlush"); q.AddJob<ActionLogFlushJob>(opts => opts.WithIdentity("ActionLogFlush"));
q.AddJob<ActionLogFlushJob>(opts => opts.WithIdentity(actionLogFlushJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(actionLogFlushJob) .ForJob("ActionLogFlush")
.WithIdentity("ActionLogFlushTrigger") .WithIdentity("ActionLogFlushTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInMinutes(5) .WithIntervalInMinutes(5)
.RepeatForever()) .RepeatForever())
); );
var lastActiveFlushJob = new JobKey("LastActiveFlush"); q.AddJob<LastActiveFlushJob>(opts => opts.WithIdentity("LastActiveFlush"));
q.AddJob<LastActiveFlushJob>(opts => opts.WithIdentity(lastActiveFlushJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(lastActiveFlushJob) .ForJob("LastActiveFlush")
.WithIdentity("LastActiveFlushTrigger") .WithIdentity("LastActiveFlushTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInMinutes(5) .WithIntervalInMinutes(5)
.RepeatForever()) .RepeatForever())
); );
var subscriptionRenewalJob = new JobKey("SubscriptionRenewal"); q.AddJob<SubscriptionRenewalJob>(opts => opts.WithIdentity("SubscriptionRenewal"));
q.AddJob<SubscriptionRenewalJob>(opts => opts.WithIdentity(subscriptionRenewalJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(subscriptionRenewalJob) .ForJob("SubscriptionRenewal")
.WithIdentity("SubscriptionRenewalTrigger") .WithIdentity("SubscriptionRenewalTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInMinutes(30) .WithIntervalInMinutes(30)
.RepeatForever()) .RepeatForever())
); );
var giftCleanupJob = new JobKey("GiftCleanup"); q.AddJob<GiftCleanupJob>(opts => opts.WithIdentity("GiftCleanup"));
q.AddJob<GiftCleanupJob>(opts => opts.WithIdentity(giftCleanupJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(giftCleanupJob) .ForJob("GiftCleanup")
.WithIdentity("GiftCleanupTrigger") .WithIdentity("GiftCleanupTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInHours(1) .WithIntervalInHours(1)
.RepeatForever()) .RepeatForever())
); );
var fundExpirationJob = new JobKey("FundExpiration"); q.AddJob<FundExpirationJob>(opts => opts.WithIdentity("FundExpiration"));
q.AddJob<FundExpirationJob>(opts => opts.WithIdentity(fundExpirationJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(fundExpirationJob) .ForJob("FundExpiration")
.WithIdentity("FundExpirationTrigger") .WithIdentity("FundExpirationTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInHours(1) .WithIntervalInHours(1)
.RepeatForever()) .RepeatForever())
); );
var lotteryDrawJob = new JobKey("LotteryDraw"); q.AddJob<Lotteries.LotteryDrawJob>(opts => opts.WithIdentity("LotteryDraw"));
q.AddJob<Lotteries.LotteryDrawJob>(opts => opts.WithIdentity(lotteryDrawJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(lotteryDrawJob) .ForJob("LotteryDraw")
.WithIdentity("LotteryDrawTrigger") .WithIdentity("LotteryDrawTrigger")
.WithCronSchedule("0 0 0 * * ?")); .WithCronSchedule("0 0 0 * * ?"));
var socialCreditValidationJob = new JobKey("SocialCreditValidation"); q.AddJob<SocialCreditValidationJob>(opts => opts.WithIdentity("SocialCreditValidation"));
q.AddJob<SocialCreditValidationJob>(opts => opts.WithIdentity(socialCreditValidationJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(socialCreditValidationJob) .ForJob("SocialCreditValidation")
.WithIdentity("SocialCreditValidationTrigger") .WithIdentity("SocialCreditValidationTrigger")
.WithCronSchedule("0 0 0 * * ?")); .WithCronSchedule("0 0 0 * * ?"));
// Presence update jobs for different user stages // Presence update jobs for different user stages
var activePresenceUpdateJob = new JobKey("ActivePresenceUpdate"); q.AddJob<PresenceUpdateJob>(opts => opts.WithIdentity("ActivePresenceUpdate"));
q.AddJob<PresenceUpdateJob>(opts => opts.WithIdentity(activePresenceUpdateJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(activePresenceUpdateJob) .ForJob("ActivePresenceUpdate")
.WithIdentity("ActivePresenceUpdateTrigger") .WithIdentity("ActivePresenceUpdateTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInMinutes(1) .WithIntervalInMinutes(1)
@@ -96,21 +87,19 @@ public static class ScheduledJobsConfiguration
.UsingJobData("stage", nameof(PresenceUpdateStage.Active)) .UsingJobData("stage", nameof(PresenceUpdateStage.Active))
); );
var maybePresenceUpdateJob = new JobKey("MaybePresenceUpdate"); q.AddJob<PresenceUpdateJob>(opts => opts.WithIdentity("MaybePresenceUpdate"));
q.AddJob<PresenceUpdateJob>(opts => opts.WithIdentity(maybePresenceUpdateJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(maybePresenceUpdateJob) .ForJob("MaybePresenceUpdate")
.WithIdentity("MaybePresenceUpdateTrigger") .WithIdentity("MaybePresenceUpdateTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInMinutes(3) .WithIntervalInMinutes(5)
.RepeatForever()) .RepeatForever())
.UsingJobData("stage", nameof(PresenceUpdateStage.Maybe)) .UsingJobData("stage", nameof(PresenceUpdateStage.Maybe))
); );
var coldPresenceUpdateJob = new JobKey("ColdPresenceUpdate"); q.AddJob<PresenceUpdateJob>(opts => opts.WithIdentity("ColdPresenceUpdate"));
q.AddJob<PresenceUpdateJob>(opts => opts.WithIdentity(coldPresenceUpdateJob));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob(coldPresenceUpdateJob) .ForJob("ColdPresenceUpdate")
.WithIdentity("ColdPresenceUpdateTrigger") .WithIdentity("ColdPresenceUpdateTrigger")
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInMinutes(10) .WithIntervalInMinutes(10)