mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-13 10:34:14 -04:00
* Fix signalr admin messages sending (#1809) * Changed messsage hub to use userIds * SignalR events are fixed * Fixed broken advanced tab on library settings * Fixed regex timeout security issues. * Added a migration for GMT+1 users where their UTC dates were getting broken somehow. * Removed a console.log * Fixed a migration name --------- Co-authored-by: Snd-R <76580768+Snd-R@users.noreply.github.com>
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using API.Extensions;
|
|
using API.SignalR.Presence;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace API.SignalR;
|
|
|
|
/// <summary>
|
|
/// Generic hub for sending messages to UI
|
|
/// </summary>
|
|
[Authorize]
|
|
public class MessageHub : Hub
|
|
{
|
|
private readonly IPresenceTracker _tracker;
|
|
|
|
public MessageHub(IPresenceTracker tracker)
|
|
{
|
|
_tracker = tracker;
|
|
}
|
|
|
|
public override async Task OnConnectedAsync()
|
|
{
|
|
await _tracker.UserConnected(Context.User.GetUserId(), Context.ConnectionId);
|
|
|
|
var currentUsers = await PresenceTracker.GetOnlineUsers();
|
|
await Clients.All.SendAsync(MessageFactory.OnlineUsers, currentUsers);
|
|
|
|
|
|
await base.OnConnectedAsync();
|
|
}
|
|
|
|
public override async Task OnDisconnectedAsync(Exception exception)
|
|
{
|
|
await _tracker.UserDisconnected(Context.User.GetUserId(), Context.ConnectionId);
|
|
|
|
var currentUsers = await PresenceTracker.GetOnlineUsers();
|
|
await Clients.All.SendAsync(MessageFactory.OnlineUsers, currentUsers);
|
|
|
|
|
|
await base.OnDisconnectedAsync(exception);
|
|
}
|
|
}
|
|
|