Фиксы по историям
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -10,6 +10,7 @@ public record StoryDto(
|
||||
string? MediaUrl,
|
||||
string? Content,
|
||||
string? BgColor,
|
||||
bool IsMuted,
|
||||
DateTime CreatedAt,
|
||||
int ViewCount,
|
||||
bool Viewed
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user