✨ Setup etcd helper and magic onion
This commit is contained in:
		| @@ -84,16 +84,16 @@ public class AccountEventService( | ||||
|         foreach (var userId in userIds) | ||||
|         { | ||||
|             var cacheKey = $"{StatusCacheKey}{userId}"; | ||||
|             // var cachedStatus = await cache.GetAsync<Status>(cacheKey); | ||||
|             // if (cachedStatus != null) | ||||
|             // { | ||||
|             //     cachedStatus.IsOnline = !cachedStatus.IsInvisible && ws.GetAccountIsConnected(userId); | ||||
|             //     results[userId] = cachedStatus; | ||||
|             // } | ||||
|             // else | ||||
|             // { | ||||
|             cacheMissUserIds.Add(userId); | ||||
|             // } | ||||
|             var cachedStatus = await cache.GetAsync<Status>(cacheKey); | ||||
|             if (cachedStatus != null) | ||||
|             { | ||||
|                 cachedStatus.IsOnline = !cachedStatus.IsInvisible /*&& ws.GetAccountIsConnected(userId)*/; | ||||
|                 results[userId] = cachedStatus; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 cacheMissUserIds.Add(userId); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (cacheMissUserIds.Any()) | ||||
| @@ -115,7 +115,7 @@ public class AccountEventService( | ||||
|                 status.IsOnline = !status.IsInvisible && isOnline; | ||||
|                 results[status.AccountId] = status; | ||||
|                 var cacheKey = $"{StatusCacheKey}{status.AccountId}"; | ||||
|                 // await cache.SetAsync(cacheKey, status, TimeSpan.FromMinutes(5)); | ||||
|                 await cache.SetAsync(cacheKey, status, TimeSpan.FromMinutes(5)); | ||||
|                 foundUserIds.Add(status.AccountId); | ||||
|             } | ||||
|  | ||||
| @@ -170,12 +170,12 @@ public class AccountEventService( | ||||
|     public async Task<bool> CheckInDailyDoAskCaptcha(Shared.Models.Account user) | ||||
|     { | ||||
|         var cacheKey = $"{CaptchaCacheKey}{user.Id}"; | ||||
|         // var needsCaptcha = await cache.GetAsync<bool?>(cacheKey); | ||||
|         // if (needsCaptcha is not null) | ||||
|         //     return needsCaptcha!.Value; | ||||
|         var needsCaptcha = await cache.GetAsync<bool?>(cacheKey); | ||||
|         if (needsCaptcha is not null) | ||||
|             return needsCaptcha!.Value; | ||||
|  | ||||
|         var result = Random.Next(100) < CaptchaProbabilityPercent; | ||||
|         // await cache.SetAsync(cacheKey, result, TimeSpan.FromHours(24)); | ||||
|         await cache.SetAsync(cacheKey, result, TimeSpan.FromHours(24)); | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -184,6 +184,7 @@ public class AccountService( | ||||
|  | ||||
|     public async Task RequestAccountDeletion(Shared.Models.Account account) | ||||
|     { | ||||
|         await Task.CompletedTask; | ||||
|         // var spell = await spells.CreateMagicSpell( | ||||
|         //     account, | ||||
|         //     MagicSpellType.AccountRemoval, | ||||
| @@ -196,6 +197,7 @@ public class AccountService( | ||||
|  | ||||
|     public async Task RequestPasswordReset(Shared.Models.Account account) | ||||
|     { | ||||
|         await Task.CompletedTask; | ||||
|         // var spell = await spells.CreateMagicSpell( | ||||
|         //     account, | ||||
|         //     MagicSpellType.AuthPasswordReset, | ||||
| @@ -520,6 +522,7 @@ public class AccountService( | ||||
|  | ||||
|     public async Task VerifyContactMethod(Shared.Models.Account account, AccountContact contact) | ||||
|     { | ||||
|         await Task.CompletedTask; | ||||
|         // var spell = await spells.CreateMagicSpell( | ||||
|         //     account, | ||||
|         //     MagicSpellType.ContactVerification, | ||||
|   | ||||
| @@ -66,8 +66,8 @@ public class NotificationService( | ||||
|             AccountId = account.Id, | ||||
|         }; | ||||
|  | ||||
|         // db.NotificationPushSubscriptions.Add(subscription); | ||||
|         // await db.SaveChangesAsync(); | ||||
|         db.NotificationPushSubscriptions.Add(subscription); | ||||
|         await db.SaveChangesAsync(); | ||||
|  | ||||
|         return subscription; | ||||
|     } | ||||
| @@ -107,7 +107,7 @@ public class NotificationService( | ||||
|         } | ||||
|  | ||||
|         if (!isSilent) | ||||
|             Console.WriteLine("Simulating notification delivery."); // _ = DeliveryNotification(notification); | ||||
|             _ = DeliveryNotification(notification); | ||||
|  | ||||
|         return notification; | ||||
|     } | ||||
| @@ -134,10 +134,10 @@ public class NotificationService( | ||||
|         var id = notifications.Where(n => n.ViewedAt == null).Select(n => n.Id).ToList(); | ||||
|         if (id.Count == 0) return; | ||||
|  | ||||
|         // await db.Notifications | ||||
|         //     .Where(n => id.Contains(n.Id)) | ||||
|         //     .ExecuteUpdateAsync(s => s.SetProperty(n => n.ViewedAt, now) | ||||
|         //     ); | ||||
|         await db.Notifications | ||||
|             .Where(n => id.Contains(n.Id)) | ||||
|             .ExecuteUpdateAsync(s => s.SetProperty(n => n.ViewedAt, now) | ||||
|             ); | ||||
|     } | ||||
|  | ||||
|     public async Task BroadcastNotification(Notification notification, bool save = false) | ||||
| @@ -161,7 +161,7 @@ public class NotificationService( | ||||
|                 }; | ||||
|                 return newNotification; | ||||
|             }).ToList(); | ||||
|             // await db.BulkInsertAsync(notifications); | ||||
|             await db.BulkInsertAsync(notifications); | ||||
|         } | ||||
|  | ||||
|         foreach (var account in accounts) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user