mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
565d3249e5
Introduces OnlinePingingController and related integration/unit tests for user online status updates. Adds PingHandlerService with memory cache throttling, IPingHandlerService interface, and service registration. Implements VerifyFriendship service and interface for friendship validation, with exception handling. Refactors CurrentUserService for improved user ID extraction and testability. Updates ChatsHub to verify friendship before messaging. Cleans up MediaController and optimizes UsersRepository queries by removing unnecessary includes.
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using Govor.Application.Interfaces;
|
|
using Govor.Contracts.Requests;
|
|
using Govor.Core.Models;
|
|
using Govor.Core.Repositories.MediasAttachments;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Govor.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/media")]
|
|
[Authorize(Roles = "User,Admin")]
|
|
public class MediaController : Controller
|
|
{
|
|
private readonly ILogger<MediaController> _logger;
|
|
private readonly IStorageService _storageService;
|
|
|
|
public MediaController(ILogger<MediaController> logger, IStorageService storageService)
|
|
{
|
|
_logger = logger;
|
|
_storageService = storageService;
|
|
}
|
|
|
|
[HttpPost("upload")]
|
|
[RequestSizeLimit(100_000_000)]// ~100MB
|
|
public async Task<IActionResult> Upload([FromForm] MediaUploadRequest request)
|
|
{
|
|
try
|
|
{
|
|
var url = await _storageService.SaveAsync(request.Data,request.FileName);
|
|
var mediaId = Guid.NewGuid();
|
|
|
|
|
|
return Ok(mediaId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, ex);
|
|
}
|
|
}
|
|
} |