mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
Add AutoMapper and message response models
Introduced AutoMapper to the API project and registered it in the DI container. Added mapping profiles for core models to DTOs and response objects. Refactored controllers to use AutoMapper for mapping entities to response DTOs. Implemented new response models for messages, media attachments, reactions, and views. Updated MessagesLoader to load messages with related data. Added a migration to support ChatGroupId in messages. Updated dependencies and fixed minor issues in related files.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||
using Govor.Contracts.Responses;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -9,8 +12,85 @@ namespace Govor.API.Controllers;
|
||||
[Route("api/chats")]
|
||||
public class ChatLoadController : Controller
|
||||
{
|
||||
public ChatLoadController(ILogger<ChatLoadController> logger, IMessagesLoader messagesLoader)
|
||||
private readonly ICurrentUserService _currentUser;
|
||||
private readonly ILogger<ChatLoadController> _logger;
|
||||
private readonly IMessagesLoader _messagesLoader;
|
||||
private readonly IMapper _mapper;
|
||||
public ChatLoadController(
|
||||
ILogger<ChatLoadController> logger,
|
||||
IMessagesLoader messagesLoader,
|
||||
ICurrentUserService currentUser,
|
||||
IMapper mapper)
|
||||
{
|
||||
|
||||
_logger = logger;
|
||||
_messagesLoader = messagesLoader;
|
||||
_currentUser = currentUser;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[HttpGet("group-messages")]
|
||||
public async Task<IActionResult> GetChatMessages(
|
||||
[FromQuery] Guid chatId,
|
||||
[FromQuery] Guid? startMessageId,
|
||||
[FromQuery] int pageSize = 20)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _messagesLoader.LoadLastMessagesInChatGroup(
|
||||
chatId,
|
||||
_currentUser.GetCurrentUserId(),
|
||||
startMessageId,
|
||||
pageSize);
|
||||
|
||||
var response = _mapper.Map<List<MessageResponse>>(result);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex.Message);
|
||||
return Unauthorized(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, ex.Message);
|
||||
return StatusCode(500, "Unexpected Error! Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("user-messages")]
|
||||
public async Task<IActionResult> GetUserMessages(
|
||||
[FromQuery] Guid userId,
|
||||
[FromQuery] Guid? startMessageId,
|
||||
[FromQuery] int pageSize = 20)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _messagesLoader.LoadLastMessagesInUserChat(
|
||||
userId,
|
||||
_currentUser.GetCurrentUserId(),
|
||||
startMessageId,
|
||||
pageSize);
|
||||
|
||||
var response = _mapper.Map<List<MessageResponse>>(result);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, ex.Message);
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex.Message);
|
||||
return Unauthorized(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, ex.Message);
|
||||
return StatusCode(500, "Unexpected Error! Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using AutoMapper;
|
||||
using Govor.Application.Interfaces.Friends;
|
||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||
using Govor.Contracts.DTOs;
|
||||
@@ -15,12 +16,15 @@ public class FriendsRequestQueryController : Controller
|
||||
private readonly ILogger<FriendsRequestQueryController> _logger;
|
||||
private readonly IFriendRequestQueryService _friendsService;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public FriendsRequestQueryController(ILogger<FriendsRequestQueryController> logger,
|
||||
IFriendRequestQueryService friendsService,
|
||||
ICurrentUserService currentUserService)
|
||||
ICurrentUserService currentUserService,
|
||||
IMapper mapper)
|
||||
{
|
||||
_logger = logger;
|
||||
_mapper = mapper;
|
||||
_friendsService = friendsService;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
@@ -31,7 +35,9 @@ public class FriendsRequestQueryController : Controller
|
||||
try
|
||||
{
|
||||
var result = await _friendsService.GetIncomingAsync(_currentUserService.GetCurrentUserId());
|
||||
return Ok(BuildFriendshipDtos(result));
|
||||
var response = _mapper.Map<List<FriendshipDto>>(result);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using AutoMapper;
|
||||
using Govor.Application.Exceptions.FriendsService;
|
||||
using Govor.Application.Interfaces.Friends;
|
||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||
@@ -12,14 +13,16 @@ public class FriendshipController : Controller
|
||||
{
|
||||
private readonly ILogger<FriendshipController> _logger;
|
||||
private readonly IFriendshipService _friendsService;
|
||||
//private readonly IUserDtoBuilder _builder;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public FriendshipController(ILogger<FriendshipController> logger,
|
||||
IFriendshipService friendsService,
|
||||
ICurrentUserService currentUserService)
|
||||
ICurrentUserService currentUserService,
|
||||
IMapper mapper)
|
||||
{
|
||||
_logger = logger;
|
||||
_mapper = mapper;
|
||||
_friendsService = friendsService;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
@@ -33,7 +36,10 @@ public class FriendshipController : Controller
|
||||
try
|
||||
{
|
||||
var result = await _friendsService.SearchUsersAsync(query, _currentUserService.GetCurrentUserId());
|
||||
return Ok(BuildUserDtos(result));
|
||||
|
||||
var response = _mapper.Map<List<UserDto>>(result);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
catch (SearchUsersException ex)
|
||||
{
|
||||
@@ -53,7 +59,10 @@ public class FriendshipController : Controller
|
||||
try
|
||||
{
|
||||
var result = await _friendsService.GetFriendsAsync(_currentUserService.GetCurrentUserId());
|
||||
return Ok(BuildUserDtos(result));
|
||||
|
||||
var response = _mapper.Map<List<UserDto>>(result);
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
@@ -66,14 +75,4 @@ public class FriendshipController : Controller
|
||||
return StatusCode(500, new { error = "Internal server error." });
|
||||
}
|
||||
}
|
||||
|
||||
private List<UserDto> BuildUserDtos(IEnumerable<User> users) => users.Select(user => new UserDto
|
||||
{
|
||||
Id = user.Id,
|
||||
Username = user.Username,
|
||||
Description = user.Description,
|
||||
WasOnline = user.WasOnline,
|
||||
IconId = user.IconId
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
@@ -65,6 +65,9 @@ public static class ConfigurationProgramExtensions
|
||||
services.AddScoped<IVerifyFriendship, VerifyFriendship>();
|
||||
services.AddScoped<IUserGroupsService, UserGroupsService>();
|
||||
services.AddScoped<IMessagesLoader, MessagesLoader>();
|
||||
|
||||
// Auto Mapper
|
||||
services.AddAutoMapper(typeof(MappingProfile));
|
||||
}
|
||||
|
||||
public static void AddRepositories(this IServiceCollection services)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using AutoMapper;
|
||||
using Govor.Contracts.DTOs;
|
||||
using Govor.Contracts.Responses;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Messages;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.API.Extensions;
|
||||
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<Message, MessageResponse>();
|
||||
CreateMap<MediaAttachments, MediaAttachmentResponse>();
|
||||
CreateMap<MessageReaction, MessageReactionResponse>();
|
||||
CreateMap<MessageView, MessageViewResponse>();
|
||||
|
||||
CreateMap<User, UserDto>();
|
||||
CreateMap<Friendship, FriendshipDto>();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
|
||||
|
||||
@@ -193,16 +193,25 @@ public class ChatsHub : Hub
|
||||
request.MessageId,
|
||||
request.NewEncryptedContent,
|
||||
DateTime.UtcNow);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _messageCommandService.EditMessageAsync(editMessageParam);
|
||||
|
||||
if(!result.IsSuccess)
|
||||
return LogAndError<MessageEditResponse>(editor, request.MessageId, "Edit message error", result.Exception);
|
||||
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return LogAndError<MessageEditResponse>(editor, request.MessageId, "Edit message error",
|
||||
result.Exception);
|
||||
|
||||
return HubResult<MessageEditResponse>.Ok();
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
return LogAndUnauthorized<MessageEditResponse>(ex, "Unauthorized editing", editor, request.MessageId);
|
||||
}
|
||||
catch (KeyNotFoundException ex)
|
||||
{
|
||||
return LogAndNotFound<MessageEditResponse>(ex, "Message not found", editor, request.MessageId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return LogAndError<MessageEditResponse>(editor, request.MessageId, "Unhandled exception error", ex);
|
||||
|
||||
@@ -96,6 +96,7 @@ builder.Services.AddSwaggerGen(options =>
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
@@ -104,7 +105,7 @@ var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
//app.MapOpenApi();
|
||||
|
||||
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
|
||||
@@ -1,24 +1,52 @@
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Core.Infrastructure.Extensions;
|
||||
using Govor.Core.Models.Messages;
|
||||
using Govor.Core.Repositories.Groups;
|
||||
using Govor.Core.Repositories.Messages;
|
||||
using Govor.Core.Repositories.PrivateChats;
|
||||
using Govor.Data;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Govor.Application.Services.Messages;
|
||||
|
||||
public class MessagesLoader : IMessagesLoader
|
||||
{
|
||||
private IVerifyFriendship _friendship;
|
||||
private IGroupsRepository _groupsRepository;
|
||||
private IMessagesRepository _messagesRepository;
|
||||
private IPrivateChatsRepository _privateChatsRepository;
|
||||
private GovorDbContext _dbContext;
|
||||
|
||||
public MessagesLoader(
|
||||
IGroupsRepository groupsRepository,
|
||||
IPrivateChatsRepository privateChatsRepository,
|
||||
GovorDbContext dbContext)
|
||||
{
|
||||
_groupsRepository = groupsRepository;
|
||||
_privateChatsRepository = privateChatsRepository;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<Message>> LoadLastMessagesInUserChat(Guid userId, Guid currentUser, Guid? startMessageId, int pageSize = 20)
|
||||
{
|
||||
await _friendship.VerifyAsync(userId, currentUser);
|
||||
if(userId == Guid.Empty)
|
||||
throw new ArgumentException("User id cannot be empty");
|
||||
|
||||
if(!_privateChatsRepository.Exist(userId, currentUser))
|
||||
throw new InvalidOperationException("Private chat not found");
|
||||
|
||||
try
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//return await _groups.GetMessages(userId, startMessageId, pageSize);
|
||||
var chat = await _privateChatsRepository.GetByMembersAsync(userId, currentUser);
|
||||
|
||||
return await _dbContext.Messages
|
||||
.AsNoTracking()
|
||||
.Include(m => m.MediaAttachments)
|
||||
.ThenInclude(m => m.MediaFile)
|
||||
.AsSplitQuery()
|
||||
.Where(m => m.RecipientType == RecipientType.User &&
|
||||
m.RecipientId == chat.Id)
|
||||
.Take(pageSize)
|
||||
.ToListOrThrowIfEmpty(new NotFoundException("Messages not found"));
|
||||
}
|
||||
catch (NotFoundException ex)
|
||||
{
|
||||
@@ -28,12 +56,23 @@ public class MessagesLoader : IMessagesLoader
|
||||
|
||||
public async Task<List<Message>> LoadLastMessagesInChatGroup(Guid chatId, Guid currentUser, Guid? startMessageId, int pageSize = 20)
|
||||
{
|
||||
if(chatId == Guid.Empty)
|
||||
throw new ArgumentException("Chat id cannot be empty");
|
||||
|
||||
if(!await _groupsRepository.IsUserMemberOfGroupAsync(currentUser, chatId))
|
||||
throw new UnauthorizedAccessException("You are not in a group.");
|
||||
|
||||
try
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//return await _groups.GetMessages(chatId, startMessageId, pageSize, RecipientType.Group);
|
||||
return await _dbContext.Messages
|
||||
.AsNoTracking()
|
||||
.Include(m => m.MediaAttachments)
|
||||
.ThenInclude(m => m.MediaFile)
|
||||
.AsSplitQuery()
|
||||
.Where(m => m.RecipientType == RecipientType.Group &&
|
||||
m.RecipientId == chatId)
|
||||
.Take(pageSize)
|
||||
.ToListOrThrowIfEmpty(new NotFoundException("Messages not found"));
|
||||
}
|
||||
catch (NotFoundException ex)
|
||||
{
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace Govor.ConsoleClient
|
||||
{
|
||||
class Program
|
||||
{
|
||||
//static string baseUrl = "https://govor-team-govor-88b3.twc1.net";
|
||||
static string baseUrl = "https://localhost:7155";
|
||||
static string baseUrl = "https://govor-team-govor-88b3.twc1.net";
|
||||
//static string baseUrl = "https://localhost:7155";
|
||||
static string? AuthToken = null;
|
||||
static HttpClientService HttpService = new(baseUrl);
|
||||
private static FriendsClient? _friendsClient; // Renamed to avoid conflict with BaseCommand
|
||||
@@ -42,6 +42,12 @@ namespace Govor.ConsoleClient
|
||||
|
||||
static async Task Main()
|
||||
{
|
||||
FriendsHubClient client = new FriendsHubClient($"{baseUrl}/hubs/friends", "eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4NDRjNzkyMi1hNjdlLTRlMzctYWI0MC0wNThlZDE5NzM5NjMiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJBZG1pbiIsImV4cCI6MTc1MjMzMjE2NX0.mGSjSCvguEXkdHqHcbZ3eUH0S8c82kz3XP89potEh1k");
|
||||
|
||||
await client.StartAsync();
|
||||
await client.AcceptRequest(Guid.Parse("3ba77c0c-7522-47be-8e77-ea47bd6c6e69"));
|
||||
|
||||
return;
|
||||
InitializeCommands();
|
||||
BaseCommand.InitializeServices(
|
||||
_friendsClient, // Initially null, will be set by Login/Register commands
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MediaAttachmentResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MessageId { get; set; }
|
||||
public Guid MediaFileId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MessageReactionResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MessageId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string ReactionCode { get; set; } // "❤️", "🔥", "👍", ":custom_emoji:"
|
||||
public DateTime ReactedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Govor.Core.Models.Messages;
|
||||
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MessageResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid SenderId { get; set; }
|
||||
public Guid RecipientId { get; set; } // or GroupId
|
||||
public RecipientType RecipientType { get; set; }
|
||||
public string EncryptedContent { get; set; } = string.Empty;
|
||||
public DateTime SentAt { get; set; }
|
||||
public bool IsEdited { get; set; } = false;
|
||||
public DateTime? EditedAt { get; set; }
|
||||
public Guid? ReplyToMessageId { get; set; }
|
||||
|
||||
public List<MediaAttachmentResponse> MediaAttachments { get; set; } = new();
|
||||
public List<MessageReactionResponse> Reactions { get; set; } = new();
|
||||
public List<MessageViewResponse> MessageViews { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Govor.Contracts.Responses;
|
||||
|
||||
public class MessageViewResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MessageId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public DateTime ViewedAt { get; set; }
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class HubResult<T>
|
||||
};
|
||||
}
|
||||
|
||||
public enum HubResultStatus
|
||||
public enum HubResultStatus : int
|
||||
{
|
||||
Success = 200,
|
||||
Created = 201,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Govor.Core.Models.Messages;
|
||||
|
||||
namespace Govor.Core.Models;
|
||||
|
||||
public class ChatGroup
|
||||
@@ -11,7 +13,8 @@ public class ChatGroup
|
||||
public List<GroupAdmins> Admins { get; set; } = new();
|
||||
public List<GroupMembership> Members { get; set; } = new();
|
||||
public List<GroupInvitation> InviteCodes { get; set; } = new();
|
||||
|
||||
public List<Message> Messages { get; set; } = new();
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
ChatGroup chatGroup = obj as ChatGroup;
|
||||
|
||||
@@ -7,7 +7,7 @@ public class PrivateChat
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserAId { get; set; }
|
||||
public Guid UserBId { get; set; }
|
||||
public List<Message> Messages { get; set; } = new List<Message>();
|
||||
public List<Message> Messages { get; set; } = new();
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Govor.Core.Repositories.Groups;
|
||||
|
||||
namespace Govor.Core.Repositories.PrivateChats;
|
||||
|
||||
public interface IPrivateChatsRepository : IPrivateChatsReader, IPrivateChatsWriter, IPrivateChatsExist
|
||||
|
||||
@@ -0,0 +1,593 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Govor.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Govor.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(GovorDbContext))]
|
||||
[Migration("20250712090733_AddChatGroupIdToMessage")]
|
||||
partial class AddChatGroupIdToMessage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("varchar(500)");
|
||||
|
||||
b.Property<Guid>("ImageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsChannel")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsPrivate")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ChatGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Friendship", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("AddresseeId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RequesterId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AddresseeId");
|
||||
|
||||
b.HasIndex("RequesterId");
|
||||
|
||||
b.ToTable("Friendships");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.GroupAdmins", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GroupId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("GroupAdmins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.GroupInvitation", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("varchar(500)");
|
||||
|
||||
b.Property<DateTime>("EndDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("GroupId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("InvitationCode")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)");
|
||||
|
||||
b.Property<int>("MaxParticipants")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid>("UserMakerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.HasIndex("UserMakerId");
|
||||
|
||||
b.ToTable("GroupInvitations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.GroupMembership", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GroupId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("InvitationId")
|
||||
.IsRequired()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsBanned")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.HasIndex("InvitationId");
|
||||
|
||||
b.ToTable("GroupMemberships");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Invitation", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("EndDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsAdmin")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("MaxParticipants")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Invitations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("MediaType")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("MineType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MediaFileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MessageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MediaFileId");
|
||||
|
||||
b.HasIndex("MessageId");
|
||||
|
||||
b.ToTable("MediaAttachments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("ChatGroupId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime?>("EditedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("EncryptedContent")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("IsEdited")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<Guid?>("PrivateChatId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RecipientId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("RecipientType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("ReplyToMessageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("SenderId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("SentAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ChatGroupId");
|
||||
|
||||
b.HasIndex("PrivateChatId");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageReaction", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MessageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("ReactedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("ReactionCode")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.HasIndex("MessageId", "UserId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("MessageReactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageView", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MessageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("ViewedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MessageId", "UserId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("MessageViews");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.PrivateChat", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("UserAId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("UserBId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PrivateChats");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateOnly>("CreatedOn")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("IconId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("InviteId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("WasOnline")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("InviteId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Friendship", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Users.User", "Addressee")
|
||||
.WithMany("ReceivedFriendRequests")
|
||||
.HasForeignKey("AddresseeId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.Users.User", "Requester")
|
||||
.WithMany("SentFriendRequests")
|
||||
.HasForeignKey("RequesterId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Addressee");
|
||||
|
||||
b.Navigation("Requester");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.GroupAdmins", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.ChatGroup", null)
|
||||
.WithMany("Admins")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.GroupInvitation", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.ChatGroup", null)
|
||||
.WithMany("InviteCodes")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.Users.User", "UserMaker")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserMakerId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("UserMaker");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.GroupMembership", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.ChatGroup", null)
|
||||
.WithMany("Members")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.GroupInvitation", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("InvitationId")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.MediaFile", "MediaFile")
|
||||
.WithMany()
|
||||
.HasForeignKey("MediaFileId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.Messages.Message", "Message")
|
||||
.WithMany("MediaAttachments")
|
||||
.HasForeignKey("MessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("MediaFile");
|
||||
|
||||
b.Navigation("Message");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.ChatGroup", null)
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("ChatGroupId");
|
||||
|
||||
b.HasOne("Govor.Core.Models.PrivateChat", null)
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("PrivateChatId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageReaction", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Messages.Message", "Message")
|
||||
.WithMany("Reactions")
|
||||
.HasForeignKey("MessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.Users.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Message");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageView", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Messages.Message", null)
|
||||
.WithMany("MessageViews")
|
||||
.HasForeignKey("MessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Users.User", "User")
|
||||
.WithOne()
|
||||
.HasForeignKey("Govor.Core.Models.Users.Admin", "UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Invitation", "Invite")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("InviteId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Invite");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
||||
{
|
||||
b.Navigation("Admins");
|
||||
|
||||
b.Navigation("InviteCodes");
|
||||
|
||||
b.Navigation("Members");
|
||||
|
||||
b.Navigation("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Invitation", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
|
||||
{
|
||||
b.Navigation("MediaAttachments");
|
||||
|
||||
b.Navigation("MessageViews");
|
||||
|
||||
b.Navigation("Reactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.PrivateChat", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||
{
|
||||
b.Navigation("ReceivedFriendRequests");
|
||||
|
||||
b.Navigation("SentFriendRequests");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Govor.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddChatGroupIdToMessage : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ChatGroupId",
|
||||
table: "Messages",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Messages_ChatGroupId",
|
||||
table: "Messages",
|
||||
column: "ChatGroupId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Messages_ChatGroups_ChatGroupId",
|
||||
table: "Messages",
|
||||
column: "ChatGroupId",
|
||||
principalTable: "ChatGroups",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Messages_ChatGroups_ChatGroupId",
|
||||
table: "Messages");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Messages_ChatGroupId",
|
||||
table: "Messages");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ChatGroupId",
|
||||
table: "Messages");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,16 +22,6 @@ namespace Govor.Data.Migrations
|
||||
|
||||
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Admin", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -207,27 +197,6 @@ namespace Govor.Data.Migrations
|
||||
b.ToTable("Invitations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MediaAttachments", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MediaFileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MessageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MediaFileId");
|
||||
|
||||
b.HasIndex("MessageId");
|
||||
|
||||
b.ToTable("MediaAttachments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MediaFile", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -255,12 +224,36 @@ namespace Govor.Data.Migrations
|
||||
b.ToTable("MediaFiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Message", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MediaFileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("MessageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MediaFileId");
|
||||
|
||||
b.HasIndex("MessageId");
|
||||
|
||||
b.ToTable("MediaAttachments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("ChatGroupId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime?>("EditedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
@@ -291,12 +284,14 @@ namespace Govor.Data.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ChatGroupId");
|
||||
|
||||
b.HasIndex("PrivateChatId");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MessageReaction", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageReaction", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -326,7 +321,7 @@ namespace Govor.Data.Migrations
|
||||
b.ToTable("MessageReactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MessageView", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageView", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -366,7 +361,17 @@ namespace Govor.Data.Migrations
|
||||
b.ToTable("PrivateChats");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.User", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -403,26 +408,15 @@ namespace Govor.Data.Migrations
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Admin", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.User", "User")
|
||||
.WithOne()
|
||||
.HasForeignKey("Govor.Core.Models.Admin", "UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Friendship", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.User", "Addressee")
|
||||
b.HasOne("Govor.Core.Models.Users.User", "Addressee")
|
||||
.WithMany("ReceivedFriendRequests")
|
||||
.HasForeignKey("AddresseeId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.User", "Requester")
|
||||
b.HasOne("Govor.Core.Models.Users.User", "Requester")
|
||||
.WithMany("SentFriendRequests")
|
||||
.HasForeignKey("RequesterId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
@@ -450,7 +444,7 @@ namespace Govor.Data.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.User", "UserMaker")
|
||||
b.HasOne("Govor.Core.Models.Users.User", "UserMaker")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserMakerId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
@@ -474,7 +468,7 @@ namespace Govor.Data.Migrations
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MediaAttachments", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.MediaFile", "MediaFile")
|
||||
.WithMany()
|
||||
@@ -482,7 +476,7 @@ namespace Govor.Data.Migrations
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.Message", "Message")
|
||||
b.HasOne("Govor.Core.Models.Messages.Message", "Message")
|
||||
.WithMany("MediaAttachments")
|
||||
.HasForeignKey("MessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
@@ -493,22 +487,26 @@ namespace Govor.Data.Migrations
|
||||
b.Navigation("Message");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Message", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.ChatGroup", null)
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("ChatGroupId");
|
||||
|
||||
b.HasOne("Govor.Core.Models.PrivateChat", null)
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("PrivateChatId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MessageReaction", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageReaction", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Message", "Message")
|
||||
b.HasOne("Govor.Core.Models.Messages.Message", "Message")
|
||||
.WithMany("Reactions")
|
||||
.HasForeignKey("MessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Govor.Core.Models.User", "User")
|
||||
b.HasOne("Govor.Core.Models.Users.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
@@ -519,16 +517,27 @@ namespace Govor.Data.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.MessageView", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.MessageView", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Message", null)
|
||||
b.HasOne("Govor.Core.Models.Messages.Message", null)
|
||||
.WithMany("MessageViews")
|
||||
.HasForeignKey("MessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.User", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Users.User", "User")
|
||||
.WithOne()
|
||||
.HasForeignKey("Govor.Core.Models.Users.Admin", "UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||
{
|
||||
b.HasOne("Govor.Core.Models.Invitation", "Invite")
|
||||
.WithMany("Users")
|
||||
@@ -546,6 +555,8 @@ namespace Govor.Data.Migrations
|
||||
b.Navigation("InviteCodes");
|
||||
|
||||
b.Navigation("Members");
|
||||
|
||||
b.Navigation("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Invitation", b =>
|
||||
@@ -553,7 +564,7 @@ namespace Govor.Data.Migrations
|
||||
b.Navigation("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.Message", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
|
||||
{
|
||||
b.Navigation("MediaAttachments");
|
||||
|
||||
@@ -567,7 +578,7 @@ namespace Govor.Data.Migrations
|
||||
b.Navigation("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Core.Models.User", b =>
|
||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||
{
|
||||
b.Navigation("ReceivedFriendRequests");
|
||||
|
||||
|
||||
@@ -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.PrivateChats;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
Reference in New Issue
Block a user