too many changes
This commit is contained in:
@@ -4,6 +4,8 @@ using MemeVault.Application.Commands.CreateCollection;
|
||||
using MemeVault.Application.Commands.CreateCollectionInvite;
|
||||
using MemeVault.Application.Commands.DeleteCollection;
|
||||
using MemeVault.Application.Commands.RevokeCollectionInvite;
|
||||
using MemeVault.Application.Commands.SetCollectionInbox;
|
||||
using MemeVault.Application.Commands.SetCollectionNsfw;
|
||||
using MemeVault.Application.Commands.ShareCollection;
|
||||
using MemeVault.Application.Commands.UpdateCollection;
|
||||
using MemeVault.Application.Queries.GetCollectionInvites;
|
||||
@@ -96,7 +98,7 @@ public sealed class CollectionsController(IMediator mediator, CurrentUser curren
|
||||
CancellationToken ct)
|
||||
{
|
||||
var token = await mediator.Send(
|
||||
new CreateCollectionInviteCommand(id, currentUser.TelegramId, request.Role), ct);
|
||||
new CreateCollectionInviteCommand(id, currentUser.TelegramId, request.Role, request.ExpiresAt), ct);
|
||||
return token is null ? NotFound() : Ok(new { token });
|
||||
}
|
||||
|
||||
@@ -109,6 +111,28 @@ public sealed class CollectionsController(IMediator mediator, CurrentUser curren
|
||||
return ok ? NoContent() : NotFound();
|
||||
}
|
||||
|
||||
// PUT /api/collections/{id}/inbox
|
||||
[HttpPut("{id:guid}/inbox")]
|
||||
public async Task<IActionResult> SetInbox(Guid id, CancellationToken ct)
|
||||
{
|
||||
var ok = await mediator.Send(new SetCollectionInboxCommand(id, currentUser.TelegramId), ct);
|
||||
return ok ? NoContent() : NotFound();
|
||||
}
|
||||
|
||||
// PUT /api/collections/{id}/nsfw
|
||||
[HttpPut("{id:guid}/nsfw")]
|
||||
public async Task<IActionResult> SetNsfw(
|
||||
Guid id,
|
||||
[FromBody] SetNsfwRequest request,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var ok = await mediator.Send(
|
||||
new SetCollectionNsfwCommand(id, currentUser.TelegramId, request.IsNsfw),
|
||||
ct);
|
||||
|
||||
return ok ? NoContent() : NotFound();
|
||||
}
|
||||
|
||||
// PUT /api/collections/{id}/visibility
|
||||
[HttpPut("{id:guid}/visibility")]
|
||||
public async Task<IActionResult> SetVisibility(
|
||||
@@ -126,5 +150,6 @@ public sealed class CollectionsController(IMediator mediator, CurrentUser curren
|
||||
|
||||
public sealed record CreateCollectionRequest(string Name, string? Description);
|
||||
public sealed record UpdateCollectionRequest(string Name, string? Description);
|
||||
public sealed record SetNsfwRequest(bool IsNsfw);
|
||||
public sealed record SetVisibilityRequest(CollectionVisibility Visibility);
|
||||
public sealed record CreateInviteRequest(CollectionRole Role);
|
||||
public sealed record CreateInviteRequest(CollectionRole Role, DateTimeOffset? ExpiresAt = null);
|
||||
|
||||
@@ -3,6 +3,8 @@ using MemeVault.Api.Auth;
|
||||
using MemeVault.Application.Commands.CopyMediaToCollection;
|
||||
using MemeVault.Application.Commands.DeleteMedia;
|
||||
using MemeVault.Application.Commands.UpdateMedia;
|
||||
using MemeVault.Application.Commands.SendMediaToChat;
|
||||
using MemeVault.Application.Queries.GetMediaDownloadUrl;
|
||||
using MemeVault.Application.Queries.GetUserMedia;
|
||||
using MemeVault.Application.Queries.SearchMedia;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -15,17 +17,45 @@ namespace MemeVault.Api.Controllers;
|
||||
[Route("api/[controller]")]
|
||||
public sealed class MediaController(IMediator mediator, CurrentUser currentUser) : ControllerBase
|
||||
{
|
||||
// GET /api/media?q=...
|
||||
// GET /api/media?q=...&includeNsfw=true
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll([FromQuery] string? q, CancellationToken ct)
|
||||
public async Task<IActionResult> GetAll(
|
||||
[FromQuery] string? q,
|
||||
[FromQuery] bool includeNsfw = true,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var items = string.IsNullOrWhiteSpace(q)
|
||||
? await mediator.Send(new GetUserMediaQuery(currentUser.TelegramId), ct)
|
||||
: await mediator.Send(new SearchMediaQuery(currentUser.TelegramId, q), ct);
|
||||
: await mediator.Send(new SearchMediaQuery(currentUser.TelegramId, q, IncludeNsfw: includeNsfw), ct);
|
||||
|
||||
return Ok(items);
|
||||
}
|
||||
|
||||
// GET /api/media/{id}/download-url
|
||||
// Returns a short-lived pre-signed URL for displaying the media file.
|
||||
[HttpGet("{id:guid}/download-url")]
|
||||
public async Task<IActionResult> GetDownloadUrl(Guid id, CancellationToken ct)
|
||||
{
|
||||
var url = await mediator.Send(
|
||||
new GetMediaDownloadUrlQuery(id, currentUser.TelegramId), ct);
|
||||
|
||||
return Ok(new { url });
|
||||
}
|
||||
|
||||
// POST /api/media/{id}/send
|
||||
// Отправляет элемент в Telegram-чат через answerWebAppQuery (режим аттачмента).
|
||||
[HttpPost("{id:guid}/send")]
|
||||
public async Task<IActionResult> SendToChat(
|
||||
Guid id,
|
||||
[FromBody] SendToChatRequest request,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var ok = await mediator.Send(
|
||||
new SendMediaToChatCommand(id, currentUser.TelegramId, request.QueryId), ct);
|
||||
|
||||
return ok ? NoContent() : NotFound();
|
||||
}
|
||||
|
||||
// PATCH /api/media/{id}
|
||||
// Обновляет caption, теги и/или перемещает в другую коллекцию
|
||||
[HttpPatch("{id:guid}")]
|
||||
@@ -67,6 +97,8 @@ public sealed class MediaController(IMediator mediator, CurrentUser currentUser)
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record SendToChatRequest(string QueryId);
|
||||
|
||||
public sealed record UpdateMediaRequest(
|
||||
string? Caption,
|
||||
IReadOnlyList<string> Tags,
|
||||
|
||||
@@ -38,8 +38,8 @@ builder.Services
|
||||
{
|
||||
o.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateIssuer = false,
|
||||
ValidateAudience = false,
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = jwtOpts.Issuer,
|
||||
@@ -53,7 +53,10 @@ builder.Services
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddExceptionHandler<DomainExceptionHandler>();
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddControllers()
|
||||
.AddJsonOptions(o =>
|
||||
o.JsonSerializerOptions.Converters.Add(
|
||||
new System.Text.Json.Serialization.JsonStringEnumConverter()));
|
||||
|
||||
// ── OpenAPI ───────────────────────────────────────────────────────────────────
|
||||
builder.Services.AddHealthChecks()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"Telegram": {
|
||||
"BotToken": ""
|
||||
"BotToken": "",
|
||||
"ApiBaseUrl": "https://api.telegram.org"
|
||||
},
|
||||
"Jwt": {
|
||||
"SecretKey": "",
|
||||
@@ -8,6 +9,13 @@
|
||||
"Audience": "memevault-miniapp",
|
||||
"ExpiryHours": 24
|
||||
},
|
||||
"S3": {
|
||||
"ServiceUrl": "http://minio:9000",
|
||||
"AccessKey": "memevault",
|
||||
"SecretKey": "changeme123",
|
||||
"BucketName": "memevault",
|
||||
"PublicUrl": "http://localhost:9000"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Postgres": "Host=localhost;Database=memevault;Username=memevault;Password=changeme",
|
||||
"Redis": "localhost:6379"
|
||||
|
||||
Reference in New Issue
Block a user