mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
client
This commit is contained in:
@@ -21,7 +21,7 @@ public class FriendsController : Controller
|
||||
_friendsService = friendsService;
|
||||
}
|
||||
|
||||
[HttpGet("search")]
|
||||
[HttpGet("search")] //api/friends/search
|
||||
public async Task<IActionResult> Search(string query)
|
||||
{
|
||||
try
|
||||
@@ -37,7 +37,7 @@ public class FriendsController : Controller
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("request")]
|
||||
[HttpPost("request")] //api/friends/request
|
||||
public async Task<IActionResult> SendRequest(Guid targetUserId)
|
||||
{
|
||||
try
|
||||
@@ -62,7 +62,7 @@ public class FriendsController : Controller
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("requests")]
|
||||
[HttpGet("requests")] //api/friends/requests
|
||||
public async Task<IActionResult> GetIncomingRequests()
|
||||
{
|
||||
try
|
||||
@@ -78,7 +78,7 @@ public class FriendsController : Controller
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("accept")]
|
||||
[HttpPost("accept")] //api/friends/accept
|
||||
public async Task<IActionResult> AcceptFriend(Guid requesterId)
|
||||
{
|
||||
try
|
||||
@@ -98,7 +98,7 @@ public class FriendsController : Controller
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HttpGet] //api/friends/
|
||||
public async Task<IActionResult> GetFriends()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -58,11 +58,6 @@ public class ChatsHub : Hub
|
||||
}
|
||||
|
||||
var senderId = GetUserId();
|
||||
if (senderId == Guid.Empty)
|
||||
{
|
||||
_logger.LogError("Could not retrieve sender userId");
|
||||
throw new InvalidOperationException("User not authenticated");
|
||||
}
|
||||
|
||||
// Проверка существования получателя
|
||||
try
|
||||
@@ -100,6 +95,7 @@ public class ChatsHub : Hub
|
||||
var userIdClaim = Context.User?.FindFirst("userID")?.Value;
|
||||
if (string.IsNullOrEmpty(userIdClaim) || !Guid.TryParse(userIdClaim, out var userId))
|
||||
{
|
||||
_logger.LogError("Could not retrieve sender userId");
|
||||
throw new UnauthorizedAccessException("userID claim is missing or invalid");
|
||||
}
|
||||
return userId;
|
||||
|
||||
@@ -59,6 +59,11 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
builder.Services.AddAuthorization();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddControllers()
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.Preserve;
|
||||
});
|
||||
|
||||
// Init DI
|
||||
builder.Services.AddServices();
|
||||
|
||||
Reference in New Issue
Block a user