diff --git a/Govor.API.Tests/Govor.API.Tests.csproj b/Govor.API.Tests/Govor.API.Tests.csproj index 541926b..2ef9646 100644 --- a/Govor.API.Tests/Govor.API.Tests.csproj +++ b/Govor.API.Tests/Govor.API.Tests.csproj @@ -27,5 +27,4 @@ - diff --git a/Govor.API.Tests/IntegrationTests/Hubs/ChatsHubTests.cs b/Govor.API.Tests/IntegrationTests/Hubs/ChatsHubTests.cs index 01d0682..8b4264c 100644 --- a/Govor.API.Tests/IntegrationTests/Hubs/ChatsHubTests.cs +++ b/Govor.API.Tests/IntegrationTests/Hubs/ChatsHubTests.cs @@ -11,7 +11,7 @@ namespace Govor.API.Tests.IntegrationTests.Hubs; public class ChatsHubTests { private Mock> _loggerMock; - private Mock _messageServiceMock; + private Mock _messageServiceMock; private Mock _userGroupsServiceMock; private Fixture _fixture; private ChatsHub _chatsHub; @@ -23,7 +23,7 @@ public class ChatsHubTests _fixture.Behaviors.OfType().ToList().ForEach(b => _fixture.Behaviors.Remove(b)); _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); - _messageServiceMock = new Mock(); + _messageServiceMock = new Mock(); _userGroupsServiceMock = new Mock(); _loggerMock = new Mock>(); diff --git a/Govor.API.Tests/UnitTests/Services/LocalStorageServiceTests.cs b/Govor.API.Tests/LocalStorageServiceTests.cs similarity index 98% rename from Govor.API.Tests/UnitTests/Services/LocalStorageServiceTests.cs rename to Govor.API.Tests/LocalStorageServiceTests.cs index c80da0a..aff7ac8 100644 --- a/Govor.API.Tests/UnitTests/Services/LocalStorageServiceTests.cs +++ b/Govor.API.Tests/LocalStorageServiceTests.cs @@ -4,7 +4,7 @@ using Govor.Application.Services; using Microsoft.AspNetCore.Hosting; using Moq; -namespace Govor.API.Tests.UnitTests.Services; +namespace Govor.Application.Tests.Services; [TestFixture] public class LocalStorageServiceTests diff --git a/Govor.API/Controllers/Friends/FriendsRequestQueryController.cs b/Govor.API/Controllers/Friends/FriendsRequestQueryController.cs index 0863894..d01c507 100644 --- a/Govor.API/Controllers/Friends/FriendsRequestQueryController.cs +++ b/Govor.API/Controllers/Friends/FriendsRequestQueryController.cs @@ -1,3 +1,5 @@ +using Govor.Application.Interfaces.Friends; +using Govor.Application.Interfaces.Infrastructure.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -8,5 +10,18 @@ namespace Govor.API.Controllers.Friends; [Route("api/friends")] public class FriendsRequestQueryController : Controller { + private readonly ILogger _logger; + private readonly IFriendRequestQueryService _friendsService; + private readonly ICurrentUserService _currentUserService; + + public FriendsRequestQueryController(ILogger logger, + IFriendRequestQueryService friendsService, + ICurrentUserService currentUserService) + { + _logger = logger; + _friendsService = friendsService; + _currentUserService = currentUserService; + } + } \ No newline at end of file diff --git a/Govor.API/Controllers/Friends/FriendshipController.cs b/Govor.API/Controllers/Friends/FriendshipController.cs index fbfe156..8daf319 100644 --- a/Govor.API/Controllers/Friends/FriendshipController.cs +++ b/Govor.API/Controllers/Friends/FriendshipController.cs @@ -1,6 +1,59 @@ +using Govor.Application.Exceptions.FriendsService; +using Govor.Application.Interfaces.Friends; +using Govor.Application.Interfaces.Infrastructure.Extensions; +using Govor.Contracts.DTOs; +using Govor.Core.Models; +using Microsoft.AspNetCore.Mvc; + namespace Govor.API.Controllers.Friends; -public class FriendshipController +[Route("api/friends")] +public class FriendshipController : Controller { + private readonly ILogger _logger; + private readonly IFriendshipService _friendsService; + //private readonly IUserDtoBuilder _builder; + private readonly ICurrentUserService _currentUserService; + + public FriendshipController(ILogger logger, + IFriendshipService friendsService, + ICurrentUserService currentUserService) + { + _logger = logger; + _friendsService = friendsService; + _currentUserService = currentUserService; + } + [HttpGet("search")] // api/friends/search?query= + public async Task Search(string query) + { + if (string.IsNullOrWhiteSpace(query)) + return BadRequest("Query cannot be empty"); + + try + { + var result = await _friendsService.SearchUsersAsync(query, _currentUserService.GetCurrentUserId()); + return Ok(BuildUserDtos(result)); + } + catch (SearchUsersException ex) + { + _logger.LogWarning(ex, ex.Message); + return NotFound(new { error = ex.Message }); + } + catch (Exception ex) + { + _logger.LogError(ex, ex.Message); + return StatusCode(500, new { error = "Internal error during user search." }); + } + } + + private List BuildUserDtos(IEnumerable users) => users.Select(user => new UserDto + { + Id = user.Id, + Username = user.Username, + Description = user.Description, + WasOnline = user.WasOnline, + IconId = user.IconId + }).ToList(); + } \ No newline at end of file diff --git a/Govor.API/Extensions/ConfigurationProgramExtensions.cs b/Govor.API/Extensions/ConfigurationProgramExtensions.cs index 88ec6d8..f85954e 100644 --- a/Govor.API/Extensions/ConfigurationProgramExtensions.cs +++ b/Govor.API/Extensions/ConfigurationProgramExtensions.cs @@ -1,5 +1,6 @@ using Govor.API.Services.AdminsStuff.Interfaces; using Govor.API.Services.Authentication.Interfaces; +using Govor.Application.Infrastructure.AdminsStuff; using Govor.Application.Infrastructure.Extensions; using Govor.Application.Infrastructure.Validators; using Govor.Application.Interfaces; @@ -9,7 +10,9 @@ using Govor.Application.Interfaces.Friends; using Govor.Application.Interfaces.Infrastructure.Extensions; using Govor.Application.Interfaces.Messages; using Govor.Application.Services; +using Govor.Application.Services.Authentication; using Govor.Application.Services.Friends; +using Govor.Application.Services.Messages; using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; @@ -57,7 +60,7 @@ public static class ConfigurationProgramExtensions services.AddMemoryCache(); services.AddScoped(); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/Govor.API/Hubs/ChatsHub.cs b/Govor.API/Hubs/ChatsHub.cs index f8e380b..f0f509c 100644 --- a/Govor.API/Hubs/ChatsHub.cs +++ b/Govor.API/Hubs/ChatsHub.cs @@ -14,13 +14,13 @@ namespace Govor.API.Hubs; public class ChatsHub : Hub { private readonly ILogger _logger; - private readonly IMessageService _messageService; + private readonly IMessageCommandService _messageCommandService; private readonly IUserGroupsService _userService; - public ChatsHub(ILogger logger, IMessageService messageService, IUserGroupsService userService) + public ChatsHub(ILogger logger, IMessageCommandService messageCommandService, IUserGroupsService userService) { _logger = logger; - _messageService = messageService; + _messageCommandService = messageCommandService; _userService = userService; } @@ -105,7 +105,7 @@ public class ChatsHub : Hub Media: request.MediaAttachments?.Select(f => new SendMedia(f.MediaId, f.EncryptedKey)) ?? Array.Empty()); - var result = await _messageService.SendMessageAsync(sendMessageParams); + var result = await _messageCommandService.SendMessageAsync(sendMessageParams); if (!result.IsSuccess || result.Message.Id == Guid.Empty) { diff --git a/Govor.API/Program.cs b/Govor.API/Program.cs index 18cf04a..fd3e0ac 100644 --- a/Govor.API/Program.cs +++ b/Govor.API/Program.cs @@ -1,7 +1,7 @@ using System.Text; using Govor.API.Extensions; using Govor.API.Hubs; -using Govor.Application.Services; +using Govor.Application.Services.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi.Models; @@ -19,7 +19,7 @@ builder.Services.AddCors(options => { options.AddPolicy("AllowFrontend", policy => { - policy.WithOrigins("http://localhost:5000", "https://5.129.212.144:5000") // Укажите ваш публичный IP + policy.WithOrigins("http://localhost:5000", "https://5.129.212.144:5000") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); diff --git a/Govor.Application.Tests/Govor.Application.Tests.csproj b/Govor.Application.Tests/Govor.Application.Tests.csproj new file mode 100644 index 0000000..cdd654f --- /dev/null +++ b/Govor.Application.Tests/Govor.Application.Tests.csproj @@ -0,0 +1,33 @@ + + + + net8.0 + latest + enable + enable + false + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Govor.API.Tests/UnitTests/Services/AdminStuff/InvitationGeneratorTests.cs b/Govor.Application.Tests/Infrastructure/AdminsStuff/InvitationGeneratorTests.cs similarity index 96% rename from Govor.API.Tests/UnitTests/Services/AdminStuff/InvitationGeneratorTests.cs rename to Govor.Application.Tests/Infrastructure/AdminsStuff/InvitationGeneratorTests.cs index 98c50a1..4ad9d52 100644 --- a/Govor.API.Tests/UnitTests/Services/AdminStuff/InvitationGeneratorTests.cs +++ b/Govor.Application.Tests/Infrastructure/AdminsStuff/InvitationGeneratorTests.cs @@ -1,11 +1,11 @@ using AutoFixture; using Govor.API.Services.AdminsStuff.Interfaces; -using Govor.Application.Interfaces.AdminsStuff; +using Govor.Application.Infrastructure.AdminsStuff; using Govor.Core.Models; using Govor.Core.Repositories.Invaites; using Moq; -namespace Govor.API.Tests.UnitTests.Services.AdminStuff; +namespace Govor.Application.Tests.Infrastructure.AdminsStuff; [TestFixture] public class InvitationGeneratorTests diff --git a/Govor.API.Tests/UnitTests/Services/CurrentUserServiceTests.cs b/Govor.Application.Tests/Infrastructure/Extensions/CurrentUserServiceTests.cs similarity index 98% rename from Govor.API.Tests/UnitTests/Services/CurrentUserServiceTests.cs rename to Govor.Application.Tests/Infrastructure/Extensions/CurrentUserServiceTests.cs index 352339e..69b8fbc 100644 --- a/Govor.API.Tests/UnitTests/Services/CurrentUserServiceTests.cs +++ b/Govor.Application.Tests/Infrastructure/Extensions/CurrentUserServiceTests.cs @@ -3,7 +3,7 @@ using Govor.Application.Infrastructure.Extensions; using Microsoft.AspNetCore.Http; using Moq; -namespace Govor.API.Tests.UnitTests.Services; +namespace Govor.Application.Tests.Infrastructure.Extensions; [TestFixture] public class CurrentUserServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/Authentication/AuthServiceTests.cs b/Govor.Application.Tests/Services/Authentication/AuthServiceTests.cs similarity index 97% rename from Govor.API.Tests/UnitTests/Services/Authentication/AuthServiceTests.cs rename to Govor.Application.Tests/Services/Authentication/AuthServiceTests.cs index 3abea94..389be9a 100644 --- a/Govor.API.Tests/UnitTests/Services/Authentication/AuthServiceTests.cs +++ b/Govor.Application.Tests/Services/Authentication/AuthServiceTests.cs @@ -6,10 +6,11 @@ using Govor.API.Services.Authentication.Interfaces; using Govor.Application.Exceptions.AuthService; using Govor.Application.Interfaces.Authentication; using Govor.Application.Services; +using Govor.Application.Services.Authentication; using Govor.Core.Repositories.Admins; using Moq; -namespace Govor.API.Tests.UnitTests.Services.Authentication; +namespace Govor.Application.Tests.Services.Authentication; [TestFixture] public class AuthServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/Authentication/JwtServiceTests.cs b/Govor.Application.Tests/Services/Authentication/JwtServiceTests.cs similarity index 94% rename from Govor.API.Tests/UnitTests/Services/Authentication/JwtServiceTests.cs rename to Govor.Application.Tests/Services/Authentication/JwtServiceTests.cs index 9e4acb8..3fa1585 100644 --- a/Govor.API.Tests/UnitTests/Services/Authentication/JwtServiceTests.cs +++ b/Govor.Application.Tests/Services/Authentication/JwtServiceTests.cs @@ -2,11 +2,12 @@ using System.IdentityModel.Tokens.Jwt; using AutoFixture; using Govor.API.Services.Authentication.Interfaces; using Govor.Application.Services; +using Govor.Application.Services.Authentication; using Govor.Core.Models; using Microsoft.Extensions.Options; using Moq; -namespace Govor.API.Tests.UnitTests.Services.Authentication; +namespace Govor.Application.Tests.Services.Authentication; [TestFixture] public class JwtServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/Friends/FriendRequestCommandServiceTests.cs b/Govor.Application.Tests/Services/Friends/FriendRequestCommandServiceTests.cs similarity index 99% rename from Govor.API.Tests/UnitTests/Services/Friends/FriendRequestCommandServiceTests.cs rename to Govor.Application.Tests/Services/Friends/FriendRequestCommandServiceTests.cs index 2b2baa3..2cfd781 100644 --- a/Govor.API.Tests/UnitTests/Services/Friends/FriendRequestCommandServiceTests.cs +++ b/Govor.Application.Tests/Services/Friends/FriendRequestCommandServiceTests.cs @@ -8,7 +8,7 @@ using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; using Moq; -namespace Govor.API.Tests.UnitTests.Services.Friends; +namespace Govor.Application.Tests.Services.Friends; [TestFixture] public class FriendRequestCommandServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/Friends/FriendRequestQueryServiceTests.cs b/Govor.Application.Tests/Services/Friends/FriendRequestQueryServiceTests.cs similarity index 98% rename from Govor.API.Tests/UnitTests/Services/Friends/FriendRequestQueryServiceTests.cs rename to Govor.Application.Tests/Services/Friends/FriendRequestQueryServiceTests.cs index 7870a5b..3cade62 100644 --- a/Govor.API.Tests/UnitTests/Services/Friends/FriendRequestQueryServiceTests.cs +++ b/Govor.Application.Tests/Services/Friends/FriendRequestQueryServiceTests.cs @@ -7,7 +7,7 @@ using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; using Moq; -namespace Govor.API.Tests.UnitTests.Services.Friends; +namespace Govor.Application.Tests.Services.Friends; [TestFixture] public class FriendRequestQueryServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/Friends/FriendshipServiceTests.cs b/Govor.Application.Tests/Services/Friends/FriendshipServiceTests.cs similarity index 99% rename from Govor.API.Tests/UnitTests/Services/Friends/FriendshipServiceTests.cs rename to Govor.Application.Tests/Services/Friends/FriendshipServiceTests.cs index abb9205..6a11e56 100644 --- a/Govor.API.Tests/UnitTests/Services/Friends/FriendshipServiceTests.cs +++ b/Govor.Application.Tests/Services/Friends/FriendshipServiceTests.cs @@ -8,7 +8,7 @@ using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; using Moq; -namespace Govor.API.Tests.UnitTests.Services.Friends; +namespace Govor.Application.Tests.Services.Friends; [TestFixture] public class FriendshipServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/MessageServiceTests.cs b/Govor.Application.Tests/Services/Messages/MessageCommandServiceTests.cs similarity index 96% rename from Govor.API.Tests/UnitTests/Services/MessageServiceTests.cs rename to Govor.Application.Tests/Services/Messages/MessageCommandServiceTests.cs index d415335..f5abc7b 100644 --- a/Govor.API.Tests/UnitTests/Services/MessageServiceTests.cs +++ b/Govor.Application.Tests/Services/Messages/MessageCommandServiceTests.cs @@ -1,7 +1,7 @@ using Govor.Application.Exceptions.VerifyFriendship; using Govor.Application.Interfaces; using Govor.Application.Interfaces.Messages.Parameters; -using Govor.Application.Services; +using Govor.Application.Services.Messages; using Govor.Core.Models; using Govor.Core.Repositories.Groups; using Govor.Core.Repositories.Messages; @@ -11,18 +11,18 @@ using Govor.Data.Repositories.Exceptions; using Microsoft.Extensions.Logging; using Moq; -namespace Govor.API.Tests.UnitTests.Services; +namespace Govor.Application.Tests.Services.Messages; [TestFixture] -public class MessageServiceTests +public class MessageCommandServiceTests { private Mock _mockMessagesRepo; private Mock _mockUsersRepo; private Mock _mockGroupsRepo; private Mock _mockVerifyFriendship; private Mock _mockPrivateChats; - private Mock> _mockLogger; - private MessageService _messageService; + private Mock> _mockLogger; + private MessageCommandService _messageService; [SetUp] public void SetUp() @@ -32,9 +32,9 @@ public class MessageServiceTests _mockGroupsRepo = new Mock(); _mockVerifyFriendship = new Mock(); _mockPrivateChats = new Mock(); - _mockLogger = new Mock>(); + _mockLogger = new Mock>(); - _messageService = new MessageService( + _messageService = new MessageCommandService( _mockMessagesRepo.Object, _mockUsersRepo.Object, _mockGroupsRepo.Object, diff --git a/Govor.API.Tests/UnitTests/Services/PasswordHasherTests.cs b/Govor.Application.Tests/Services/PasswordHasherTests.cs similarity index 92% rename from Govor.API.Tests/UnitTests/Services/PasswordHasherTests.cs rename to Govor.Application.Tests/Services/PasswordHasherTests.cs index d060db5..a0e4074 100644 --- a/Govor.API.Tests/UnitTests/Services/PasswordHasherTests.cs +++ b/Govor.Application.Tests/Services/PasswordHasherTests.cs @@ -1,8 +1,8 @@ using AutoFixture; -using Govor.Application.Services; +using Govor.Application.Services.Authentication; using Govor.Core.Infrastructure.Extensions; -namespace Govor.API.Tests.UnitTests.Services; +namespace Govor.Application.Tests.Services; [TestFixture] public class PasswordHasherTests diff --git a/Govor.API.Tests/UnitTests/Services/PingHandlerServiceTests.cs b/Govor.Application.Tests/Services/PingHandlerServiceTests.cs similarity index 97% rename from Govor.API.Tests/UnitTests/Services/PingHandlerServiceTests.cs rename to Govor.Application.Tests/Services/PingHandlerServiceTests.cs index 312342b..44ba86b 100644 --- a/Govor.API.Tests/UnitTests/Services/PingHandlerServiceTests.cs +++ b/Govor.Application.Tests/Services/PingHandlerServiceTests.cs @@ -4,7 +4,7 @@ using Govor.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; -namespace Govor.API.Tests.UnitTests.Services; +namespace Govor.Application.Tests.Services; [TestFixture] public class PingHandlerServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/UserGroupsServiceTests.cs b/Govor.Application.Tests/Services/UserGroupsServiceTests.cs similarity index 97% rename from Govor.API.Tests/UnitTests/Services/UserGroupsServiceTests.cs rename to Govor.Application.Tests/Services/UserGroupsServiceTests.cs index 4849ed8..d093df6 100644 --- a/Govor.API.Tests/UnitTests/Services/UserGroupsServiceTests.cs +++ b/Govor.Application.Tests/Services/UserGroupsServiceTests.cs @@ -6,7 +6,7 @@ using Govor.Core.Repositories.Groups; using Govor.Data.Repositories.Exceptions; using Moq; -namespace Govor.API.Tests.UnitTests.Services; +namespace Govor.Application.Tests.Services; [TestFixture] public class UserGroupsServiceTests diff --git a/Govor.API.Tests/UnitTests/Services/VerifyFriendshipTests.cs b/Govor.Application.Tests/Services/VerifyFriendshipTests.cs similarity index 98% rename from Govor.API.Tests/UnitTests/Services/VerifyFriendshipTests.cs rename to Govor.Application.Tests/Services/VerifyFriendshipTests.cs index 721f69b..a4a396d 100644 --- a/Govor.API.Tests/UnitTests/Services/VerifyFriendshipTests.cs +++ b/Govor.Application.Tests/Services/VerifyFriendshipTests.cs @@ -7,7 +7,7 @@ using Govor.Data.Repositories.Exceptions; using Microsoft.Extensions.Logging; using Moq; -namespace Govor.API.Tests.UnitTests.Services; +namespace Govor.Application.Tests.Services; [TestFixture] public class VerifyFriendshipTests diff --git a/Govor.API.Tests/UnitTests/Services/Validators/UsernameValidatorTests.cs b/Govor.Application.Tests/Validators/UsernameValidatorTests.cs similarity index 100% rename from Govor.API.Tests/UnitTests/Services/Validators/UsernameValidatorTests.cs rename to Govor.Application.Tests/Validators/UsernameValidatorTests.cs diff --git a/Govor.Application/Interfaces/AdminsStuff/InvitationGenerator.cs b/Govor.Application/Infrastructure/AdminsStuff/InvitationGenerator.cs similarity index 93% rename from Govor.Application/Interfaces/AdminsStuff/InvitationGenerator.cs rename to Govor.Application/Infrastructure/AdminsStuff/InvitationGenerator.cs index e744b65..d448c49 100644 --- a/Govor.Application/Interfaces/AdminsStuff/InvitationGenerator.cs +++ b/Govor.Application/Infrastructure/AdminsStuff/InvitationGenerator.cs @@ -2,7 +2,7 @@ using Govor.API.Services.AdminsStuff.Interfaces; using Govor.Core.Models; using Govor.Core.Repositories.Invaites; -namespace Govor.Application.Interfaces.AdminsStuff; +namespace Govor.Application.Infrastructure.AdminsStuff; public class InvitationGenerator(IInvitesRepository repository) : IInvitationGenerator { diff --git a/Govor.Application/Interfaces/AdminsStuff/UsersService.cs b/Govor.Application/Infrastructure/AdminsStuff/UsersService.cs similarity index 100% rename from Govor.Application/Interfaces/AdminsStuff/UsersService.cs rename to Govor.Application/Infrastructure/AdminsStuff/UsersService.cs diff --git a/Govor.Application/Interfaces/Messages/IMessageService.cs b/Govor.Application/Interfaces/Messages/IMessageCommandService.cs similarity index 97% rename from Govor.Application/Interfaces/Messages/IMessageService.cs rename to Govor.Application/Interfaces/Messages/IMessageCommandService.cs index f4c269e..a089c16 100644 --- a/Govor.Application/Interfaces/Messages/IMessageService.cs +++ b/Govor.Application/Interfaces/Messages/IMessageCommandService.cs @@ -4,7 +4,7 @@ using Govor.Core.Models; namespace Govor.Application.Interfaces.Messages; // Combining IChatService and IGroupService functionalities relevant to messages -public interface IMessageService +public interface IMessageCommandService { Task SendMessageAsync(SendMessage messageParameters); Task EditMessageAsync(EditMessage messageParameters); diff --git a/Govor.Application/Services/AuthService.cs b/Govor.Application/Services/Authentication/AuthService.cs similarity index 98% rename from Govor.Application/Services/AuthService.cs rename to Govor.Application/Services/Authentication/AuthService.cs index f16bdb8..96685b8 100644 --- a/Govor.Application/Services/AuthService.cs +++ b/Govor.Application/Services/Authentication/AuthService.cs @@ -8,7 +8,7 @@ using Govor.Application.Interfaces.Authentication; using Govor.Core.Infrastructure.Validators; using Govor.Core.Repositories.Admins; -namespace Govor.Application.Services; +namespace Govor.Application.Services.Authentication; public class AuthService : IAccountService { diff --git a/Govor.Application/Services/JwtOption.cs b/Govor.Application/Services/Authentication/JwtOption.cs similarity index 65% rename from Govor.Application/Services/JwtOption.cs rename to Govor.Application/Services/Authentication/JwtOption.cs index 144c231..a4ebef1 100644 --- a/Govor.Application/Services/JwtOption.cs +++ b/Govor.Application/Services/Authentication/JwtOption.cs @@ -1,4 +1,4 @@ -namespace Govor.Application.Services; +namespace Govor.Application.Services.Authentication; public class JwtOption { public string SecretKeу {get; set;} diff --git a/Govor.Application/Services/JwtService.cs b/Govor.Application/Services/Authentication/JwtService.cs similarity index 95% rename from Govor.Application/Services/JwtService.cs rename to Govor.Application/Services/Authentication/JwtService.cs index dcd8334..56cf08c 100644 --- a/Govor.Application/Services/JwtService.cs +++ b/Govor.Application/Services/Authentication/JwtService.cs @@ -6,7 +6,7 @@ using Govor.Core.Models; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -namespace Govor.Application.Services; +namespace Govor.Application.Services.Authentication; public class JwtService : IJwtService { diff --git a/Govor.Application/Services/PasswordHasher.cs b/Govor.Application/Services/Authentication/PasswordHasher.cs similarity index 87% rename from Govor.Application/Services/PasswordHasher.cs rename to Govor.Application/Services/Authentication/PasswordHasher.cs index ec83d71..99003ef 100644 --- a/Govor.Application/Services/PasswordHasher.cs +++ b/Govor.Application/Services/Authentication/PasswordHasher.cs @@ -1,6 +1,6 @@ using Govor.Core.Infrastructure.Extensions; -namespace Govor.Application.Services; +namespace Govor.Application.Services.Authentication; public class PasswordHasher : IPasswordHasher { diff --git a/Govor.Application/Services/MediaService.cs b/Govor.Application/Services/Messages/MediaService.cs similarity index 92% rename from Govor.Application/Services/MediaService.cs rename to Govor.Application/Services/Messages/MediaService.cs index 178c364..46df591 100644 --- a/Govor.Application/Services/MediaService.cs +++ b/Govor.Application/Services/Messages/MediaService.cs @@ -1,7 +1,7 @@ using Govor.Application.Interfaces; using Govor.Application.Interfaces.Medias; -namespace Govor.Application.Services; +namespace Govor.Application.Services.Messages; public class MediaService : IMediaService { diff --git a/Govor.Application/Services/MessageService.cs b/Govor.Application/Services/Messages/MessageCommandService.cs similarity index 97% rename from Govor.Application/Services/MessageService.cs rename to Govor.Application/Services/Messages/MessageCommandService.cs index e39af2f..590ee52 100644 --- a/Govor.Application/Services/MessageService.cs +++ b/Govor.Application/Services/Messages/MessageCommandService.cs @@ -8,24 +8,24 @@ using Govor.Core.Repositories.PrivateChats; using Govor.Core.Repositories.Users; using Microsoft.Extensions.Logging; -namespace Govor.Application.Services; +namespace Govor.Application.Services.Messages; -public class MessageService : IMessageService +public class MessageCommandService : IMessageCommandService { private readonly IMessagesRepository _messagesRepository; private readonly IUsersRepository _usersRepository; // For validating user recipients private readonly IGroupsRepository _groupsRepository; // For validating group recipients and fetching members private readonly IPrivateChatsRepository _privateChats; private readonly IVerifyFriendship _verifyFriendship; // For private messages - private readonly ILogger _logger; + private readonly ILogger _logger; - public MessageService( + public MessageCommandService( IMessagesRepository messagesRepository, IUsersRepository usersRepository, IGroupsRepository groupsRepository, IVerifyFriendship verifyFriendship, IPrivateChatsRepository privateChats, - ILogger logger) + ILogger logger) { _messagesRepository = messagesRepository; _usersRepository = usersRepository; diff --git a/Govor.Application/Services/MessagesLoader.cs b/Govor.Application/Services/Messages/MessagesLoader.cs similarity index 96% rename from Govor.Application/Services/MessagesLoader.cs rename to Govor.Application/Services/Messages/MessagesLoader.cs index 406a974..fc4cca5 100644 --- a/Govor.Application/Services/MessagesLoader.cs +++ b/Govor.Application/Services/Messages/MessagesLoader.cs @@ -4,7 +4,7 @@ using Govor.Core.Repositories.Groups; using Govor.Core.Repositories.Messages; using Govor.Data.Repositories.Exceptions; -namespace Govor.Application.Services; +namespace Govor.Application.Services.Messages; public class MessagesLoader : IMessagesLoader { diff --git a/Govor.sln b/Govor.sln index d3eeb87..8c4b6c7 100644 --- a/Govor.sln +++ b/Govor.sln @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Govor.Contracts", "Govor.Co EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Govor.Application", "Govor.Application\Govor.Application.csproj", "{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Govor.Application.Tests", "Govor.Application.Tests\Govor.Application.Tests.csproj", "{F56A64DF-2938-4BE0-83F2-B86429F19259}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +57,10 @@ Global {FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Release|Any CPU.Build.0 = Release|Any CPU + {F56A64DF-2938-4BE0-83F2-B86429F19259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F56A64DF-2938-4BE0-83F2-B86429F19259}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F56A64DF-2938-4BE0-83F2-B86429F19259}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F56A64DF-2938-4BE0-83F2-B86429F19259}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {15031CBD-F319-4755-BA91-B86F20BD8E37} = {4ED5259A-6FB4-4D89-8E6B-4778DC68F7D4} @@ -64,5 +70,6 @@ Global {E4EDB179-7EB5-468D-9C1F-0CBE2E5E459E} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776} {4E94907F-BE20-42A6-AB15-637850FEAD11} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776} {FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776} + {F56A64DF-2938-4BE0-83F2-B86429F19259} = {4ED5259A-6FB4-4D89-8E6B-4778DC68F7D4} EndGlobalSection EndGlobal