merge
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.TaskChat.Commands.DeleteMessage;
|
||||
@@ -9,16 +10,18 @@ public record DeleteMessageCommand(Guid MessageId) : IBaseCommand;
|
||||
public class DeleteMessageCommandHandler : IBaseCommandHandler<DeleteMessageCommand>
|
||||
{
|
||||
private readonly ITaskChatMessageRepository _repository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public DeleteMessageCommandHandler(ITaskChatMessageRepository repository)
|
||||
public DeleteMessageCommandHandler(ITaskChatMessageRepository repository, IAuthHelper authHelper)
|
||||
{
|
||||
_repository = repository;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(DeleteMessageCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
// TODO: Get current user
|
||||
var currentUserId = 1L;
|
||||
var currentUserId = _authHelper.GetCurrentUserId()??
|
||||
throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||
|
||||
var message = await _repository.GetByIdAsync(request.MessageId);
|
||||
if (message == null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
||||
using MediatR;
|
||||
|
||||
@@ -13,16 +14,18 @@ public record EditMessageCommand(
|
||||
public class EditMessageCommandHandler : IBaseCommandHandler<EditMessageCommand>
|
||||
{
|
||||
private readonly ITaskChatMessageRepository _repository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public EditMessageCommandHandler(ITaskChatMessageRepository repository)
|
||||
public EditMessageCommandHandler(ITaskChatMessageRepository repository, IAuthHelper authHelper)
|
||||
{
|
||||
_repository = repository;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(EditMessageCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
// TODO: Get current user
|
||||
var currentUserId = 1L;
|
||||
var currentUserId = _authHelper.GetCurrentUserId()??
|
||||
throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||
|
||||
var message = await _repository.GetByIdAsync(request.MessageId);
|
||||
if (message == null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
||||
using MediatR;
|
||||
|
||||
@@ -10,16 +11,18 @@ public record PinMessageCommand(Guid MessageId) : IBaseCommand;
|
||||
public class PinMessageCommandHandler : IBaseCommandHandler<PinMessageCommand>
|
||||
{
|
||||
private readonly ITaskChatMessageRepository _repository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public PinMessageCommandHandler(ITaskChatMessageRepository repository)
|
||||
public PinMessageCommandHandler(ITaskChatMessageRepository repository, IAuthHelper authHelper)
|
||||
{
|
||||
_repository = repository;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(PinMessageCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
// TODO: Get current user
|
||||
var currentUserId = 1L;
|
||||
var currentUserId = _authHelper.GetCurrentUserId()??
|
||||
throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||
|
||||
var message = await _repository.GetByIdAsync(request.MessageId);
|
||||
if (message == null)
|
||||
|
||||
@@ -2,6 +2,7 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
||||
using GozareshgirProgramManager.Application.Services.FileManagement;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Entities;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
|
||||
@@ -29,24 +30,27 @@ public class SendMessageCommandHandler : IBaseCommandHandler<SendMessageCommand,
|
||||
private readonly IProjectTaskRepository _taskRepository;
|
||||
private readonly IFileStorageService _fileStorageService;
|
||||
private readonly IThumbnailGeneratorService _thumbnailService;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public SendMessageCommandHandler(
|
||||
ITaskChatMessageRepository messageRepository,
|
||||
IUploadedFileRepository fileRepository,
|
||||
IProjectTaskRepository taskRepository,
|
||||
IFileStorageService fileStorageService,
|
||||
IThumbnailGeneratorService thumbnailService)
|
||||
IThumbnailGeneratorService thumbnailService, IAuthHelper authHelper)
|
||||
{
|
||||
_messageRepository = messageRepository;
|
||||
_fileRepository = fileRepository;
|
||||
_taskRepository = taskRepository;
|
||||
_fileStorageService = fileStorageService;
|
||||
_thumbnailService = thumbnailService;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<MessageDto>> Handle(SendMessageCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentUserId = 1L;
|
||||
var currentUserId = _authHelper.GetCurrentUserId()
|
||||
?? throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||
|
||||
var task = await _taskRepository.GetByIdAsync(request.TaskId, cancellationToken);
|
||||
if (task == null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
||||
using MediatR;
|
||||
|
||||
@@ -10,16 +11,18 @@ public record UnpinMessageCommand(Guid MessageId) : IBaseCommand;
|
||||
public class UnpinMessageCommandHandler : IBaseCommandHandler<UnpinMessageCommand>
|
||||
{
|
||||
private readonly ITaskChatMessageRepository _repository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public UnpinMessageCommandHandler(ITaskChatMessageRepository repository)
|
||||
public UnpinMessageCommandHandler(ITaskChatMessageRepository repository, IAuthHelper authHelper)
|
||||
{
|
||||
_repository = repository;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Handle(UnpinMessageCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
// TODO: Get current user
|
||||
var currentUserId = 1L;
|
||||
var currentUserId = _authHelper.GetCurrentUserId()??
|
||||
throw new UnAuthorizedException("کاربر احراز هویت نشده است");
|
||||
|
||||
var message = await _repository.GetByIdAsync(request.MessageId);
|
||||
if (message == null)
|
||||
|
||||
Reference in New Issue
Block a user