added methods to update vanity colors and submodule bump

This commit is contained in:
azyges
2025-09-26 18:53:47 +09:00
parent f5d621e354
commit 2b05223a4b
3 changed files with 117 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ using LightlessSync.API.Data;
using LightlessSync.API.Dto.Group;
using LightlessSyncShared.Metrics;
using Microsoft.AspNetCore.SignalR;
using System.Threading;
namespace LightlessSyncServer.Hubs;
@@ -97,6 +98,28 @@ public partial class LightlessHub
await _redis.RemoveAsync("UID:" + UserUID, StackExchange.Redis.CommandFlags.FireAndForget).ConfigureAwait(false);
}
private async Task<User?> EnsureUserHasVanity(string uid, CancellationToken cancellationToken = default)
{
cancellationToken = cancellationToken == default && _contextAccessor.HttpContext != null
? _contextAccessor.HttpContext.RequestAborted
: cancellationToken;
var user = await DbContext.Users.SingleOrDefaultAsync(u => u.UID == uid, cancellationToken).ConfigureAwait(false);
if (user == null)
{
_logger.LogCallWarning(LightlessHubLogger.Args("vanity check", uid, "missing user"));
return null;
}
if (user.HasVanity != true)
{
_logger.LogCallWarning(LightlessHubLogger.Args("vanity check", uid, "no vanity"));
return null;
}
return user;
}
private async Task SendGroupDeletedToAll(List<GroupPair> groupUsers)
{
foreach (var pair in groupUsers)