mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Media Controller Tests and other
This commit is contained in:
@@ -30,16 +30,16 @@ public class ChatsHub : Hub
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
_logger.LogWarning("User connected with invalid UserID claim.");
|
||||
Context.Abort(); // Abort connection if userID is invalid
|
||||
Context.Abort();
|
||||
return;
|
||||
}
|
||||
|
||||
// Add user to their own group (for private messages and notifications)
|
||||
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, userId.ToString());
|
||||
_logger.LogInformation("User {UserId} connected with ConnectionId {ConnectionId} and added to their group",
|
||||
userId, Context.ConnectionId);
|
||||
|
||||
var userGroups = await _userService.GetUserGroupsAsync(userId);
|
||||
|
||||
foreach (var group in userGroups)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, $"group_{group.Id}");
|
||||
@@ -51,19 +51,17 @@ public class ChatsHub : Hub
|
||||
public override async Task OnDisconnectedAsync(Exception? exception)
|
||||
{
|
||||
var userId =
|
||||
GetUserId(suppressException: true); // Suppress exception if userID is not found (e.g. connection aborted early)
|
||||
GetUserId(suppressException: true);
|
||||
if (userId != Guid.Empty)
|
||||
{
|
||||
// Remove user from their own group
|
||||
await Groups.RemoveFromGroupAsync(Context.ConnectionId, userId.ToString());
|
||||
_logger.LogInformation(
|
||||
"User {UserId} disconnected with ConnectionId {ConnectionId} and removed from their group", userId,
|
||||
Context.ConnectionId);
|
||||
_logger.LogInformation("User {UserId} disconnected with ConnectionId {ConnectionId} and removed from their group",
|
||||
userId, Context.ConnectionId);
|
||||
|
||||
var userGroups =
|
||||
await _userService
|
||||
.GetUserGroupsAsync(
|
||||
userId); // This might be problematic if the service relies on the user being connected
|
||||
userId);
|
||||
foreach (var group in userGroups)
|
||||
{
|
||||
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"group_{group.Id}");
|
||||
|
||||
@@ -33,11 +33,10 @@ public class FriendsHub : Hub
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
_logger.LogWarning("User connected with invalid UserID claim.");
|
||||
Context.Abort(); // Abort connection if userID is invalid
|
||||
Context.Abort();
|
||||
return;
|
||||
}
|
||||
|
||||
// Add user to their own group (for private messages and notifications)
|
||||
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, userId.ToString());
|
||||
_logger.LogInformation("User {UserId} connected with ConnectionId {ConnectionId} and added to their group",
|
||||
userId, Context.ConnectionId);
|
||||
@@ -48,7 +47,7 @@ public class FriendsHub : Hub
|
||||
public override async Task OnDisconnectedAsync(Exception? exception)
|
||||
{
|
||||
var userId =
|
||||
GetUserId(suppressException: true); // Suppress exception if userID is not found (e.g. connection aborted early)
|
||||
GetUserId(suppressException: true);
|
||||
if (userId != Guid.Empty)
|
||||
{
|
||||
// Remove user from their own group
|
||||
|
||||
Reference in New Issue
Block a user