diff --git a/Govor.API.Tests/UnitTests/Infrastructure/Validators/MessageValidatorTests.cs b/Govor.API.Tests/UnitTests/Infrastructure/Validators/MessageValidatorTests.cs index c171087..8472243 100644 --- a/Govor.API.Tests/UnitTests/Infrastructure/Validators/MessageValidatorTests.cs +++ b/Govor.API.Tests/UnitTests/Infrastructure/Validators/MessageValidatorTests.cs @@ -1,6 +1,7 @@ using AutoFixture; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.API.Tests.UnitTests.Infrastructure.Validators; diff --git a/Govor.API.Tests/UnitTests/Infrastructure/Validators/UserValidatorTests.cs b/Govor.API.Tests/UnitTests/Infrastructure/Validators/UserValidatorTests.cs index 6c1e228..c7d9162 100644 --- a/Govor.API.Tests/UnitTests/Infrastructure/Validators/UserValidatorTests.cs +++ b/Govor.API.Tests/UnitTests/Infrastructure/Validators/UserValidatorTests.cs @@ -1,6 +1,7 @@ using AutoFixture; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.API.Tests.UnitTests.Infrastructure.Validators; diff --git a/Govor.API/Controllers/AdminStuff/FriendshipsController.cs b/Govor.API/Controllers/AdminStuff/FriendshipsController.cs index a124dbf..502abf4 100644 --- a/Govor.API/Controllers/AdminStuff/FriendshipsController.cs +++ b/Govor.API/Controllers/AdminStuff/FriendshipsController.cs @@ -1,5 +1,6 @@ using Govor.Contracts.DTOs; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Friendships; using Govor.Data.Repositories.Exceptions; using Microsoft.AspNetCore.Authorization; diff --git a/Govor.API/Controllers/AdminStuff/UsersController.cs b/Govor.API/Controllers/AdminStuff/UsersController.cs index dd7e67f..fa75d8e 100644 --- a/Govor.API/Controllers/AdminStuff/UsersController.cs +++ b/Govor.API/Controllers/AdminStuff/UsersController.cs @@ -1,6 +1,7 @@ using Govor.API.Services.AdminsStuff.Interfaces; +using Govor.Application.Interfaces; using Govor.Contracts.Responses.Admins; -using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Data.Repositories.Exceptions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/Govor.API/Controllers/Friends/FriendshipController.cs b/Govor.API/Controllers/Friends/FriendshipController.cs index 2aff5e0..e8bb89d 100644 --- a/Govor.API/Controllers/Friends/FriendshipController.cs +++ b/Govor.API/Controllers/Friends/FriendshipController.cs @@ -2,7 +2,7 @@ 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 Govor.Core.Models.Users; using Microsoft.AspNetCore.Mvc; namespace Govor.API.Controllers.Friends; diff --git a/Govor.API/Extensions/ConfigurationProgramExtensions.cs b/Govor.API/Extensions/ConfigurationProgramExtensions.cs index f85954e..b687326 100644 --- a/Govor.API/Extensions/ConfigurationProgramExtensions.cs +++ b/Govor.API/Extensions/ConfigurationProgramExtensions.cs @@ -4,7 +4,6 @@ using Govor.Application.Infrastructure.AdminsStuff; using Govor.Application.Infrastructure.Extensions; using Govor.Application.Infrastructure.Validators; using Govor.Application.Interfaces; -using Govor.Application.Interfaces.AdminsStuff; using Govor.Application.Interfaces.Authentication; using Govor.Application.Interfaces.Friends; using Govor.Application.Interfaces.Infrastructure.Extensions; @@ -16,6 +15,8 @@ using Govor.Application.Services.Messages; using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Messages; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Admins; using Govor.Core.Repositories.Friendships; using Govor.Core.Repositories.Groups; diff --git a/Govor.API/Hubs/ChatsHub.cs b/Govor.API/Hubs/ChatsHub.cs index af8c6e3..cdd9d73 100644 --- a/Govor.API/Hubs/ChatsHub.cs +++ b/Govor.API/Hubs/ChatsHub.cs @@ -1,10 +1,10 @@ -using Govor.API.Services; +using Govor.Application.Exceptions.VerifyFriendship; using Govor.Application.Interfaces; using Govor.Application.Interfaces.Messages; using Govor.Application.Interfaces.Messages.Parameters; using Govor.Contracts.Requests.SignalR; using Govor.Contracts.Responses.SignalR; -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.SignalR; @@ -85,143 +85,191 @@ public class ChatsHub : Hub await base.OnDisconnectedAsync(exception); } - public async Task Send(MessageRequest request) + public async Task> Send(MessageRequest request) { var senderId = GetUserId(); - + if (string.IsNullOrWhiteSpace(request.EncryptedContent) && (request.MediaAttachments == null || !request.MediaAttachments.Any())) { - _logger.LogWarning("Empty message (no content and no attachments) received from user {UserId}", senderId); - throw new ArgumentException("Message cannot be empty (must have content or attachments)."); + _logger.LogWarning("Empty message received from user {UserId}", senderId); + return HubResult.BadRequest("Message must contain content or media."); } - _logger.LogInformation("Message send initiated by {SenderId} to {RecipientId} of type {RecipientType}", + _logger.LogInformation("Sending message from {SenderId} to {RecipientId} ({RecipientType})", senderId, request.RecipientId, request.RecipientType); - var sendMessageParams = new SendMessage(EncryptContent: request.EncryptedContent, - ReplyToMessageId: request.ReplyToMessageId, FromUserId: senderId, RecipientId: request.RecipientId, - RecipientType: request.RecipientType, SendAt: DateTime.UtcNow, + var sendMessageParams = new SendMessage( + EncryptContent: request.EncryptedContent, + ReplyToMessageId: request.ReplyToMessageId, + FromUserId: senderId, + RecipientId: request.RecipientId, + RecipientType: request.RecipientType, + SendAt: DateTime.UtcNow, Media: request.MediaAttachments?.Select(f => new SendMedia(f.MediaId, f.EncryptedKey)) ?? - Array.Empty()); - - var result = await _messageCommandService.SendMessageAsync(sendMessageParams); - - if (!result.IsSuccess || result.Message.Id == Guid.Empty) - { - _logger.LogError(result.Exception, - "Failed to send message from {SenderId} to {RecipientId}. Error: {ErrorMessage}", senderId, - request.RecipientId, result.Exception?.Message ?? "Unknown error"); - if (result.Exception != null) - throw result.Exception; - throw new HubException("Failed to send message due to an internal error."); - } - - var messageResponse = new UserMessageResponse // Assuming a response DTO - { - MessageId = result.Message.Id, - SenderId = result.Message.SenderId, - RecipientId = result.Message.RecipientId, - RecipientType = result.Message.RecipientType, - EncryptedContent = result.Message.EncryptedContent, - SentAt = result.Message.SentAt, - IsEdited = false, - MediaAttachments = result.Message.MediaAttachments.Select(m => m.MediaFile).ToList(), - ReplyToMessageId = request.ReplyToMessageId - }; - - // Notify recipient (user or group) - if (request.RecipientType == RecipientType.User) - { - // Send to the recipient's personal group - await Clients.Group(request.RecipientId.ToString()).SendAsync("ReceiveMessage", messageResponse); - } - else if (request.RecipientType == RecipientType.Group) - { - // Send to all members of the group, including the sender if they are part of the group via a different connection - await Clients.Group($"group_{request.RecipientId}").SendAsync("ReceiveMessage", messageResponse); - } - - // Notify sender (confirmation) on their connection - await Clients.Caller.SendAsync("MessageSent", - messageResponse); // Or use "ReceiveMessage" if the sender should also just get it like anyone else - - _logger.LogInformation( - "Message {MessageId} sent successfully from {SenderId} to {RecipientId} ({RecipientType})", - result.Message.Id, senderId, request.RecipientId, request.RecipientType); - } - - public async Task Remove(RemoveMessageRequest request) - { - var removerId = GetUserId(); - _logger.LogInformation("Message removal initiated by {RemoverId} for message {MessageId}", removerId, request.MessageId); - - var removeParams = new DeleteMessage( - DeleterId: removerId, - MessageId: request.MessageId + Array.Empty() ); - + try { - var result = await _messageCommandService.DeleteMessageAsync(removeParams); - if (!result.IsSuccess) - { - _logger.LogError(result.Exception, "Failed to remove message {MessageId} by {RemoverId}. Error: {ErrorMessage}", request.MessageId, removerId, result.Exception?.Message ?? "Unknown error"); - if (result.Exception != null) throw result.Exception; - throw new HubException("Failed to remove message."); - } - - var originalMessage = result.OriginalMessage; // Assuming service returns this - if (originalMessage == null) - { - _logger.LogError("DeleteMessageAsync succeeded but did not return the original message details for message {MessageId}", request.MessageId); - throw new HubException("Failed to process message deletion due to missing message details."); - } + var result = await _messageCommandService.SendMessageAsync(sendMessageParams); - var removalNotification = new MessageRemovedResponse - { - MessageId = request.MessageId, - SenderId = originalMessage.SenderId, - RecipientId = originalMessage.RecipientId, - RecipientType = originalMessage.RecipientType - }; + if (!result.IsSuccess || result.Message.Id == Guid.Empty) + return LogAndError(senderId, request.RecipientId, "Failed to send message", result.Exception); - // Notify relevant clients - if (originalMessage.RecipientType == RecipientType.User) - { - await Clients.Group(originalMessage.SenderId.ToString()).SendAsync("MessageRemoved", removalNotification); - if (originalMessage.SenderId != originalMessage.RecipientId) - { - await Clients.Group(originalMessage.RecipientId.ToString()).SendAsync("MessageRemoved", removalNotification); - } - } - else if (originalMessage.RecipientType == RecipientType.Group) - { - await Clients.Group($"group_{originalMessage.RecipientId}").SendAsync("MessageRemoved", removalNotification); - } - _logger.LogInformation("Message {MessageId} removed successfully by {RemoverId}", request.MessageId, removerId); + var response = BuildUserMessageResponse(result.Message, request.ReplyToMessageId); + + await NotifyClientsAboutMessage(response); + + return HubResult.Ok(response); } catch (UnauthorizedAccessException ex) { - _logger.LogWarning(ex, "Unauthorized attempt to remove message {MessageId} by user {RemoverId}", request.MessageId, removerId); - throw new HubException("You are not authorized to remove this message.", ex); + return LogAndUnauthorized(ex, "Unauthorized sending attempt", senderId, + request.RecipientId); } - catch (KeyNotFoundException ex) // Or a custom NotFoundException + catch (FriendshipException) { - _logger.LogWarning(ex, "Attempt to remove non-existent message {MessageId} by user {RemoverId}", request.MessageId, removerId); - throw new HubException("Message not found.", ex); + return HubResult.Unauthorized( + "You cannot send this message because you are not friends."); + } + catch (ArgumentException) + { + return HubResult.BadRequest("Invalid message content."); } catch (Exception ex) { - _logger.LogError(ex, "Error removing message {MessageId} by {RemoverId}", request.MessageId, removerId); - throw new HubException("An error occurred while removing the message.", ex); + return LogAndError(senderId, request.RecipientId, "Unhandled exception", ex); } } - public async Task Edit(EditMessageRequest request) + + public async Task> Remove(RemoveMessageRequest request) { + var removerId = GetUserId(); + _logger.LogInformation("Removing message {MessageId} by user {RemoverId}", request.MessageId, removerId); + + try + { + var result = await _messageCommandService.DeleteMessageAsync(new DeleteMessage(removerId, request.MessageId)); + + if (!result.IsSuccess || result.OriginalMessage == null) + return LogAndError(removerId, request.MessageId, "Message deletion failed", result.Exception); + + var notification = new MessageRemovedResponse + { + MessageId = request.MessageId, + SenderId = result.OriginalMessage.SenderId, + RecipientId = result.OriginalMessage.RecipientId, + RecipientType = result.OriginalMessage.RecipientType + }; + + await NotifyClientsAboutRemoval(notification); + + _logger.LogInformation("Message {MessageId} removed successfully by {RemoverId}", request.MessageId, removerId); + return HubResult.Ok(notification); + } + catch (UnauthorizedAccessException ex) + { + return LogAndUnauthorized(ex, "Unauthorized removal", removerId, request.MessageId); + } + catch (KeyNotFoundException ex) + { + return LogAndNotFound(ex, "Message not found", removerId, request.MessageId); + } + catch (Exception ex) + { + return LogAndError(removerId, request.MessageId, "Unhandled deletion error", ex); + } } + + public async Task> Edit(EditMessageRequest request) + { + var editor = GetUserId(); + _logger.LogInformation("Editing message {MessageId} by user {EditorId}", request.MessageId, editor); + + var editMessageParam = new EditMessage(editor, + request.MessageId, + request.NewEncryptedContent, + DateTime.UtcNow); + + try + { + var result = await _messageCommandService.EditMessageAsync(editMessageParam); + + if(!result.IsSuccess) + return LogAndError(editor, request.MessageId, "Edit message error", result.Exception); + + return HubResult.Ok(); + } + catch (Exception ex) + { + return LogAndError(editor, request.MessageId, "Unhandled exception error", ex); + } + } + + + private UserMessageResponse BuildUserMessageResponse(Message message, Guid? replyToId) + { + return new UserMessageResponse + { + MessageId = message.Id, + SenderId = message.SenderId, + RecipientId = message.RecipientId, + RecipientType = message.RecipientType, + EncryptedContent = message.EncryptedContent, + SentAt = message.SentAt, + IsEdited = false, + MediaAttachments = message.MediaAttachments.Select(m => m.MediaFile).ToList(), + ReplyToMessageId = replyToId + }; + } + + private async Task NotifyClientsAboutMessage(UserMessageResponse response) + { + string group = response.RecipientType == RecipientType.User + ? response.RecipientId.ToString() + : $"group_{response.RecipientId}"; + + await Clients.Group(group).SendAsync("ReceiveMessage", response); + await Clients.Caller.SendAsync("MessageSent", response); + } + + private async Task NotifyClientsAboutRemoval(MessageRemovedResponse response) + { + if (response.RecipientType == RecipientType.User) + { + await Clients.Group(response.SenderId.ToString()).SendAsync("MessageRemoved", response); + if (response.SenderId != response.RecipientId) + await Clients.Group(response.RecipientId.ToString()).SendAsync("MessageRemoved", response); + } + else + { + await Clients.Group($"group_{response.RecipientId}").SendAsync("MessageRemoved", response); + } + } + + // Logging helpers + private HubResult LogAndError(Guid userId, Guid targetId, string message, Exception ex) + { + _logger.LogError(ex, "{Message} from {UserId} to {TargetId}", message, userId, targetId); + return HubResult.Error(ex?.Message ?? "Internal server error"); + } + + private HubResult LogAndUnauthorized(Exception ex, string msg, Guid userId, Guid targetId) + { + _logger.LogWarning(ex, "{Msg}: {UserId} -> {TargetId}", msg, userId, targetId); + return HubResult.Unauthorized("You are not authorized to perform this action."); + } + + private HubResult LogAndNotFound(Exception ex, string msg, Guid userId, Guid targetId) + { + _logger.LogWarning(ex, "{Msg}: {UserId} -> {TargetId}", msg, userId, targetId); + return HubResult.NotFound("Message not found."); + } + + private Guid GetUserId(bool suppressException = false) { var userIdClaim = Context.User?.FindFirst("userId")?.Value; diff --git a/Govor.API/Program.cs b/Govor.API/Program.cs index 3232205..cacd149 100644 --- a/Govor.API/Program.cs +++ b/Govor.API/Program.cs @@ -121,7 +121,7 @@ app.UseAuthorization(); app.MapControllers(); -app.MapHub("/hubs/friends"); +app.MapHub("/hubs/chats"); app.MapHub("/hubs/friends"); app.MapSwagger().RequireAuthorization(); diff --git a/Govor.Application.Tests/Services/Authentication/AuthServiceTests.cs b/Govor.Application.Tests/Services/Authentication/AuthServiceTests.cs index 389be9a..5964ad8 100644 --- a/Govor.Application.Tests/Services/Authentication/AuthServiceTests.cs +++ b/Govor.Application.Tests/Services/Authentication/AuthServiceTests.cs @@ -7,6 +7,7 @@ using Govor.Application.Exceptions.AuthService; using Govor.Application.Interfaces.Authentication; using Govor.Application.Services; using Govor.Application.Services.Authentication; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Admins; using Moq; diff --git a/Govor.Application.Tests/Services/Authentication/JwtServiceTests.cs b/Govor.Application.Tests/Services/Authentication/JwtServiceTests.cs index 3fa1585..d7a2889 100644 --- a/Govor.Application.Tests/Services/Authentication/JwtServiceTests.cs +++ b/Govor.Application.Tests/Services/Authentication/JwtServiceTests.cs @@ -1,9 +1,9 @@ using System.IdentityModel.Tokens.Jwt; using AutoFixture; using Govor.API.Services.Authentication.Interfaces; -using Govor.Application.Services; +using Govor.Application.Interfaces.Authentication; using Govor.Application.Services.Authentication; -using Govor.Core.Models; +using Govor.Core.Models.Users; using Microsoft.Extensions.Options; using Moq; diff --git a/Govor.Application.Tests/Services/Friends/FriendRequestQueryServiceTests.cs b/Govor.Application.Tests/Services/Friends/FriendRequestQueryServiceTests.cs index 3cade62..56029ec 100644 --- a/Govor.Application.Tests/Services/Friends/FriendRequestQueryServiceTests.cs +++ b/Govor.Application.Tests/Services/Friends/FriendRequestQueryServiceTests.cs @@ -2,6 +2,7 @@ using AutoFixture; using Govor.Application.Interfaces.Friends; using Govor.Application.Services.Friends; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Friendships; using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Application.Tests/Services/Friends/FriendshipServiceTests.cs b/Govor.Application.Tests/Services/Friends/FriendshipServiceTests.cs index 6a11e56..df8d52d 100644 --- a/Govor.Application.Tests/Services/Friends/FriendshipServiceTests.cs +++ b/Govor.Application.Tests/Services/Friends/FriendshipServiceTests.cs @@ -3,6 +3,7 @@ using Govor.Application.Exceptions.FriendsService; using Govor.Application.Interfaces.Friends; using Govor.Application.Services.Friends; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Friendships; using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Application.Tests/Services/Messages/MessageCommandServiceTests.cs b/Govor.Application.Tests/Services/Messages/MessageCommandServiceTests.cs index f5abc7b..8cccb45 100644 --- a/Govor.Application.Tests/Services/Messages/MessageCommandServiceTests.cs +++ b/Govor.Application.Tests/Services/Messages/MessageCommandServiceTests.cs @@ -3,6 +3,7 @@ using Govor.Application.Interfaces; using Govor.Application.Interfaces.Messages.Parameters; using Govor.Application.Services.Messages; using Govor.Core.Models; +using Govor.Core.Models.Messages; using Govor.Core.Repositories.Groups; using Govor.Core.Repositories.Messages; using Govor.Core.Repositories.PrivateChats; @@ -296,7 +297,7 @@ public class MessageCommandServiceTests Assert.That(result, Is.Not.Null); Assert.That(result.IsSuccess, Is.False); Assert.That(result.Exception, Is.Not.Null); - Assert.That(result.Exception,Is.TypeOf>()); + Assert.That(result.Exception,Is.TypeOf()); Assert.That(result.OriginalMessage, Is.Null); } diff --git a/Govor.Application.Tests/Services/PingHandlerServiceTests.cs b/Govor.Application.Tests/Services/PingHandlerServiceTests.cs index 44ba86b..d59e6ec 100644 --- a/Govor.Application.Tests/Services/PingHandlerServiceTests.cs +++ b/Govor.Application.Tests/Services/PingHandlerServiceTests.cs @@ -1,5 +1,5 @@ using Govor.Application.Services; -using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; diff --git a/Govor.Application/Infrastructure/AdminsStuff/UsersService.cs b/Govor.Application/Infrastructure/AdminsStuff/UsersService.cs index 56044cb..4651283 100644 --- a/Govor.Application/Infrastructure/AdminsStuff/UsersService.cs +++ b/Govor.Application/Infrastructure/AdminsStuff/UsersService.cs @@ -1,9 +1,9 @@ -using Govor.API.Services.AdminsStuff.Interfaces; -using Govor.Core.Models; +using Govor.Application.Interfaces; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; -namespace Govor.Application.Interfaces.AdminsStuff; +namespace Govor.Application.Infrastructure.AdminsStuff; public class UsersService : IUsersAdministration { diff --git a/Govor.Application/Interfaces/Authentication/IInvitesService.cs b/Govor.Application/Interfaces/Authentication/IInvitesService.cs index ba5a9c9..566f145 100644 --- a/Govor.Application/Interfaces/Authentication/IInvitesService.cs +++ b/Govor.Application/Interfaces/Authentication/IInvitesService.cs @@ -1,4 +1,5 @@ using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.API.Services.Authentication.Interfaces; diff --git a/Govor.Application/Interfaces/Authentication/IJwtService.cs b/Govor.Application/Interfaces/Authentication/IJwtService.cs index 7f0bf6b..6904693 100644 --- a/Govor.Application/Interfaces/Authentication/IJwtService.cs +++ b/Govor.Application/Interfaces/Authentication/IJwtService.cs @@ -1,6 +1,6 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; -namespace Govor.API.Services.Authentication.Interfaces; +namespace Govor.Application.Interfaces.Authentication; public interface IJwtService { diff --git a/Govor.Application/Interfaces/Friends/IFriendshipService.cs b/Govor.Application/Interfaces/Friends/IFriendshipService.cs index c791143..e3d5a7c 100644 --- a/Govor.Application/Interfaces/Friends/IFriendshipService.cs +++ b/Govor.Application/Interfaces/Friends/IFriendshipService.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Application.Interfaces.Friends; diff --git a/Govor.Application/Interfaces/IFriendsService.cs b/Govor.Application/Interfaces/IFriendsService.cs index 9cd4f71..4933f6f 100644 --- a/Govor.Application/Interfaces/IFriendsService.cs +++ b/Govor.Application/Interfaces/IFriendsService.cs @@ -1,4 +1,5 @@ using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Application.Interfaces; diff --git a/Govor.Application/Interfaces/IGroupService.cs b/Govor.Application/Interfaces/IGroupService.cs index e57119c..c3a8a40 100644 --- a/Govor.Application/Interfaces/IGroupService.cs +++ b/Govor.Application/Interfaces/IGroupService.cs @@ -1,5 +1,6 @@ using Govor.Application.Interfaces.Messages.Parameters; using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Application.Interfaces; diff --git a/Govor.Application/Interfaces/IMessagesLoader.cs b/Govor.Application/Interfaces/IMessagesLoader.cs index 1cc3334..cb8880d 100644 --- a/Govor.Application/Interfaces/IMessagesLoader.cs +++ b/Govor.Application/Interfaces/IMessagesLoader.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Application.Interfaces; diff --git a/Govor.Application/Interfaces/IUsersAdministration.cs b/Govor.Application/Interfaces/IUsersAdministration.cs index a6ccae5..dfdd34e 100644 --- a/Govor.Application/Interfaces/IUsersAdministration.cs +++ b/Govor.Application/Interfaces/IUsersAdministration.cs @@ -1,6 +1,6 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; -namespace Govor.API.Services.AdminsStuff.Interfaces; +namespace Govor.Application.Interfaces; public interface IUsersAdministration { diff --git a/Govor.Application/Interfaces/Medias/IMediaService.cs b/Govor.Application/Interfaces/Medias/IMediaService.cs index ec3e707..6b0e3b3 100644 --- a/Govor.Application/Interfaces/Medias/IMediaService.cs +++ b/Govor.Application/Interfaces/Medias/IMediaService.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Application.Interfaces.Medias; diff --git a/Govor.Application/Interfaces/Messages/IMessageCommandService.cs b/Govor.Application/Interfaces/Messages/IMessageCommandService.cs index a089c16..e38aa15 100644 --- a/Govor.Application/Interfaces/Messages/IMessageCommandService.cs +++ b/Govor.Application/Interfaces/Messages/IMessageCommandService.cs @@ -1,5 +1,5 @@ using Govor.Application.Interfaces.Messages.Parameters; -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Application.Interfaces.Messages; diff --git a/Govor.Application/Interfaces/Messages/Parameters/SendMessage.cs b/Govor.Application/Interfaces/Messages/Parameters/SendMessage.cs index f59e222..3f68d10 100644 --- a/Govor.Application/Interfaces/Messages/Parameters/SendMessage.cs +++ b/Govor.Application/Interfaces/Messages/Parameters/SendMessage.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Application.Interfaces.Messages.Parameters; diff --git a/Govor.Application/Services/Authentication/AuthService.cs b/Govor.Application/Services/Authentication/AuthService.cs index 96685b8..dbfcf01 100644 --- a/Govor.Application/Services/Authentication/AuthService.cs +++ b/Govor.Application/Services/Authentication/AuthService.cs @@ -1,11 +1,9 @@ -using System.Text.RegularExpressions; -using Govor.API.Services.Authentication.Interfaces; using Govor.Application.Exceptions.AuthService; using Govor.Core.Infrastructure.Extensions; using Govor.Core.Models; using Govor.Core.Repositories.Users; using Govor.Application.Interfaces.Authentication; -using Govor.Core.Infrastructure.Validators; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Admins; namespace Govor.Application.Services.Authentication; diff --git a/Govor.Application/Services/Authentication/JwtService.cs b/Govor.Application/Services/Authentication/JwtService.cs index 56cf08c..9f5e8e4 100644 --- a/Govor.Application/Services/Authentication/JwtService.cs +++ b/Govor.Application/Services/Authentication/JwtService.cs @@ -2,7 +2,8 @@ using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text; using Govor.API.Services.Authentication.Interfaces; -using Govor.Core.Models; +using Govor.Application.Interfaces.Authentication; +using Govor.Core.Models.Users; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; diff --git a/Govor.Application/Services/Friends/FriendshipService.cs b/Govor.Application/Services/Friends/FriendshipService.cs index 522b2f5..a6bfa9f 100644 --- a/Govor.Application/Services/Friends/FriendshipService.cs +++ b/Govor.Application/Services/Friends/FriendshipService.cs @@ -1,6 +1,7 @@ using Govor.Application.Exceptions.FriendsService; using Govor.Application.Interfaces.Friends; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Friendships; using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Application/Services/InvitesService.cs b/Govor.Application/Services/InvitesService.cs index 07b4f49..0a5a240 100644 --- a/Govor.Application/Services/InvitesService.cs +++ b/Govor.Application/Services/InvitesService.cs @@ -1,6 +1,7 @@ using Govor.API.Services.Authentication.Interfaces; using Govor.Application.Exceptions.InvitesService; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Invaites; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Application/Services/Messages/MessageCommandService.cs b/Govor.Application/Services/Messages/MessageCommandService.cs index 590ee52..09b59d1 100644 --- a/Govor.Application/Services/Messages/MessageCommandService.cs +++ b/Govor.Application/Services/Messages/MessageCommandService.cs @@ -2,10 +2,12 @@ using Govor.Application.Interfaces; using Govor.Application.Interfaces.Messages; using Govor.Application.Interfaces.Messages.Parameters; using Govor.Core.Models; +using Govor.Core.Models.Messages; using Govor.Core.Repositories.Groups; using Govor.Core.Repositories.Messages; using Govor.Core.Repositories.PrivateChats; using Govor.Core.Repositories.Users; +using Govor.Data.Repositories.Exceptions; using Microsoft.Extensions.Logging; namespace Govor.Application.Services.Messages; @@ -183,11 +185,14 @@ public class MessageCommandService : IMessageCommandService // return new DeleteMessageResult(false, new UnauthorizedAccessException("User is not authorized to delete this message."), null); // } // } else { - _logger.LogWarning("User {DeleterId} attempted to delete message {MessageId} not sent by them (sender was {SenderId})", deleteParams.DeleterId, deleteParams.MessageId, message.SenderId); - return new DeleteMessageResult(false, new UnauthorizedAccessException("User is not authorized to delete this message."), default); + _logger.LogWarning( + "User {DeleterId} attempted to delete message {MessageId} not sent by them (sender was {SenderId})", + deleteParams.DeleterId, deleteParams.MessageId, message.SenderId); + return new DeleteMessageResult(false, + new UnauthorizedAccessException("User is not authorized to delete this message."), default); // } } - + var originalMessageForNotification = new Message { Id = message.Id, @@ -195,12 +200,17 @@ public class MessageCommandService : IMessageCommandService RecipientId = message.RecipientId, RecipientType = message.RecipientType, }; - + await _messagesRepository.RemoveAsync(deleteParams.MessageId); - - _logger.LogInformation("Message {MessageId} deleted successfully by user {DeleterId}", deleteParams.MessageId, deleteParams.DeleterId); + + _logger.LogInformation("Message {MessageId} deleted successfully by user {DeleterId}", + deleteParams.MessageId, deleteParams.DeleterId); return new DeleteMessageResult(true, default, originalMessageForNotification); } + catch (NotFoundByKeyException ex) + { + return new DeleteMessageResult(false, new KeyNotFoundException("Message not found", ex), default); + } catch (Exception ex) { _logger.LogError(ex, "Error deleting message {MessageId} by user {DeleterId}", deleteParams.MessageId, deleteParams.DeleterId); diff --git a/Govor.Application/Services/Messages/MessagesLoader.cs b/Govor.Application/Services/Messages/MessagesLoader.cs index fc4cca5..3734002 100644 --- a/Govor.Application/Services/Messages/MessagesLoader.cs +++ b/Govor.Application/Services/Messages/MessagesLoader.cs @@ -1,5 +1,5 @@ using Govor.Application.Interfaces; -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Govor.Core.Repositories.Groups; using Govor.Core.Repositories.Messages; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Console/Program.cs b/Govor.Console/Program.cs index 4609304..bc21795 100644 --- a/Govor.Console/Program.cs +++ b/Govor.Console/Program.cs @@ -10,6 +10,7 @@ using Govor.ConsoleClient.Commands; using Govor.Contracts.Requests.SignalR; using Govor.Contracts.Responses.SignalR; using Govor.Core.Models; +using Govor.Core.Models.Messages; /*==================================== *Личные сообщения| Егор @@ -200,7 +201,7 @@ namespace Govor.ConsoleClient options.AccessTokenProvider = () => Task.FromResult(AuthToken); }) .Build(); - + _hubConnection.On("ReceiveMessage", (message) => { var myId = GetMyUserId(); diff --git a/Govor.Contracts/Requests/MediaUploadRequest.cs b/Govor.Contracts/Requests/MediaUploadRequest.cs index 73f2c20..4408dc1 100644 --- a/Govor.Contracts/Requests/MediaUploadRequest.cs +++ b/Govor.Contracts/Requests/MediaUploadRequest.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Contracts.Requests; diff --git a/Govor.Contracts/Requests/SignalR/MessageRequest.cs b/Govor.Contracts/Requests/SignalR/MessageRequest.cs index fdce57f..a29e3fb 100644 --- a/Govor.Contracts/Requests/SignalR/MessageRequest.cs +++ b/Govor.Contracts/Requests/SignalR/MessageRequest.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Contracts.Requests.SignalR; diff --git a/Govor.Contracts/Responses/SignalR/MessageEditResponse.cs b/Govor.Contracts/Responses/SignalR/MessageEditResponse.cs new file mode 100644 index 0000000..a82ecca --- /dev/null +++ b/Govor.Contracts/Responses/SignalR/MessageEditResponse.cs @@ -0,0 +1,6 @@ +namespace Govor.Contracts.Responses.SignalR; + +public class MessageEditResponse +{ + +} \ No newline at end of file diff --git a/Govor.Contracts/Responses/SignalR/MessageRemovedResponse.cs b/Govor.Contracts/Responses/SignalR/MessageRemovedResponse.cs index 2fd3ff8..89471b4 100644 --- a/Govor.Contracts/Responses/SignalR/MessageRemovedResponse.cs +++ b/Govor.Contracts/Responses/SignalR/MessageRemovedResponse.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Contracts.Responses.SignalR; diff --git a/Govor.Contracts/Responses/SignalR/UserMessageResponse.cs b/Govor.Contracts/Responses/SignalR/UserMessageResponse.cs index 20a33fd..6632c60 100644 --- a/Govor.Contracts/Responses/SignalR/UserMessageResponse.cs +++ b/Govor.Contracts/Responses/SignalR/UserMessageResponse.cs @@ -1,5 +1,5 @@ -using Govor.Contracts.Requests.SignalR; using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Contracts.Responses.SignalR; diff --git a/Govor.Core/Infrastructure/Validators/AdminValidator.cs b/Govor.Core/Infrastructure/Validators/AdminValidator.cs index 4c5acc5..2aebfb6 100644 --- a/Govor.Core/Infrastructure/Validators/AdminValidator.cs +++ b/Govor.Core/Infrastructure/Validators/AdminValidator.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Core.Infrastructure.Validators; diff --git a/Govor.Core/Infrastructure/Validators/MediaAttachmentsValidator.cs b/Govor.Core/Infrastructure/Validators/MediaAttachmentsValidator.cs index aa598f7..6a2bd1c 100644 --- a/Govor.Core/Infrastructure/Validators/MediaAttachmentsValidator.cs +++ b/Govor.Core/Infrastructure/Validators/MediaAttachmentsValidator.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Exception = System.Exception; namespace Govor.Core.Infrastructure.Validators; diff --git a/Govor.Core/Infrastructure/Validators/MessageValidator.cs b/Govor.Core/Infrastructure/Validators/MessageValidator.cs index fbe5530..149ac1d 100644 --- a/Govor.Core/Infrastructure/Validators/MessageValidator.cs +++ b/Govor.Core/Infrastructure/Validators/MessageValidator.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Infrastructure.Validators; diff --git a/Govor.Core/Infrastructure/Validators/UserValidator.cs b/Govor.Core/Infrastructure/Validators/UserValidator.cs index 6bcc609..b849aca 100644 --- a/Govor.Core/Infrastructure/Validators/UserValidator.cs +++ b/Govor.Core/Infrastructure/Validators/UserValidator.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; using ArgumentNullException = System.ArgumentNullException; namespace Govor.Core.Infrastructure.Validators; diff --git a/Govor.Core/Models/Friendship.cs b/Govor.Core/Models/Friendship.cs index 6a7fe25..442bf37 100644 --- a/Govor.Core/Models/Friendship.cs +++ b/Govor.Core/Models/Friendship.cs @@ -1,3 +1,5 @@ +using Govor.Core.Models.Users; + namespace Govor.Core.Models; public class Friendship diff --git a/Govor.Core/Models/GroupInvitation.cs b/Govor.Core/Models/GroupInvitation.cs index 57f44c9..3f135fd 100644 --- a/Govor.Core/Models/GroupInvitation.cs +++ b/Govor.Core/Models/GroupInvitation.cs @@ -1,3 +1,5 @@ +using Govor.Core.Models.Users; + namespace Govor.Core.Models; public class GroupInvitation diff --git a/Govor.Core/Models/Invitation.cs b/Govor.Core/Models/Invitation.cs index adb0d90..46e0555 100644 --- a/Govor.Core/Models/Invitation.cs +++ b/Govor.Core/Models/Invitation.cs @@ -1,3 +1,5 @@ +using Govor.Core.Models.Users; + namespace Govor.Core.Models; public class Invitation diff --git a/Govor.Core/Models/MediaFile.cs b/Govor.Core/Models/MediaFile.cs index 038f00f..6023416 100644 --- a/Govor.Core/Models/MediaFile.cs +++ b/Govor.Core/Models/MediaFile.cs @@ -1,3 +1,5 @@ +using Govor.Core.Models.Messages; + namespace Govor.Core.Models; public class MediaFile diff --git a/Govor.Core/Models/MediaAttachments.cs b/Govor.Core/Models/Messages/MediaAttachments.cs similarity index 93% rename from Govor.Core/Models/MediaAttachments.cs rename to Govor.Core/Models/Messages/MediaAttachments.cs index 947d458..99a5a6b 100644 --- a/Govor.Core/Models/MediaAttachments.cs +++ b/Govor.Core/Models/Messages/MediaAttachments.cs @@ -1,4 +1,4 @@ -namespace Govor.Core.Models; +namespace Govor.Core.Models.Messages; public class MediaAttachments { diff --git a/Govor.Core/Models/Message.cs b/Govor.Core/Models/Messages/Message.cs similarity index 97% rename from Govor.Core/Models/Message.cs rename to Govor.Core/Models/Messages/Message.cs index 6b72852..d999f4b 100644 --- a/Govor.Core/Models/Message.cs +++ b/Govor.Core/Models/Messages/Message.cs @@ -1,4 +1,4 @@ -namespace Govor.Core.Models; +namespace Govor.Core.Models.Messages; public class Message { diff --git a/Govor.Core/Models/MessageReaction.cs b/Govor.Core/Models/Messages/MessageReaction.cs similarity index 84% rename from Govor.Core/Models/MessageReaction.cs rename to Govor.Core/Models/Messages/MessageReaction.cs index 8e8fa80..1ce2382 100644 --- a/Govor.Core/Models/MessageReaction.cs +++ b/Govor.Core/Models/Messages/MessageReaction.cs @@ -1,4 +1,6 @@ -namespace Govor.Core.Models; +using Govor.Core.Models.Users; + +namespace Govor.Core.Models.Messages; public class MessageReaction { diff --git a/Govor.Core/Models/MessageView.cs b/Govor.Core/Models/Messages/MessageView.cs similarity index 82% rename from Govor.Core/Models/MessageView.cs rename to Govor.Core/Models/Messages/MessageView.cs index 8f09035..0bb266a 100644 --- a/Govor.Core/Models/MessageView.cs +++ b/Govor.Core/Models/Messages/MessageView.cs @@ -1,4 +1,4 @@ -namespace Govor.Core.Models; +namespace Govor.Core.Models.Messages; public class MessageView { diff --git a/Govor.Core/Models/PrivateChat.cs b/Govor.Core/Models/PrivateChat.cs index 51f0921..df8cc29 100644 --- a/Govor.Core/Models/PrivateChat.cs +++ b/Govor.Core/Models/PrivateChat.cs @@ -1,3 +1,5 @@ +using Govor.Core.Models.Messages; + namespace Govor.Core.Models; public class PrivateChat diff --git a/Govor.Core/Models/Admin.cs b/Govor.Core/Models/Users/Admin.cs similarity index 82% rename from Govor.Core/Models/Admin.cs rename to Govor.Core/Models/Users/Admin.cs index a0ef8ca..c3e20bf 100644 --- a/Govor.Core/Models/Admin.cs +++ b/Govor.Core/Models/Users/Admin.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Govor.Core.Models; +namespace Govor.Core.Models.Users; public class Admin { diff --git a/Govor.Core/Models/Users/PrivacyUserSettings.cs b/Govor.Core/Models/Users/PrivacyUserSettings.cs new file mode 100644 index 0000000..1fece99 --- /dev/null +++ b/Govor.Core/Models/Users/PrivacyUserSettings.cs @@ -0,0 +1,39 @@ +namespace Govor.Core.Models.Users; + +public class PrivacyUserSettings +{ + public Guid UserId { get; set; } + public bool IsGlobalAccount { get; set; } + + public WhoCan CanSend { get; set; } + public List? WhitelistSent { get; set; } + public List? BlacklistSent { get; set; } + + public WhoCan CanSeeTimeWas { get; set; } + public List? WhitelistTimeWas { get; set; } + public List? BlacklistTimeWas { get; set; } + + public WhoCan CanSeeImage { get; set; } + public List? WhitelistSeeImage { get; set; } + public List? BlacklistSeeImage{ get; set; } + + public DeletingMessagesVia Via { get; set; } // if min value = none + public int DeletingIn { get; set; } +} + +public enum WhoCan +{ + None = 0, + OnlyFriends = 1, + EveryoneCanSend = 2, +} + +public enum DeletingMessagesVia +{ + None = 0, + Hours = 1, + Days = 2, + Months = 3, + Years = 4 +} + diff --git a/Govor.Core/Models/User.cs b/Govor.Core/Models/Users/User.cs similarity index 97% rename from Govor.Core/Models/User.cs rename to Govor.Core/Models/Users/User.cs index 616d9d8..0669a69 100644 --- a/Govor.Core/Models/User.cs +++ b/Govor.Core/Models/Users/User.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Govor.Core.Models; +namespace Govor.Core.Models.Users; public class User { diff --git a/Govor.Core/Repositories/Admins/IAdminsExist.cs b/Govor.Core/Repositories/Admins/IAdminsExist.cs index c847400..c04e928 100644 --- a/Govor.Core/Repositories/Admins/IAdminsExist.cs +++ b/Govor.Core/Repositories/Admins/IAdminsExist.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Core.Repositories.Admins; diff --git a/Govor.Core/Repositories/Admins/IAdminsReader.cs b/Govor.Core/Repositories/Admins/IAdminsReader.cs index b5d01af..ca550a8 100644 --- a/Govor.Core/Repositories/Admins/IAdminsReader.cs +++ b/Govor.Core/Repositories/Admins/IAdminsReader.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Core.Repositories.Admins; diff --git a/Govor.Core/Repositories/Admins/IAdminsWriter.cs b/Govor.Core/Repositories/Admins/IAdminsWriter.cs index d34d582..60cbe2a 100644 --- a/Govor.Core/Repositories/Admins/IAdminsWriter.cs +++ b/Govor.Core/Repositories/Admins/IAdminsWriter.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Core.Repositories.Admins; diff --git a/Govor.Core/Repositories/Groups/IGroupMessagesReader.cs b/Govor.Core/Repositories/Groups/IGroupMessagesReader.cs index aed1ffc..d53b8ce 100644 --- a/Govor.Core/Repositories/Groups/IGroupMessagesReader.cs +++ b/Govor.Core/Repositories/Groups/IGroupMessagesReader.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Repositories.Groups; diff --git a/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsExist.cs b/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsExist.cs index efca3bd..89ab2d7 100644 --- a/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsExist.cs +++ b/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsExist.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Repositories.MediasAttachments; diff --git a/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsReader.cs b/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsReader.cs index 9a6f201..cb54728 100644 --- a/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsReader.cs +++ b/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsReader.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Repositories.MediasAttachments; diff --git a/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsWriter.cs b/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsWriter.cs index fbed08b..5754a3f 100644 --- a/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsWriter.cs +++ b/Govor.Core/Repositories/MediasAttachments/IMediaAttachmentsWriter.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Repositories.MediasAttachments; diff --git a/Govor.Core/Repositories/Messages/IMessagesExist.cs b/Govor.Core/Repositories/Messages/IMessagesExist.cs index 9bb0833..6d6deb6 100644 --- a/Govor.Core/Repositories/Messages/IMessagesExist.cs +++ b/Govor.Core/Repositories/Messages/IMessagesExist.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Repositories.Messages; diff --git a/Govor.Core/Repositories/Messages/IMessagesReader.cs b/Govor.Core/Repositories/Messages/IMessagesReader.cs index 623256c..5ca6afc 100644 --- a/Govor.Core/Repositories/Messages/IMessagesReader.cs +++ b/Govor.Core/Repositories/Messages/IMessagesReader.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Repositories.Messages; diff --git a/Govor.Core/Repositories/Messages/IMessagesWriter.cs b/Govor.Core/Repositories/Messages/IMessagesWriter.cs index d316bbf..f9f7b81 100644 --- a/Govor.Core/Repositories/Messages/IMessagesWriter.cs +++ b/Govor.Core/Repositories/Messages/IMessagesWriter.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; namespace Govor.Core.Repositories.Messages; diff --git a/Govor.Core/Repositories/Users/IUsersExist.cs b/Govor.Core/Repositories/Users/IUsersExist.cs index 19f2038..a06a180 100644 --- a/Govor.Core/Repositories/Users/IUsersExist.cs +++ b/Govor.Core/Repositories/Users/IUsersExist.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Core.Repositories.Users; diff --git a/Govor.Core/Repositories/Users/IUsersReader.cs b/Govor.Core/Repositories/Users/IUsersReader.cs index 277c906..53c4a32 100644 --- a/Govor.Core/Repositories/Users/IUsersReader.cs +++ b/Govor.Core/Repositories/Users/IUsersReader.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Core.Repositories.Users; diff --git a/Govor.Core/Repositories/Users/IUsersWriter.cs b/Govor.Core/Repositories/Users/IUsersWriter.cs index edfcbe9..d05c8cf 100644 --- a/Govor.Core/Repositories/Users/IUsersWriter.cs +++ b/Govor.Core/Repositories/Users/IUsersWriter.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; namespace Govor.Core.Repositories.Users; diff --git a/Govor.Data.Tests/Repositories/AdminsRepositoryTests.cs b/Govor.Data.Tests/Repositories/AdminsRepositoryTests.cs index ed6b383..5e95ea6 100644 --- a/Govor.Data.Tests/Repositories/AdminsRepositoryTests.cs +++ b/Govor.Data.Tests/Repositories/AdminsRepositoryTests.cs @@ -1,6 +1,7 @@ using AutoFixture; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Data; using Govor.Data.Repositories; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Data.Tests/Repositories/MediaAttachmentsTests.cs b/Govor.Data.Tests/Repositories/MediaAttachmentsTests.cs index 54331a6..232b62c 100644 --- a/Govor.Data.Tests/Repositories/MediaAttachmentsTests.cs +++ b/Govor.Data.Tests/Repositories/MediaAttachmentsTests.cs @@ -1,6 +1,7 @@ using AutoFixture; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Messages; using Govor.Data; using Govor.Data.Repositories; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Data.Tests/Repositories/MessagesRepositoryTests.cs b/Govor.Data.Tests/Repositories/MessagesRepositoryTests.cs index e0f60e2..7c4a144 100644 --- a/Govor.Data.Tests/Repositories/MessagesRepositoryTests.cs +++ b/Govor.Data.Tests/Repositories/MessagesRepositoryTests.cs @@ -1,6 +1,7 @@ using AutoFixture; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Messages; using Govor.Data; using Govor.Data.Repositories; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Data.Tests/Repositories/UsersRepositoryTests.cs b/Govor.Data.Tests/Repositories/UsersRepositoryTests.cs index 6080460..8a37d46 100644 --- a/Govor.Data.Tests/Repositories/UsersRepositoryTests.cs +++ b/Govor.Data.Tests/Repositories/UsersRepositoryTests.cs @@ -1,6 +1,7 @@ using AutoFixture; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Data; using Govor.Data.Repositories; using Govor.Data.Repositories.Exceptions; diff --git a/Govor.Data/Configurations/AdminConfiguration.cs b/Govor.Data/Configurations/AdminConfiguration.cs index 6d4190f..7f0dfad 100644 --- a/Govor.Data/Configurations/AdminConfiguration.cs +++ b/Govor.Data/Configurations/AdminConfiguration.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/Govor.Data/Configurations/MediaAttachmentsConfiguration.cs b/Govor.Data/Configurations/MediaAttachmentsConfiguration.cs index b0ad220..26fcca3 100644 --- a/Govor.Data/Configurations/MediaAttachmentsConfiguration.cs +++ b/Govor.Data/Configurations/MediaAttachmentsConfiguration.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/Govor.Data/Configurations/MessageReactionConfiguration.cs b/Govor.Data/Configurations/MessageReactionConfiguration.cs index 90080c3..77ca4f2 100644 --- a/Govor.Data/Configurations/MessageReactionConfiguration.cs +++ b/Govor.Data/Configurations/MessageReactionConfiguration.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/Govor.Data/Configurations/MessageViewConfiguration.cs b/Govor.Data/Configurations/MessageViewConfiguration.cs index 7758abc..04d5774 100644 --- a/Govor.Data/Configurations/MessageViewConfiguration.cs +++ b/Govor.Data/Configurations/MessageViewConfiguration.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/Govor.Data/Configurations/MessagesConfiguration.cs b/Govor.Data/Configurations/MessagesConfiguration.cs index f1a973d..5eee870 100644 --- a/Govor.Data/Configurations/MessagesConfiguration.cs +++ b/Govor.Data/Configurations/MessagesConfiguration.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/Govor.Data/Configurations/UserConfiguration.cs b/Govor.Data/Configurations/UserConfiguration.cs index 205442d..fb3bfed 100644 --- a/Govor.Data/Configurations/UserConfiguration.cs +++ b/Govor.Data/Configurations/UserConfiguration.cs @@ -1,4 +1,4 @@ -using Govor.Core.Models; +using Govor.Core.Models.Users; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/Govor.Data/GovorDbContext.cs b/Govor.Data/GovorDbContext.cs index 5414310..040314a 100644 --- a/Govor.Data/GovorDbContext.cs +++ b/Govor.Data/GovorDbContext.cs @@ -1,5 +1,7 @@ using System.Text.RegularExpressions; using Govor.Core.Models; +using Govor.Core.Models.Messages; +using Govor.Core.Models.Users; using Govor.Data.Configurations; using Microsoft.EntityFrameworkCore; diff --git a/Govor.Data/Repositories/AdminsRepository.cs b/Govor.Data/Repositories/AdminsRepository.cs index d6a050c..022c7bb 100644 --- a/Govor.Data/Repositories/AdminsRepository.cs +++ b/Govor.Data/Repositories/AdminsRepository.cs @@ -1,6 +1,7 @@ using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Admins; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore; diff --git a/Govor.Data/Repositories/FriendshipsRepository.cs b/Govor.Data/Repositories/FriendshipsRepository.cs index 7ccf49b..42d6789 100644 --- a/Govor.Data/Repositories/FriendshipsRepository.cs +++ b/Govor.Data/Repositories/FriendshipsRepository.cs @@ -1,6 +1,7 @@ using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Friendships; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore; diff --git a/Govor.Data/Repositories/GroupRepository.cs b/Govor.Data/Repositories/GroupRepository.cs index f765551..6250600 100644 --- a/Govor.Data/Repositories/GroupRepository.cs +++ b/Govor.Data/Repositories/GroupRepository.cs @@ -1,7 +1,7 @@ -using System.Text.RegularExpressions; using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Groups; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore; diff --git a/Govor.Data/Repositories/InvitesRepository.cs b/Govor.Data/Repositories/InvitesRepository.cs index 9e2c2f3..86cc7be 100644 --- a/Govor.Data/Repositories/InvitesRepository.cs +++ b/Govor.Data/Repositories/InvitesRepository.cs @@ -1,6 +1,7 @@ using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Invaites; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore; diff --git a/Govor.Data/Repositories/MediaAttachmentsRepository.cs b/Govor.Data/Repositories/MediaAttachmentsRepository.cs index e60a3b4..7694691 100644 --- a/Govor.Data/Repositories/MediaAttachmentsRepository.cs +++ b/Govor.Data/Repositories/MediaAttachmentsRepository.cs @@ -1,6 +1,6 @@ using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; -using Govor.Core.Models; +using Govor.Core.Models.Messages; using Govor.Core.Repositories.MediasAttachments; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore; diff --git a/Govor.Data/Repositories/MessagesRepository.cs b/Govor.Data/Repositories/MessagesRepository.cs index a6c0a16..5f34c85 100644 --- a/Govor.Data/Repositories/MessagesRepository.cs +++ b/Govor.Data/Repositories/MessagesRepository.cs @@ -1,6 +1,7 @@ using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; +using Govor.Core.Models.Messages; using Govor.Core.Repositories.Messages; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore; diff --git a/Govor.Data/Repositories/UsersRepository.cs b/Govor.Data/Repositories/UsersRepository.cs index b08bbb9..55b3519 100644 --- a/Govor.Data/Repositories/UsersRepository.cs +++ b/Govor.Data/Repositories/UsersRepository.cs @@ -1,7 +1,6 @@ using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; -using Govor.Core.Models; -using Govor.Core.Repositories; +using Govor.Core.Models.Users; using Govor.Core.Repositories.Users; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore;