Фиксы по историям

This commit is contained in:
Халимов Рустам
2026-04-03 21:13:28 +03:00
parent 2ab5b295e8
commit a04f04a448
13 changed files with 233 additions and 171 deletions

View File

@@ -10,7 +10,7 @@ using Knot.Modules.Stories.Domain;
namespace Knot.Modules.Stories.Application.Stories.Commands.CreateStory;
public record CreateStoryCommand(Guid UserId, string Type, string? MediaUrl, string? Content, string? BgColor) : ICommand<Guid>;
public record CreateStoryCommand(Guid UserId, string Type, string? MediaUrl, string? Content, string? BgColor, bool IsMuted) : ICommand<Guid>;
internal sealed class CreateStoryCommandHandler : ICommandHandler<CreateStoryCommand, Guid>
{
@@ -27,7 +27,7 @@ internal sealed class CreateStoryCommandHandler : ICommandHandler<CreateStoryCom
{
if (!Enum.TryParse<StoryType>(request.Type, true, out var parsedType))
{
parsedType = StoryType.Text;
parsedType = StoryType.Image;
}
// Проверка Klipy
@@ -45,7 +45,8 @@ internal sealed class CreateStoryCommandHandler : ICommandHandler<CreateStoryCom
parsedType,
request.MediaUrl,
request.Content,
request.BgColor);
request.BgColor,
request.IsMuted);
await _storyRepository.AddAsync(story, cancellationToken);

View File

@@ -3,4 +3,4 @@ using System;
using Knot.Modules.Stories.Application.Abstractions;
namespace Knot.Modules.Stories.Application.DTOs;
public record CreateStoryRequest(string Type, string? MediaUrl, string? Content, string? BgColor);
public record CreateStoryRequest(string Type, string? MediaUrl, string? Content, string? BgColor, bool IsMuted);

View File

@@ -10,6 +10,7 @@ public record StoryDto(
string? MediaUrl,
string? Content,
string? BgColor,
bool IsMuted,
DateTime CreatedAt,
int ViewCount,
bool Viewed

View File

@@ -81,6 +81,7 @@ internal sealed class GetStoriesQueryHandler : IQueryHandler<GetStoriesQuery, Li
s.MediaUrl,
s.Content,
s.BgColor,
s.IsMuted,
s.CreatedAt,
s.ViewsCount,
viewedStoriesIds.Contains(s.Id)

View File

@@ -56,6 +56,7 @@ internal sealed class GetUserStoriesQueryHandler : IQueryHandler<GetUserStoriesQ
s.MediaUrl,
s.Content,
s.BgColor,
s.IsMuted,
s.CreatedAt,
s.ViewsCount,
viewedStoriesIds.Contains(s.Id)

View File

@@ -27,6 +27,7 @@ public class Story : Entity<Guid>
public string? MediaUrl { get; private set; }
public string? Content { get; private set; }
public string? BgColor { get; private set; }
public bool IsMuted { get; private set; }
public DateTime CreatedAt { get; private set; }
public int ViewsCount { get; private set; }
public List<StoryReaction> Reactions { get; private set; } = new();
@@ -34,19 +35,20 @@ public class Story : Entity<Guid>
protected Story() : base(Guid.NewGuid()) { }
internal Story(Guid id, Guid userId, StoryType type, string? mediaUrl, string? content, string? bgColor) : base(id)
internal Story(Guid id, Guid userId, StoryType type, string? mediaUrl, string? content, string? bgColor, bool isMuted) : base(id)
{
UserId = userId;
Type = type;
MediaUrl = mediaUrl;
Content = content;
BgColor = bgColor;
IsMuted = isMuted;
CreatedAt = DateTime.UtcNow;
}
public static Story Create(Guid userId, StoryType type, string? mediaUrl, string? content, string? bgColor)
public static Story Create(Guid userId, StoryType type, string? mediaUrl, string? content, string? bgColor, bool isMuted = false)
{
return new Story(Guid.NewGuid(), userId, type, mediaUrl, content, bgColor);
return new Story(Guid.NewGuid(), userId, type, mediaUrl, content, bgColor, isMuted);
}
public void IncrementViewsCount()

View File

@@ -36,7 +36,7 @@ public static class StoriesEndpoints
group.MapPost("", async ([FromBody] CreateStoryRequest request, ISender sender, IUserContext userContext, CancellationToken ct) =>
{
var result = await sender.Send(new CreateStoryCommand(userContext.UserId, request.Type, request.MediaUrl, request.Content, request.BgColor), ct);
var result = await sender.Send(new CreateStoryCommand(userContext.UserId, request.Type, request.MediaUrl, request.Content, request.BgColor, request.IsMuted), ct);
return Results.Ok(new { id = result.Value });
});