diff --git a/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs b/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs index 27d842c3e1..d9c32143ce 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs @@ -11,8 +11,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Utils.SignalR { /// @@ -46,7 +44,7 @@ namespace Tgstation.Server.Host.Utils.SignalR readonly ConcurrentDictionary> userConnections; /// - public event Func, Task>, CancellationToken, ValueTask> OnConnectionMapGroups; + public event Func, Task>, CancellationToken, ValueTask>? OnConnectionMapGroups; /// /// Initializes a new instance of the class. @@ -67,7 +65,7 @@ namespace Tgstation.Server.Host.Utils.SignalR public List UserConnectionIds(User user) { ArgumentNullException.ThrowIfNull(user); - var connectionIds = userConnections.GetOrAdd(user.Id.Value, _ => new Dictionary()); + var connectionIds = userConnections.GetOrAdd(user.Require(x => x.Id), _ => new Dictionary()); lock (connectionIds) return connectionIds.Keys.ToList(); } @@ -78,7 +76,7 @@ namespace Tgstation.Server.Host.Utils.SignalR ArgumentNullException.ThrowIfNull(authenticationContext); ArgumentNullException.ThrowIfNull(hub); - var userId = authenticationContext.User.Id.Value; + var userId = authenticationContext.User.Require(x => x.Id); var context = hub.Context; logger.LogTrace( "Mapping user {userId} to hub connection ID: {connectionId}", @@ -131,11 +129,12 @@ namespace Tgstation.Server.Host.Utils.SignalR public void AbortUnauthedConnections(User user) { ArgumentNullException.ThrowIfNull(user); - logger.LogTrace("NotifyAndAbortUnauthedConnections. UID {userId}", user.Id.Value); + var uid = user.Require(x => x.Id); + logger.LogTrace("NotifyAndAbortUnauthedConnections. UID {userId}", uid); - List connections = null; + List? connections = null; userConnections.AddOrUpdate( - user.Id.Value, + uid, _ => new Dictionary(), (_, old) => { @@ -148,7 +147,7 @@ namespace Tgstation.Server.Host.Utils.SignalR return old; }); - foreach (var context in connections) + foreach (var context in connections!) context.Abort(); } }