mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
new app server and database + added hub and controller of user profile
This commit is contained in:
@@ -3,7 +3,6 @@ using Govor.API.Controllers;
|
|||||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||||
using Govor.Application.Interfaces.UserSession;
|
using Govor.Application.Interfaces.UserSession;
|
||||||
using Govor.Contracts.DTOs;
|
using Govor.Contracts.DTOs;
|
||||||
using Govor.Core.Models;
|
|
||||||
using Govor.Core.Models.Users;
|
using Govor.Core.Models.Users;
|
||||||
using Govor.Data.Repositories.Exceptions;
|
using Govor.Data.Repositories.Exceptions;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -18,6 +17,7 @@ public class SessionControllerTests
|
|||||||
{
|
{
|
||||||
private Mock<ILogger<SessionController>> _loggerMock;
|
private Mock<ILogger<SessionController>> _loggerMock;
|
||||||
private Mock<ICurrentUserService> _currentUserServiceMock;
|
private Mock<ICurrentUserService> _currentUserServiceMock;
|
||||||
|
private Mock<ICurrentUserSessionService> _currentUserSessionServiceMock;
|
||||||
private Mock<IUserSessionReader> _userSessionReaderMock;
|
private Mock<IUserSessionReader> _userSessionReaderMock;
|
||||||
private Mock<IUserSessionRevoker> _userSessionRevokerMock;
|
private Mock<IUserSessionRevoker> _userSessionRevokerMock;
|
||||||
private Mock<IMapper> _mapperMock;
|
private Mock<IMapper> _mapperMock;
|
||||||
@@ -28,17 +28,20 @@ public class SessionControllerTests
|
|||||||
{
|
{
|
||||||
_loggerMock = new Mock<ILogger<SessionController>>();
|
_loggerMock = new Mock<ILogger<SessionController>>();
|
||||||
_currentUserServiceMock = new Mock<ICurrentUserService>();
|
_currentUserServiceMock = new Mock<ICurrentUserService>();
|
||||||
|
_currentUserSessionServiceMock = new Mock<ICurrentUserSessionService>();
|
||||||
_userSessionReaderMock = new Mock<IUserSessionReader>();
|
_userSessionReaderMock = new Mock<IUserSessionReader>();
|
||||||
_userSessionRevokerMock = new Mock<IUserSessionRevoker>();
|
_userSessionRevokerMock = new Mock<IUserSessionRevoker>();
|
||||||
_mapperMock = new Mock<IMapper>();
|
_mapperMock = new Mock<IMapper>();
|
||||||
_controller = new SessionController(
|
_controller = new SessionController(
|
||||||
_loggerMock.Object,
|
_loggerMock.Object,
|
||||||
_currentUserServiceMock.Object,
|
_currentUserServiceMock.Object,
|
||||||
|
_currentUserSessionServiceMock.Object,
|
||||||
_userSessionReaderMock.Object,
|
_userSessionReaderMock.Object,
|
||||||
_userSessionRevokerMock.Object,
|
_userSessionRevokerMock.Object,
|
||||||
_mapperMock.Object);
|
_mapperMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region GetAllSessions
|
||||||
[Test]
|
[Test]
|
||||||
public async Task GetAllSessions_Successful_ReturnsOkWithMappedSessions()
|
public async Task GetAllSessions_Successful_ReturnsOkWithMappedSessions()
|
||||||
{
|
{
|
||||||
@@ -106,7 +109,9 @@ public class SessionControllerTests
|
|||||||
exception,
|
exception,
|
||||||
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CloseSession
|
||||||
[Test]
|
[Test]
|
||||||
public async Task CloseSession_ValidSessionId_ReturnsOk()
|
public async Task CloseSession_ValidSessionId_ReturnsOk()
|
||||||
{
|
{
|
||||||
@@ -213,7 +218,105 @@ public class SessionControllerTests
|
|||||||
exception,
|
exception,
|
||||||
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CloseCurrentSession
|
||||||
|
[Test]
|
||||||
|
public async Task CloseCurrentSession_ValidSessionIdAndUserId_ReturnsOk()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var userId = Guid.NewGuid();
|
||||||
|
var sessionId = Guid.NewGuid();
|
||||||
|
_currentUserServiceMock.Setup(s => s.GetCurrentUserId()).Returns(userId);
|
||||||
|
_currentUserSessionServiceMock.Setup(s => s.GetUserSessionId()).Returns(sessionId);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.CloseCurrent();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.TypeOf<OkResult>());
|
||||||
|
_userSessionRevokerMock.Verify(r => r.CloseSessionByIdAsync(sessionId, userId), Times.Once());
|
||||||
|
_loggerMock.VerifyNoOtherCalls();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task CloseCurrentSession_UnauthorizedAccess_ReturnsForbid()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var userId = Guid.NewGuid();
|
||||||
|
var sessionId = Guid.NewGuid();
|
||||||
|
var exception = new UnauthorizedAccessException("Unauthorized");
|
||||||
|
_currentUserServiceMock.Setup(s => s.GetCurrentUserId()).Returns(userId);
|
||||||
|
_currentUserSessionServiceMock.Setup(s => s.GetUserSessionId()).Returns(sessionId);
|
||||||
|
_userSessionRevokerMock.Setup(r => r.CloseSessionByIdAsync(sessionId, userId)).ThrowsAsync(exception);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.CloseCurrent();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.TypeOf<ForbidResult>());
|
||||||
|
_loggerMock.Verify(l => l.Log(
|
||||||
|
LogLevel.Warning,
|
||||||
|
It.IsAny<EventId>(),
|
||||||
|
It.IsAny<It.IsAnyType>(),
|
||||||
|
exception,
|
||||||
|
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task CloseCurrentSession_NotFound_ReturnsNotFound()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var userId = Guid.NewGuid();
|
||||||
|
var sessionId = Guid.NewGuid();
|
||||||
|
var exception = new NotFoundException("Session not found");
|
||||||
|
_currentUserServiceMock.Setup(s => s.GetCurrentUserId()).Returns(userId);
|
||||||
|
_currentUserSessionServiceMock.Setup(s => s.GetUserSessionId()).Returns(sessionId);
|
||||||
|
_userSessionRevokerMock.Setup(r => r.CloseSessionByIdAsync(sessionId, userId)).ThrowsAsync(exception);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.CloseCurrent();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.TypeOf<NotFoundObjectResult>());
|
||||||
|
var notFoundResult = result as NotFoundObjectResult;
|
||||||
|
Assert.That(notFoundResult.Value, Is.EqualTo("Session not found"));
|
||||||
|
_loggerMock.Verify(l => l.Log(
|
||||||
|
LogLevel.Warning,
|
||||||
|
It.IsAny<EventId>(),
|
||||||
|
It.IsAny<It.IsAnyType>(),
|
||||||
|
exception,
|
||||||
|
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task CloseCurrentSession_InvalidOperation_ReturnsBadRequest()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var userId = Guid.NewGuid();
|
||||||
|
var sessionId = Guid.NewGuid();
|
||||||
|
var exception = new InvalidOperationException("Invalid operation");
|
||||||
|
_currentUserServiceMock.Setup(s => s.GetCurrentUserId()).Returns(userId);
|
||||||
|
_currentUserSessionServiceMock.Setup(s => s.GetUserSessionId()).Returns(sessionId);
|
||||||
|
_userSessionRevokerMock.Setup(r => r.CloseSessionByIdAsync(sessionId, userId)).ThrowsAsync(exception);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.CloseCurrent();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.TypeOf<BadRequestObjectResult>());
|
||||||
|
var badRequestResult = result as BadRequestObjectResult;
|
||||||
|
Assert.That(badRequestResult.Value, Is.EqualTo("Invalid operation"));
|
||||||
|
_loggerMock.Verify(l => l.Log(
|
||||||
|
LogLevel.Error,
|
||||||
|
It.IsAny<EventId>(),
|
||||||
|
It.IsAny<It.IsAnyType>(),
|
||||||
|
exception,
|
||||||
|
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CloseAllSessions
|
||||||
[Test]
|
[Test]
|
||||||
public async Task CloseAllSessions_Successful_ReturnsOk()
|
public async Task CloseAllSessions_Successful_ReturnsOk()
|
||||||
{
|
{
|
||||||
@@ -276,4 +379,5 @@ public class SessionControllerTests
|
|||||||
exception,
|
exception,
|
||||||
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||||
<PackageReference Include="Moq" Version="4.20.72" />
|
<PackageReference Include="Moq" Version="4.20.72" />
|
||||||
<PackageReference Include="NUnit" Version="4.4.0-beta.1" />
|
<PackageReference Include="NUnit" Version="4.4.0-beta.1" />
|
||||||
|
<PackageReference Include="NUnit.Analyzers" Version="4.4.0"/>
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,145 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Govor.API.Controllers;
|
||||||
|
using Govor.Application.Interfaces;
|
||||||
|
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||||
|
using Govor.Application.Interfaces.Medias;
|
||||||
|
using Govor.Application.Profiles;
|
||||||
|
using Govor.Contracts.DTOs;
|
||||||
|
using Govor.Data.Repositories.Exceptions;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Moq;
|
||||||
|
|
||||||
|
namespace Govor.API.Tests;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class ProfileControllerTests
|
||||||
|
{
|
||||||
|
private Mock<ILogger<ProfileController>> _mockLogger = null!;
|
||||||
|
private Mock<IMediaService> _mockMediaService = null!;
|
||||||
|
private Mock<IProfileService> _mockProfileService = null!;
|
||||||
|
private Mock<ICurrentUserService> _mockCurrentUserService = null!;
|
||||||
|
private Mock<IMapper> _mockMapper = null!;
|
||||||
|
private ProfileController _controller = null!;
|
||||||
|
|
||||||
|
private Guid _userId;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
_mockLogger = new Mock<ILogger<ProfileController>>();
|
||||||
|
_mockMediaService = new Mock<IMediaService>();
|
||||||
|
_mockProfileService = new Mock<IProfileService>();
|
||||||
|
_mockCurrentUserService = new Mock<ICurrentUserService>();
|
||||||
|
_mockMapper = new Mock<IMapper>();
|
||||||
|
|
||||||
|
_controller = new ProfileController(
|
||||||
|
_mockLogger.Object,
|
||||||
|
_mockMediaService.Object,
|
||||||
|
_mockProfileService.Object,
|
||||||
|
_mockCurrentUserService.Object,
|
||||||
|
_mockMapper.Object);
|
||||||
|
|
||||||
|
_userId = Guid.NewGuid();
|
||||||
|
_mockCurrentUserService.Setup(x => x.GetCurrentUserId()).Returns(_userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task DowloadProfile_ReturnsOk_WhenProfileExists()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var userProfile = new UserProfile
|
||||||
|
{
|
||||||
|
Id = _userId,
|
||||||
|
Username = "test_user",
|
||||||
|
Description = "test description",
|
||||||
|
IconId = Guid.NewGuid()
|
||||||
|
};
|
||||||
|
|
||||||
|
var userProfileDto = new UserProfileDto
|
||||||
|
{
|
||||||
|
Id = _userId,
|
||||||
|
Username = "test_user",
|
||||||
|
Description = "test description",
|
||||||
|
IconId = userProfile.IconId
|
||||||
|
};
|
||||||
|
|
||||||
|
_mockProfileService.Setup(s => s.GetUserProfileAsync(_userId))
|
||||||
|
.ReturnsAsync(userProfile);
|
||||||
|
|
||||||
|
_mockMapper.Setup(m => m.Map<UserProfileDto>(userProfile))
|
||||||
|
.Returns(userProfileDto);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.DowloadProfile();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var okResult = result as OkObjectResult;
|
||||||
|
Assert.That(okResult, Is.Not.Null);
|
||||||
|
Assert.That(okResult!.StatusCode, Is.EqualTo(200));
|
||||||
|
Assert.That(okResult.Value, Is.EqualTo(userProfileDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task DowloadProfile_ReturnsNotFound_WhenProfileIsNull()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockProfileService.Setup(s => s.GetUserProfileAsync(_userId))
|
||||||
|
.ReturnsAsync((UserProfile?)null);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.DowloadProfile();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var notFoundResult = result as NotFoundObjectResult;
|
||||||
|
Assert.That(notFoundResult, Is.Not.Null);
|
||||||
|
Assert.That(notFoundResult!.Value, Is.EqualTo("Profile not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task DowloadProfile_ReturnsForbid_WhenUnauthorizedAccessExceptionThrown()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockProfileService.Setup(s => s.GetUserProfileAsync(_userId))
|
||||||
|
.ThrowsAsync(new UnauthorizedAccessException("Access denied"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.DowloadProfile();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.InstanceOf<ForbidResult>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task DowloadProfile_ReturnsBadRequest_WhenNotFoundExceptionThrown()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockProfileService.Setup(s => s.GetUserProfileAsync(_userId))
|
||||||
|
.ThrowsAsync(new NotFoundException("User not found"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.DowloadProfile();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var badRequest = result as BadRequestObjectResult;
|
||||||
|
Assert.That(badRequest, Is.Not.Null);
|
||||||
|
Assert.That(badRequest!.Value, Is.EqualTo("User not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task DowloadProfile_Returns500_WhenUnexpectedExceptionThrown()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockProfileService.Setup(s => s.GetUserProfileAsync(_userId))
|
||||||
|
.ThrowsAsync(new Exception("Unexpected error"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _controller.DowloadProfile();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var objectResult = result as ObjectResult;
|
||||||
|
Assert.That(objectResult, Is.Not.Null);
|
||||||
|
Assert.That(objectResult!.StatusCode, Is.EqualTo(500));
|
||||||
|
Assert.That(objectResult.Value, Is.EqualTo("Unexpected Error! Please try again later."));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -97,6 +97,8 @@ public static class ConfigurationProgramExtensions
|
|||||||
services.AddScoped<ISessionKeyAttacher, SessionKeyAttacher>();
|
services.AddScoped<ISessionKeyAttacher, SessionKeyAttacher>();
|
||||||
services.AddScoped<ISessionKeysReader, SessionKeysReader>();
|
services.AddScoped<ISessionKeysReader, SessionKeysReader>();
|
||||||
services.AddScoped<IOneTimePreKeysRotator, OneTimePreKeysRotator>();
|
services.AddScoped<IOneTimePreKeysRotator, OneTimePreKeysRotator>();
|
||||||
|
|
||||||
|
services.AddScoped<IProfileService, ProfileService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddRepositories(this IServiceCollection services)
|
public static void AddRepositories(this IServiceCollection services)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Govor.API.Extensions.Mapping;
|
using Govor.API.Extensions.Mapping;
|
||||||
|
using Govor.Application.Profiles;
|
||||||
using Govor.Contracts.DTOs;
|
using Govor.Contracts.DTOs;
|
||||||
using Govor.Contracts.Responses;
|
using Govor.Contracts.Responses;
|
||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
@@ -23,5 +24,7 @@ public class MappingProfile : Profile
|
|||||||
CreateMap<Friendship, FriendshipDto>();
|
CreateMap<Friendship, FriendshipDto>();
|
||||||
|
|
||||||
CreateMap<UserSession, SessionDto>();
|
CreateMap<UserSession, SessionDto>();
|
||||||
|
|
||||||
|
CreateMap<UserProfile, UserProfileDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ namespace Govor.API.Controllers.AdminStuff;
|
|||||||
|
|
||||||
[Route("api/admin/[controller]")]
|
[Route("api/admin/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize(Roles = "Admin")]
|
//[Authorize(Roles = "Admin")]
|
||||||
public class InviteUserController : Controller
|
public class InviteUserController : Controller
|
||||||
{
|
{
|
||||||
private readonly IInvitesRepository _repository;
|
private readonly IInvitesRepository _repository;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||||
using Govor.Application.Interfaces.Medias;
|
using Govor.Application.Interfaces.Medias;
|
||||||
using Govor.Contracts.Requests;
|
using Govor.Contracts.Requests;
|
||||||
|
using Govor.Core.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ public class MediaController : Controller
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
byte[] fileBytes = await ReadFileAsync(request.FromFile);
|
byte[] fileBytes = await ReadFileAsync(request.FromFile);
|
||||||
|
|
||||||
var media = new Media(
|
var media = new Media(
|
||||||
_currentUserService.GetCurrentUserId(),
|
_currentUserService.GetCurrentUserId(),
|
||||||
DateTime.UtcNow,
|
DateTime.UtcNow,
|
||||||
@@ -55,8 +56,15 @@ public class MediaController : Controller
|
|||||||
fileBytes,
|
fileBytes,
|
||||||
request.Type,
|
request.Type,
|
||||||
request.MimeType,
|
request.MimeType,
|
||||||
request.EncryptedKey
|
request.EncryptedKey,
|
||||||
);
|
request.OwnerType,
|
||||||
|
null)
|
||||||
|
{
|
||||||
|
OwnerType = request.OwnerType,
|
||||||
|
OwnerId = request.OwnerType == MediaOwnerType.Avatar
|
||||||
|
? _currentUserService.GetCurrentUserId()
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
|
||||||
var result = await _mediaService.UploadMediaAsync(media);
|
var result = await _mediaService.UploadMediaAsync(media);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Govor.Application.Interfaces;
|
||||||
|
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||||
|
using Govor.Application.Interfaces.Medias;
|
||||||
|
using Govor.Contracts.DTOs;
|
||||||
|
using Govor.Data.Repositories.Exceptions;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Govor.API.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/profile")]
|
||||||
|
[Authorize(Roles = "Admin,User")]
|
||||||
|
public class ProfileController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<ProfileController> _logger;
|
||||||
|
private readonly IMediaService _mediaService;
|
||||||
|
private readonly IProfileService _profileService;
|
||||||
|
private readonly ICurrentUserService _currentUserService;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public ProfileController(
|
||||||
|
ILogger<ProfileController> logger,
|
||||||
|
IMediaService mediaService,
|
||||||
|
IProfileService profileService,
|
||||||
|
ICurrentUserService currentUserService,
|
||||||
|
IMapper mapper)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_mediaService = mediaService;
|
||||||
|
_profileService = profileService;
|
||||||
|
_currentUserService = currentUserService;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("dowload")]
|
||||||
|
public async Task<IActionResult> DowloadProfile()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var userId = _currentUserService.GetCurrentUserId();
|
||||||
|
var user = await _profileService.GetUserProfileAsync(userId);
|
||||||
|
|
||||||
|
if (user is null)
|
||||||
|
return NotFound("Profile not found");
|
||||||
|
|
||||||
|
var dto = _mapper.Map<UserProfileDto>(user);
|
||||||
|
return Ok(dto);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex.Message);
|
||||||
|
return Forbid(ex.Message);
|
||||||
|
}
|
||||||
|
catch (NotFoundException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, ex.Message);
|
||||||
|
return BadRequest(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, ex.Message);
|
||||||
|
return StatusCode(500, "Unexpected Error! Please try again later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ public class SessionController : Controller
|
|||||||
{
|
{
|
||||||
private readonly ILogger<SessionController> _logger;
|
private readonly ILogger<SessionController> _logger;
|
||||||
private readonly ICurrentUserService _currentUserService;
|
private readonly ICurrentUserService _currentUserService;
|
||||||
|
private readonly ICurrentUserSessionService _currentUserSessionService;
|
||||||
private readonly IUserSessionReader _userSessionReader;
|
private readonly IUserSessionReader _userSessionReader;
|
||||||
private readonly IUserSessionRevoker _userSessionRevoker;
|
private readonly IUserSessionRevoker _userSessionRevoker;
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
@@ -22,12 +23,14 @@ public class SessionController : Controller
|
|||||||
public SessionController(
|
public SessionController(
|
||||||
ILogger<SessionController> logger,
|
ILogger<SessionController> logger,
|
||||||
ICurrentUserService currentUserService,
|
ICurrentUserService currentUserService,
|
||||||
|
ICurrentUserSessionService currentUserSessionService,
|
||||||
IUserSessionReader userSessionReader,
|
IUserSessionReader userSessionReader,
|
||||||
IUserSessionRevoker userSessionRevoker,
|
IUserSessionRevoker userSessionRevoker,
|
||||||
IMapper mapper)
|
IMapper mapper)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_currentUserService = currentUserService;
|
_currentUserService = currentUserService;
|
||||||
|
_currentUserSessionService = currentUserSessionService;
|
||||||
_userSessionReader = userSessionReader;
|
_userSessionReader = userSessionReader;
|
||||||
_userSessionRevoker = userSessionRevoker;
|
_userSessionRevoker = userSessionRevoker;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
@@ -86,7 +89,40 @@ public class SessionController : Controller
|
|||||||
return StatusCode(500, "Unexpected Error! Please try again later.");
|
return StatusCode(500, "Unexpected Error! Please try again later.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("close")]
|
||||||
|
public async Task<IActionResult> CloseCurrent()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _userSessionRevoker.CloseSessionByIdAsync(
|
||||||
|
_currentUserSessionService.GetUserSessionId(),
|
||||||
|
_currentUserService.GetCurrentUserId());
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, ex.Message);
|
||||||
|
return BadRequest(ex.Message);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, ex.Message);
|
||||||
|
return Forbid(ex.Message);
|
||||||
|
}
|
||||||
|
catch (NotFoundException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, ex.Message);
|
||||||
|
return NotFound(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, ex.Message);
|
||||||
|
return StatusCode(500, "Unexpected Error! Please try again later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpDelete("close/all")]
|
[HttpDelete("close/all")]
|
||||||
public async Task<IActionResult> CloseAllSessions()
|
public async Task<IActionResult> CloseAllSessions()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class ChatsHub : Hub
|
|||||||
await base.OnConnectedAsync();
|
await base.OnConnectedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task OnDisconnectedAsync(Exception? exception)
|
public override async Task OnDisconnectedAsync(Exception exception)
|
||||||
{
|
{
|
||||||
var userId = _userAccessor.GetUserId(Context, true);
|
var userId = _userAccessor.GetUserId(Context, true);
|
||||||
if (userId != Guid.Empty)
|
if (userId != Guid.Empty)
|
||||||
@@ -87,7 +87,7 @@ public class ChatsHub : Hub
|
|||||||
|
|
||||||
public async Task<HubResult<UserMessageResponse>> Send(MessageRequest request)
|
public async Task<HubResult<UserMessageResponse>> Send(MessageRequest request)
|
||||||
{
|
{
|
||||||
var senderId= _userAccessor.GetUserId(Context);
|
var senderId = _userAccessor.GetUserId(Context);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(request.EncryptedContent) &&
|
if (string.IsNullOrWhiteSpace(request.EncryptedContent) &&
|
||||||
(request.MediaAttachments == null || !request.MediaAttachments.Any()))
|
(request.MediaAttachments == null || !request.MediaAttachments.Any()))
|
||||||
@@ -96,6 +96,12 @@ public class ChatsHub : Hub
|
|||||||
return HubResult<UserMessageResponse>.BadRequest("Message must contain content or media.");
|
return HubResult<UserMessageResponse>.BadRequest("Message must contain content or media.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.EncryptedContent.Length > 50_000)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("User {SenderId} tried to send a too long message (length: {Length})", senderId, request.EncryptedContent.Length);
|
||||||
|
return HubResult<UserMessageResponse>.BadRequest("Message cannot exceed 50,000 characters.");
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Sending message from {SenderId} to {RecipientId} ({RecipientType})",
|
_logger.LogInformation("Sending message from {SenderId} to {RecipientId} ({RecipientType})",
|
||||||
senderId, request.RecipientId, request.RecipientType);
|
senderId, request.RecipientId, request.RecipientType);
|
||||||
|
|
||||||
@@ -143,7 +149,6 @@ public class ChatsHub : Hub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<HubResult<MessageRemovedResponse>> Remove(RemoveMessageRequest request)
|
public async Task<HubResult<MessageRemovedResponse>> Remove(RemoveMessageRequest request)
|
||||||
{
|
{
|
||||||
var removerId = _userAccessor.GetUserId(Context);
|
var removerId = _userAccessor.GetUserId(Context);
|
||||||
@@ -183,7 +188,6 @@ public class ChatsHub : Hub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<HubResult<MessageEditResponse>> Edit(EditMessageRequest request)
|
public async Task<HubResult<MessageEditResponse>> Edit(EditMessageRequest request)
|
||||||
{
|
{
|
||||||
var editor = _userAccessor.GetUserId(Context);
|
var editor = _userAccessor.GetUserId(Context);
|
||||||
@@ -232,7 +236,7 @@ public class ChatsHub : Hub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region common
|
||||||
private UserMessageResponse BuildUserMessageResponse(Message message, Guid? replyToId)
|
private UserMessageResponse BuildUserMessageResponse(Message message, Guid? replyToId)
|
||||||
{
|
{
|
||||||
return new UserMessageResponse
|
return new UserMessageResponse
|
||||||
@@ -305,4 +309,5 @@ public class ChatsHub : Hub
|
|||||||
_logger.LogWarning(ex, "{Msg}: {UserId} -> {TargetId}", msg, userId, targetId);
|
_logger.LogWarning(ex, "{Msg}: {UserId} -> {TargetId}", msg, userId, targetId);
|
||||||
return HubResult<T>.NotFound("Message not found.");
|
return HubResult<T>.NotFound("Message not found.");
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
using Govor.API.Common.SignalR.Helpers;
|
||||||
|
using Govor.Application.Interfaces;
|
||||||
|
using Govor.Contracts.Responses.SignalR;
|
||||||
|
using Govor.Core.Repositories.Groups;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
|
namespace Govor.API.Hubs;
|
||||||
|
|
||||||
|
[Authorize]
|
||||||
|
public class ProfileHub : Hub
|
||||||
|
{
|
||||||
|
private readonly IGroupsRepository _groupsRepository;
|
||||||
|
private readonly IFriendsService _friendsService;
|
||||||
|
private readonly IProfileService _profileService;
|
||||||
|
private readonly IHubUserAccessor _userAccessor;
|
||||||
|
private readonly ILogger<ProfileHub> _logger;
|
||||||
|
|
||||||
|
public ProfileHub(
|
||||||
|
IGroupsRepository groupsRepository,
|
||||||
|
IFriendsService friendsService,
|
||||||
|
IProfileService profileService,
|
||||||
|
IHubUserAccessor userAccessor,
|
||||||
|
ILogger<ProfileHub> logger)
|
||||||
|
{
|
||||||
|
_groupsRepository = groupsRepository;
|
||||||
|
_friendsService = friendsService;
|
||||||
|
_profileService = profileService;
|
||||||
|
_userAccessor = userAccessor;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task OnConnectedAsync()
|
||||||
|
{
|
||||||
|
var userId = _userAccessor.GetUserId(Context);
|
||||||
|
|
||||||
|
// Добавляем в персональную группу
|
||||||
|
await Groups.AddToGroupAsync(Context.ConnectionId, $"user-{userId}");
|
||||||
|
|
||||||
|
// Friends
|
||||||
|
var friendships = await _friendsService.GetFriendsAsync(userId);
|
||||||
|
foreach (var friends in friendships)
|
||||||
|
await Groups.AddToGroupAsync(Context.ConnectionId, $"friends-{friends.Id}");
|
||||||
|
|
||||||
|
// Groups
|
||||||
|
var groups = await _groupsRepository.GetByUserIdAsync(userId);
|
||||||
|
foreach (var group in groups)
|
||||||
|
await Groups.AddToGroupAsync(Context.ConnectionId, $"group-{group.Id}");
|
||||||
|
|
||||||
|
_logger.LogInformation("User {UserId} connected with ConnectionId {ConnectionId}", userId, Context.ConnectionId);
|
||||||
|
|
||||||
|
await base.OnConnectedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task OnDisconnectedAsync(Exception exception)
|
||||||
|
{
|
||||||
|
var userId = _userAccessor.GetUserId(Context);
|
||||||
|
|
||||||
|
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"user-{userId}");
|
||||||
|
// Friends
|
||||||
|
var friendships = await _friendsService.GetFriendsAsync(userId);
|
||||||
|
foreach (var friendship in friendships)
|
||||||
|
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"friends-{friendship.Id}");
|
||||||
|
|
||||||
|
// Groups
|
||||||
|
var groups = await _groupsRepository.GetByUserIdAsync(userId);
|
||||||
|
foreach (var group in groups)
|
||||||
|
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"group-{group.Id}");
|
||||||
|
|
||||||
|
await base.OnDisconnectedAsync(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<HubResult<bool>> SetDescription(string description)
|
||||||
|
{
|
||||||
|
var userId = _userAccessor.GetUserId(Context);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _profileService.SetDescription(description, userId);
|
||||||
|
|
||||||
|
var payload = new { userId, description };
|
||||||
|
|
||||||
|
await NotifyFriendsAndGroupsAsync(userId, "DescriptionUpdated", payload);
|
||||||
|
|
||||||
|
return HubResult<bool>.Ok(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "An error occurred while updating the user's {userId} descripton!", userId);
|
||||||
|
return HubResult<bool>.Error("An unaccounted error on the server!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<HubResult<bool>> SetAvatar(Guid iconId)
|
||||||
|
{
|
||||||
|
var userId = _userAccessor.GetUserId(Context);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (iconId == Guid.Empty)
|
||||||
|
return HubResult<bool>.BadRequest("IconId can't be empty!");
|
||||||
|
|
||||||
|
await _profileService.SetNewIcon(userId, iconId);
|
||||||
|
|
||||||
|
var payload = new { userId, iconId };
|
||||||
|
|
||||||
|
await NotifyFriendsAndGroupsAsync(userId, "AvatarUpdated", payload);
|
||||||
|
|
||||||
|
return HubResult<bool>.Ok(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "An error occurred while updating the user's {userId} avatar {iconId}", userId, iconId);
|
||||||
|
return HubResult<bool>.Error("An unaccounted error on the server!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task NotifyFriendsAndGroupsAsync(Guid userId, string eventName, object payload)
|
||||||
|
{
|
||||||
|
var friendIds = await _friendsService.GetFriendsAsync(userId);
|
||||||
|
var groups = await _groupsRepository.GetByUserIdAsync(userId);
|
||||||
|
|
||||||
|
var groupIds = groups.Select(g => g.Id).ToList();
|
||||||
|
|
||||||
|
await Clients.Group($"user-{userId}") // current user
|
||||||
|
.SendAsync(eventName, payload);
|
||||||
|
|
||||||
|
foreach (var friendId in friendIds)
|
||||||
|
await Clients.Group($"friends-{friendId}")
|
||||||
|
.SendAsync(eventName, payload);
|
||||||
|
|
||||||
|
foreach (var groupId in groupIds)
|
||||||
|
await Clients.Group($"group-{groupId}")
|
||||||
|
.SendAsync(eventName, payload);
|
||||||
|
|
||||||
|
_logger.LogInformation("Sent {EventName} for {UserId} to {Friends} friends and {Groups} groups",
|
||||||
|
eventName, userId, friendIds.Count, groupIds.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ builder.Services.AddCors(options =>
|
|||||||
{
|
{
|
||||||
options.AddPolicy("AllowFrontend", policy =>
|
options.AddPolicy("AllowFrontend", policy =>
|
||||||
{
|
{
|
||||||
policy.WithOrigins("http://localhost:5000", "https://5.129.212.144:5000")
|
policy.WithOrigins("https://localhost:7155", "http://localhost:7155")
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowCredentials();
|
.AllowCredentials();
|
||||||
@@ -126,6 +126,7 @@ app.MapControllers();
|
|||||||
|
|
||||||
app.MapHub<ChatsHub>("/hubs/chats");
|
app.MapHub<ChatsHub>("/hubs/chats");
|
||||||
app.MapHub<FriendsHub>("/hubs/friends");
|
app.MapHub<FriendsHub>("/hubs/friends");
|
||||||
|
app.MapHub<ProfileHub>("/hubs/profiles");
|
||||||
|
|
||||||
app.MapSwagger().RequireAuthorization();
|
app.MapSwagger().RequireAuthorization();
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"GovorDbContext": "Server=147.45.255.215;Port=3306;Database=artemy_DB;User=artemy;Password=LoxHuy))228Goy;"
|
"GovorDbContext": "Host=77.233.213.226;Port=5432;Database=GovorDb;Username=gen_user;Password=co|HPq}JI6D@,t;"
|
||||||
},
|
},
|
||||||
"UseMySql": true,
|
"UseMySql": false,
|
||||||
"AllowedHosts": "govor-team-govor-88b3.twc1.net;localhost;localhost:7155",
|
"AllowedHosts": "govor-team-govor-8ce1.twc1.net;localhost;localhost:7155",
|
||||||
"JwtAccessOption": {
|
"JwtAccessOption": {
|
||||||
"SecretKey": "Q89eY7zP7C4+TqLmHF4kw9xkF1E8Ru4Zpg+up9wFt9g=",
|
"SecretKey": "Q89eY7zP7C4+TqLmHF4kw9xkF1E8Ru4Zpg+up9wFt9g=",
|
||||||
"Minutes": 5
|
"Minutes": 10
|
||||||
},
|
},
|
||||||
"JwtRefreshOption": {
|
"JwtRefreshOption": {
|
||||||
"RefreshTokenLifetimeDays": 30
|
"RefreshTokenLifetimeDays": 30
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 691 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 314 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 480 KiB |
@@ -16,6 +16,8 @@
|
|||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||||
<PackageReference Include="Moq" Version="4.20.72" />
|
<PackageReference Include="Moq" Version="4.20.72" />
|
||||||
<PackageReference Include="NUnit" Version="4.4.0-beta.1" />
|
<PackageReference Include="NUnit" Version="4.4.0-beta.1" />
|
||||||
|
<PackageReference Include="NUnit.Analyzers" Version="4.4.0"/>
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class AccesserToDownloadMediaServiceTests
|
|||||||
_groupId = Guid.NewGuid();
|
_groupId = Guid.NewGuid();
|
||||||
_mediaFileId = Guid.NewGuid();
|
_mediaFileId = Guid.NewGuid();
|
||||||
|
|
||||||
// Seed message from user to other user
|
// Áàçîâîå ñîîáùåíèå è ìåäèà
|
||||||
var message = new Message
|
var message = new Message
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
@@ -40,7 +40,6 @@ public class AccesserToDownloadMediaServiceTests
|
|||||||
RecipientType = RecipientType.User
|
RecipientType = RecipientType.User
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var media = new MediaFile
|
var media = new MediaFile
|
||||||
{
|
{
|
||||||
Id = _mediaFileId,
|
Id = _mediaFileId,
|
||||||
@@ -48,7 +47,9 @@ public class AccesserToDownloadMediaServiceTests
|
|||||||
MineType = "image/png",
|
MineType = "image/png",
|
||||||
MediaType = MediaType.Image,
|
MediaType = MediaType.Image,
|
||||||
UploaderId = _userId,
|
UploaderId = _userId,
|
||||||
DateCreated = DateTime.UtcNow
|
DateCreated = DateTime.UtcNow,
|
||||||
|
OwnerType = MediaOwnerType.Message,
|
||||||
|
OwnerId = message.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
var attachment = new MediaAttachments
|
var attachment = new MediaAttachments
|
||||||
@@ -108,7 +109,9 @@ public class AccesserToDownloadMediaServiceTests
|
|||||||
MineType = "image/png",
|
MineType = "image/png",
|
||||||
MediaType = MediaType.Image,
|
MediaType = MediaType.Image,
|
||||||
UploaderId = _userId,
|
UploaderId = _userId,
|
||||||
DateCreated = DateTime.UtcNow
|
DateCreated = DateTime.UtcNow,
|
||||||
|
OwnerType = MediaOwnerType.Message,
|
||||||
|
OwnerId = groupMessage.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
var attachment = new MediaAttachments
|
var attachment = new MediaAttachments
|
||||||
@@ -144,9 +147,148 @@ public class AccesserToDownloadMediaServiceTests
|
|||||||
Assert.That(result, Is.False);
|
Assert.That(result, Is.False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task HasAccessAsync_ReturnsTrue_ForUserAvatar()
|
||||||
|
{
|
||||||
|
var avatarMedia = new MediaFile
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Url = "/media/avatar.png",
|
||||||
|
MineType = "image/png",
|
||||||
|
MediaType = MediaType.Image,
|
||||||
|
UploaderId = _userId,
|
||||||
|
OwnerType = MediaOwnerType.Avatar,
|
||||||
|
OwnerId = _userId,
|
||||||
|
DateCreated = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
await _dbContext.MediaFiles.AddAsync(avatarMedia);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var result = await _accesser.HasAccessAsync(avatarMedia.Id, _userId);
|
||||||
|
Assert.That(result, Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task HasAccessAsync_ReturnsFalse_ForOtherUserAvatar()
|
||||||
|
{
|
||||||
|
var avatarMedia = new MediaFile
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Url = "/media/avatar2.png",
|
||||||
|
MineType = "image/png",
|
||||||
|
MediaType = MediaType.Image,
|
||||||
|
UploaderId = _otherUserId,
|
||||||
|
OwnerType = MediaOwnerType.Avatar,
|
||||||
|
OwnerId = _otherUserId,
|
||||||
|
DateCreated = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
await _dbContext.MediaFiles.AddAsync(avatarMedia);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var result = await _accesser.HasAccessAsync(avatarMedia.Id, _userId);
|
||||||
|
Assert.That(result, Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task HasAccessAsync_ReturnsTrue_ForGroupAvatarMember()
|
||||||
|
{
|
||||||
|
var groupAvatar = new MediaFile
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Url = "/media/group_avatar.png",
|
||||||
|
MineType = "image/png",
|
||||||
|
MediaType = MediaType.Image,
|
||||||
|
UploaderId = _userId,
|
||||||
|
OwnerType = MediaOwnerType.GroupAvatar,
|
||||||
|
OwnerId = _groupId,
|
||||||
|
DateCreated = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
var membership = new GroupMembership
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
GroupId = _groupId,
|
||||||
|
UserId = _otherUserId
|
||||||
|
};
|
||||||
|
|
||||||
|
await _dbContext.MediaFiles.AddAsync(groupAvatar);
|
||||||
|
await _dbContext.GroupMemberships.AddAsync(membership);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var result = await _accesser.HasAccessAsync(groupAvatar.Id, _otherUserId);
|
||||||
|
Assert.That(result, Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task HasAccessAsync_ReturnsFalse_ForGroupAvatarNonMember()
|
||||||
|
{
|
||||||
|
var groupAvatar = new MediaFile
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Url = "/media/group_avatar2.png",
|
||||||
|
MineType = "image/png",
|
||||||
|
MediaType = MediaType.Image,
|
||||||
|
UploaderId = _userId,
|
||||||
|
OwnerType = MediaOwnerType.GroupAvatar,
|
||||||
|
OwnerId = _groupId,
|
||||||
|
DateCreated = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
await _dbContext.MediaFiles.AddAsync(groupAvatar);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var unrelatedUserId = Guid.NewGuid();
|
||||||
|
var result = await _accesser.HasAccessAsync(groupAvatar.Id, unrelatedUserId);
|
||||||
|
Assert.That(result, Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task HasAccessAsync_ReturnsTrue_ForSystemMedia()
|
||||||
|
{
|
||||||
|
var systemMedia = new MediaFile
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Url = "/media/system.png",
|
||||||
|
MineType = "image/png",
|
||||||
|
MediaType = MediaType.Image,
|
||||||
|
UploaderId = _userId,
|
||||||
|
OwnerType = MediaOwnerType.System,
|
||||||
|
DateCreated = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
await _dbContext.MediaFiles.AddAsync(systemMedia);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var result = await _accesser.HasAccessAsync(systemMedia.Id, Guid.NewGuid());
|
||||||
|
Assert.That(result, Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task HasAccessAsync_ReturnsFalse_ForUnknownOwnerType()
|
||||||
|
{
|
||||||
|
var unknownMedia = new MediaFile
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Url = "/media/unknown.png",
|
||||||
|
MineType = "image/png",
|
||||||
|
MediaType = MediaType.Image,
|
||||||
|
UploaderId = _userId,
|
||||||
|
OwnerType = (MediaOwnerType)999, // íåèçâåñòíûé òèï
|
||||||
|
DateCreated = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
await _dbContext.MediaFiles.AddAsync(unknownMedia);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var result = await _accesser.HasAccessAsync(unknownMedia.Id, _userId);
|
||||||
|
Assert.That(result, Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
[TearDown]
|
[TearDown]
|
||||||
public void TearDown()
|
public void TearDown()
|
||||||
{
|
{
|
||||||
_dbContext.Dispose();
|
_dbContext.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Govor.Application.Exceptions.VerifyFriendship;
|
using Govor.Application.Exceptions.VerifyFriendship;
|
||||||
using Govor.Application.Interfaces;
|
using Govor.Application.Interfaces;
|
||||||
|
using Govor.Application.Interfaces.Medias;
|
||||||
using Govor.Application.Interfaces.Messages.Parameters;
|
using Govor.Application.Interfaces.Messages.Parameters;
|
||||||
using Govor.Application.Services.Messages;
|
using Govor.Application.Services.Messages;
|
||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
@@ -22,6 +23,7 @@ public class MessageCommandServiceTests
|
|||||||
private Mock<IGroupsRepository> _mockGroupsRepo;
|
private Mock<IGroupsRepository> _mockGroupsRepo;
|
||||||
private Mock<IVerifyFriendship> _mockVerifyFriendship;
|
private Mock<IVerifyFriendship> _mockVerifyFriendship;
|
||||||
private Mock<IPrivateChatsRepository> _mockPrivateChats;
|
private Mock<IPrivateChatsRepository> _mockPrivateChats;
|
||||||
|
private Mock<IMediaService> _mockMediaService;
|
||||||
private Mock<ILogger<MessageCommandService>> _mockLogger;
|
private Mock<ILogger<MessageCommandService>> _mockLogger;
|
||||||
private MessageCommandService _messageService;
|
private MessageCommandService _messageService;
|
||||||
|
|
||||||
@@ -33,6 +35,7 @@ public class MessageCommandServiceTests
|
|||||||
_mockGroupsRepo = new Mock<IGroupsRepository>();
|
_mockGroupsRepo = new Mock<IGroupsRepository>();
|
||||||
_mockVerifyFriendship = new Mock<IVerifyFriendship>();
|
_mockVerifyFriendship = new Mock<IVerifyFriendship>();
|
||||||
_mockPrivateChats = new Mock<IPrivateChatsRepository>();
|
_mockPrivateChats = new Mock<IPrivateChatsRepository>();
|
||||||
|
_mockMediaService = new Mock<IMediaService>();
|
||||||
_mockLogger = new Mock<ILogger<MessageCommandService>>();
|
_mockLogger = new Mock<ILogger<MessageCommandService>>();
|
||||||
|
|
||||||
_messageService = new MessageCommandService(
|
_messageService = new MessageCommandService(
|
||||||
@@ -41,6 +44,7 @@ public class MessageCommandServiceTests
|
|||||||
_mockGroupsRepo.Object,
|
_mockGroupsRepo.Object,
|
||||||
_mockVerifyFriendship.Object,
|
_mockVerifyFriendship.Object,
|
||||||
_mockPrivateChats.Object,
|
_mockPrivateChats.Object,
|
||||||
|
_mockMediaService.Object,
|
||||||
_mockLogger.Object);
|
_mockLogger.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +56,6 @@ public class MessageCommandServiceTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
var senderId = Guid.NewGuid();
|
var senderId = Guid.NewGuid();
|
||||||
var recipientId = Guid.NewGuid();
|
var recipientId = Guid.NewGuid();
|
||||||
|
|
||||||
var sendMessageParams = new SendMessage("Hello",
|
var sendMessageParams = new SendMessage("Hello",
|
||||||
null,
|
null,
|
||||||
recipientId,
|
recipientId,
|
||||||
@@ -66,6 +69,7 @@ public class MessageCommandServiceTests
|
|||||||
_mockMessagesRepo.Setup(r => r.AddAsync(It.IsAny<Message>())).Returns(Task.CompletedTask);
|
_mockMessagesRepo.Setup(r => r.AddAsync(It.IsAny<Message>())).Returns(Task.CompletedTask);
|
||||||
_mockPrivateChats.Setup(c => c.Exist(senderId, recipientId)).Returns(true);
|
_mockPrivateChats.Setup(c => c.Exist(senderId, recipientId)).Returns(true);
|
||||||
_mockPrivateChats.Setup(c => c.GetByMembersAsync(senderId, recipientId)).ReturnsAsync(new PrivateChat(){Id = recipientId});
|
_mockPrivateChats.Setup(c => c.GetByMembersAsync(senderId, recipientId)).ReturnsAsync(new PrivateChat(){Id = recipientId});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await _messageService.SendMessageAsync(sendMessageParams);
|
var result = await _messageService.SendMessageAsync(sendMessageParams);
|
||||||
// Assert
|
// Assert
|
||||||
@@ -79,7 +83,53 @@ public class MessageCommandServiceTests
|
|||||||
m.RecipientType == RecipientType.User &&
|
m.RecipientType == RecipientType.User &&
|
||||||
m.EncryptedContent == "Hello")), Times.Once);
|
m.EncryptedContent == "Hello")), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task SendMessageAsync_ToUser_When_AttachMediaThrowsException_ReturnsFailure()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var senderId = Guid.NewGuid();
|
||||||
|
var recipientId = Guid.NewGuid();
|
||||||
|
var sendMediaId = Guid.NewGuid();
|
||||||
|
|
||||||
|
var sendMessageParams = new SendMessage(
|
||||||
|
"Hello",
|
||||||
|
null,
|
||||||
|
recipientId,
|
||||||
|
RecipientType.User,
|
||||||
|
senderId,
|
||||||
|
DateTime.UtcNow,
|
||||||
|
new List<SendMedia> { new SendMedia(sendMediaId, string.Empty) });
|
||||||
|
|
||||||
|
_mockUsersRepo.Setup(r => r.ExistsByIdAsync(recipientId)).ReturnsAsync(true);
|
||||||
|
_mockVerifyFriendship.Setup(v => v.VerifyAsync(senderId, recipientId)).Returns(Task.CompletedTask);
|
||||||
|
_mockMessagesRepo.Setup(r => r.AddAsync(It.IsAny<Message>())).Returns(Task.CompletedTask);
|
||||||
|
_mockPrivateChats.Setup(c => c.Exist(senderId, recipientId)).Returns(true);
|
||||||
|
_mockPrivateChats.Setup(c => c.GetByMembersAsync(senderId, recipientId))
|
||||||
|
.ReturnsAsync(new PrivateChat { Id = recipientId });
|
||||||
|
|
||||||
|
// !
|
||||||
|
_mockMediaService
|
||||||
|
.Setup(m => m.AttachToMessageAsync(sendMediaId, It.IsAny<Guid>()))
|
||||||
|
.ThrowsAsync(new Exception("Unexpected DB error"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _messageService.SendMessageAsync(sendMessageParams);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.Not.Null);
|
||||||
|
Assert.That(result.IsSuccess, Is.False);
|
||||||
|
Assert.That(result.Exception, Is.Not.Null);
|
||||||
|
Assert.That(result.Exception.Message, Is.EqualTo("Unexpected DB error"));
|
||||||
|
|
||||||
|
// Проверяем, что сообщение не было сохранено
|
||||||
|
_mockMessagesRepo.Verify(r => r.AddAsync(It.IsAny<Message>()), Times.Never);
|
||||||
|
|
||||||
|
// Проверяем, что метод прикрепления медиа вызывался
|
||||||
|
_mockMediaService.Verify(m => m.AttachToMessageAsync(sendMediaId, It.IsAny<Guid>()), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task SendMessageAsync_ToGroup_Success()
|
public async Task SendMessageAsync_ToGroup_Success()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
using Govor.Application.Services;
|
||||||
|
using Govor.Core.Models.Users;
|
||||||
|
using Govor.Core.Repositories.Users;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Moq;
|
||||||
|
|
||||||
|
namespace Govor.Application.Tests.Services;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class ProfileServiceTests
|
||||||
|
{
|
||||||
|
private Mock<IUsersRepository> _mockUsersRepo = null!;
|
||||||
|
private Mock<ILogger<ProfileService>> _mockLogger = null!;
|
||||||
|
private ProfileService _service = null!;
|
||||||
|
private User _testUser = null!;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
_mockUsersRepo = new Mock<IUsersRepository>();
|
||||||
|
_mockLogger = new Mock<ILogger<ProfileService>>();
|
||||||
|
|
||||||
|
_service = new ProfileService(_mockUsersRepo.Object, _mockLogger.Object);
|
||||||
|
|
||||||
|
_testUser = new User
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Username = "testuser",
|
||||||
|
Description = "old description",
|
||||||
|
IconId = Guid.NewGuid()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- GetUserProfileAsync ----------
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task GetUserProfileAsync_ReturnsCorrectData()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockUsersRepo.Setup(r => r.FindByIdAsync(_testUser.Id))
|
||||||
|
.ReturnsAsync(_testUser);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await _service.GetUserProfileAsync(_testUser.Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.Not.Null);
|
||||||
|
Assert.That(result.Id, Is.EqualTo(_testUser.Id));
|
||||||
|
Assert.That(result.Username, Is.EqualTo("testuser"));
|
||||||
|
Assert.That(result.Description, Is.EqualTo("old description"));
|
||||||
|
Assert.That(result.IconId, Is.EqualTo(_testUser.IconId));
|
||||||
|
|
||||||
|
_mockUsersRepo.Verify(r => r.FindByIdAsync(_testUser.Id), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetUserProfileAsync_Throws_WhenUserNotFound()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockUsersRepo.Setup(r => r.FindByIdAsync(It.IsAny<Guid>()))
|
||||||
|
.ReturnsAsync((User)null!);
|
||||||
|
|
||||||
|
// Act + Assert
|
||||||
|
Assert.ThrowsAsync<NullReferenceException>(() =>
|
||||||
|
_service.GetUserProfileAsync(Guid.NewGuid()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- SetDescription ----------
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task SetDescription_UpdatesUserDescription()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var newDescription = "new cool description";
|
||||||
|
_mockUsersRepo.Setup(r => r.FindByIdAsync(_testUser.Id))
|
||||||
|
.ReturnsAsync(_testUser);
|
||||||
|
_mockUsersRepo.Setup(r => r.UpdateAsync(It.IsAny<User>()))
|
||||||
|
.Returns(Task.CompletedTask);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await _service.SetDescription(newDescription, _testUser.Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(_testUser.Description, Is.EqualTo(newDescription));
|
||||||
|
_mockUsersRepo.Verify(r => r.UpdateAsync(It.Is<User>(u => u.Description == newDescription)), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetDescription_Throws_WhenUserNotFound()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockUsersRepo.Setup(r => r.FindByIdAsync(It.IsAny<Guid>()))
|
||||||
|
.ReturnsAsync((User)null!);
|
||||||
|
|
||||||
|
// Act + Assert
|
||||||
|
Assert.ThrowsAsync<NullReferenceException>(() =>
|
||||||
|
_service.SetDescription("desc", Guid.NewGuid()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- SetNewIcon ----------
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task SetNewIcon_UpdatesUserIconId()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var newIconId = Guid.NewGuid();
|
||||||
|
_mockUsersRepo.Setup(r => r.FindByIdAsync(_testUser.Id))
|
||||||
|
.ReturnsAsync(_testUser);
|
||||||
|
_mockUsersRepo.Setup(r => r.UpdateAsync(It.IsAny<User>()))
|
||||||
|
.Returns(Task.CompletedTask);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await _service.SetNewIcon(_testUser.Id, newIconId);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(_testUser.IconId, Is.EqualTo(newIconId));
|
||||||
|
_mockUsersRepo.Verify(r => r.UpdateAsync(It.Is<User>(u => u.IconId == newIconId)), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetNewIcon_Throws_WhenUserNotFound()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockUsersRepo.Setup(r => r.FindByIdAsync(It.IsAny<Guid>()))
|
||||||
|
.ReturnsAsync((User)null!);
|
||||||
|
|
||||||
|
// Act + Assert
|
||||||
|
Assert.ThrowsAsync<NullReferenceException>(() =>
|
||||||
|
_service.SetNewIcon(Guid.NewGuid(), Guid.NewGuid()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,12 @@ public class UserSessionReaderTests
|
|||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
_fixture = new Fixture();
|
_fixture = new Fixture();
|
||||||
|
_fixture.Behaviors.OfType<ThrowingRecursionBehavior>()
|
||||||
|
.ToList()
|
||||||
|
.ForEach(b => _fixture.Behaviors.Remove(b));
|
||||||
|
|
||||||
|
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
|
||||||
|
|
||||||
_mockUserSessionsRepository = new Mock<IUserSessionsRepository>();
|
_mockUserSessionsRepository = new Mock<IUserSessionsRepository>();
|
||||||
_mockLogger = new Mock<ILogger<UserSessionReader>>();
|
_mockLogger = new Mock<ILogger<UserSessionReader>>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Linq.Expressions;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Govor.Application.Exceptions.AuthService;
|
using Govor.Application.Exceptions.AuthService;
|
||||||
using Govor.Application.Interfaces.Authentication;
|
using Govor.Application.Interfaces.Authentication;
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Govor.Application.Profiles;
|
||||||
|
|
||||||
|
namespace Govor.Application.Interfaces;
|
||||||
|
|
||||||
|
public interface IProfileService
|
||||||
|
{
|
||||||
|
public Task<UserProfile> GetUserProfileAsync(Guid userId);
|
||||||
|
public Task SetDescription(string description, Guid userId);
|
||||||
|
public Task SetNewIcon(Guid userId, Guid iconId);
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Govor.Core.Models;
|
||||||
using Govor.Core.Models.Messages;
|
using Govor.Core.Models.Messages;
|
||||||
|
|
||||||
namespace Govor.Application.Interfaces.Medias;
|
namespace Govor.Application.Interfaces.Medias;
|
||||||
@@ -8,6 +9,7 @@ public interface IMediaService
|
|||||||
public Task DeleteMediaAsync(Guid fileId);
|
public Task DeleteMediaAsync(Guid fileId);
|
||||||
public Task<Media> GetMediaByUrlAsync(string url);
|
public Task<Media> GetMediaByUrlAsync(string url);
|
||||||
public Task<Media> GetMediaByIdAsync(Guid mediaId);
|
public Task<Media> GetMediaByIdAsync(Guid mediaId);
|
||||||
|
Task AttachToMessageAsync(Guid mediaId, Guid messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Media(Guid UploaderId,
|
public record Media(Guid UploaderId,
|
||||||
@@ -16,6 +18,8 @@ public record Media(Guid UploaderId,
|
|||||||
byte[] Data,
|
byte[] Data,
|
||||||
MediaType Type,
|
MediaType Type,
|
||||||
string MimeType,
|
string MimeType,
|
||||||
string EncryptedKey);
|
string EncryptedKey,
|
||||||
|
MediaOwnerType OwnerType,
|
||||||
|
Guid? OwnerId);
|
||||||
|
|
||||||
public record MediaUploadResult(Guid? MediaId, string Url);
|
public record MediaUploadResult(Guid? MediaId, string Url);
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Govor.Application.Profiles;
|
||||||
|
|
||||||
|
public class UserProfile
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Username { get; set; } = string.Empty;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public Guid? IconId { get; set; }
|
||||||
|
}
|
||||||
@@ -46,7 +46,7 @@ public class AuthService : IAccountService
|
|||||||
PasswordHash = passwordHash,
|
PasswordHash = passwordHash,
|
||||||
Description = string.Empty,
|
Description = string.Empty,
|
||||||
CreatedOn = DateOnly.FromDateTime(DateTime.UtcNow),
|
CreatedOn = DateOnly.FromDateTime(DateTime.UtcNow),
|
||||||
IconId = Guid.NewGuid(),
|
IconId = Guid.Empty,
|
||||||
WasOnline = DateTime.UtcNow,
|
WasOnline = DateTime.UtcNow,
|
||||||
InviteId = invitation.Id
|
InviteId = invitation.Id
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class LocalStorageService : IStorageService
|
|||||||
var fullPath = Path.Combine(folder, uniqueFileName);
|
var fullPath = Path.Combine(folder, uniqueFileName);
|
||||||
|
|
||||||
await using var stream = new FileStream(fullPath, FileMode.Create);
|
await using var stream = new FileStream(fullPath, FileMode.Create);
|
||||||
stream.WriteAsync(data, 0, data.Length);
|
await stream.WriteAsync(data, 0, data.Length);
|
||||||
|
|
||||||
return Path.Combine(date, uniqueFileName);
|
return Path.Combine(date, uniqueFileName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Govor.Application.Interfaces.Medias;
|
using Govor.Application.Interfaces.Medias;
|
||||||
using Govor.Core.Models.Messages;
|
using Govor.Core.Models;
|
||||||
using Govor.Data;
|
using Govor.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
@@ -14,20 +14,35 @@ public class AccesserToDownloadMediaService : IAccesserToDownloadMedia
|
|||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> HasAccessAsync(Guid mediaFileId, Guid userId)
|
public async Task<bool> HasAccessAsync(Guid mediaId, Guid userId)
|
||||||
{
|
{
|
||||||
return await _dbContext.MediaAttachments
|
var media = await _dbContext.MediaFiles
|
||||||
.Include(ma => ma.Message)
|
.AsNoTracking()
|
||||||
.AnyAsync(ma =>
|
.Where(m => m.Id == mediaId)
|
||||||
ma.MediaFileId == mediaFileId &&
|
.Select(m => new { m.OwnerType, m.OwnerId, m.UploaderId })
|
||||||
(
|
.FirstOrDefaultAsync();
|
||||||
(ma.Message.RecipientType == RecipientType.User &&
|
|
||||||
(ma.Message.SenderId == userId || ma.Message.RecipientId == userId))
|
if (media is null)
|
||||||
||
|
return false;
|
||||||
(ma.Message.RecipientType == RecipientType.Group &&
|
|
||||||
_dbContext.GroupMemberships.Any(gm =>
|
return media.OwnerType switch
|
||||||
gm.GroupId == ma.Message.RecipientId &&
|
{
|
||||||
gm.UserId == userId))
|
MediaOwnerType.Avatar => true, // media.OwnerId == userId
|
||||||
));
|
MediaOwnerType.GroupAvatar => await _dbContext.GroupMemberships
|
||||||
|
.AnyAsync(gm => gm.GroupId == media.OwnerId && gm.UserId == userId),
|
||||||
|
|
||||||
|
MediaOwnerType.Message => await _dbContext.MediaAttachments
|
||||||
|
.AnyAsync(ma =>
|
||||||
|
ma.MediaFileId == mediaId &&
|
||||||
|
(
|
||||||
|
ma.Message.SenderId == userId ||
|
||||||
|
ma.Message.RecipientId == userId ||
|
||||||
|
_dbContext.GroupMemberships.Any(gm =>
|
||||||
|
gm.GroupId == ma.Message.RecipientId && gm.UserId == userId)
|
||||||
|
)),
|
||||||
|
|
||||||
|
MediaOwnerType.System => true,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,9 @@ public class MediaService : IMediaService
|
|||||||
DateCreated = file.UploadedOn,
|
DateCreated = file.UploadedOn,
|
||||||
MediaType = file.Type,
|
MediaType = file.Type,
|
||||||
MineType = file.MimeType,
|
MineType = file.MimeType,
|
||||||
Url = url
|
Url = url,
|
||||||
|
OwnerType = file.OwnerType,
|
||||||
|
OwnerId = file.OwnerId,
|
||||||
});
|
});
|
||||||
|
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
@@ -87,7 +89,9 @@ public class MediaService : IMediaService
|
|||||||
contentBytes,
|
contentBytes,
|
||||||
mediaFile.MediaType,
|
mediaFile.MediaType,
|
||||||
mediaFile.MineType,
|
mediaFile.MineType,
|
||||||
string.Empty
|
string.Empty,
|
||||||
|
mediaFile.OwnerType,
|
||||||
|
mediaFile.OwnerId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException ex)
|
catch (FileNotFoundException ex)
|
||||||
@@ -96,4 +100,24 @@ public class MediaService : IMediaService
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public async Task AttachToMessageAsync(Guid mediaId, Guid messageId)
|
||||||
|
{
|
||||||
|
var mediaFile = await _dbContext.MediaFiles
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == mediaId)
|
||||||
|
?? throw new KeyNotFoundException($"No media found by given id {mediaId}");
|
||||||
|
|
||||||
|
if (mediaFile.OwnerType != MediaOwnerType.Message)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Attempt to attach already owned media {MediaId}", mediaId);
|
||||||
|
throw new InvalidOperationException($"Media {mediaId} is already attached to {mediaFile.OwnerType}");
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaFile.OwnerType = MediaOwnerType.Message;
|
||||||
|
mediaFile.OwnerId = messageId;
|
||||||
|
|
||||||
|
_dbContext.MediaFiles.Update(mediaFile);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
_logger.LogInformation("Media {MediaId} successfully attached to message {MessageId}", mediaId, messageId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Govor.Application.Interfaces;
|
using Govor.Application.Interfaces;
|
||||||
|
using Govor.Application.Interfaces.Medias;
|
||||||
using Govor.Application.Interfaces.Messages;
|
using Govor.Application.Interfaces.Messages;
|
||||||
using Govor.Application.Interfaces.Messages.Parameters;
|
using Govor.Application.Interfaces.Messages.Parameters;
|
||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
@@ -18,7 +19,8 @@ public class MessageCommandService : IMessageCommandService
|
|||||||
private readonly IUsersRepository _usersRepository;
|
private readonly IUsersRepository _usersRepository;
|
||||||
private readonly IGroupsRepository _groupsRepository;
|
private readonly IGroupsRepository _groupsRepository;
|
||||||
private readonly IPrivateChatsRepository _privateChats;
|
private readonly IPrivateChatsRepository _privateChats;
|
||||||
private readonly IVerifyFriendship _verifyFriendship;
|
private readonly IVerifyFriendship _verifyFriendship;
|
||||||
|
private readonly IMediaService _mediaService;
|
||||||
private readonly ILogger<MessageCommandService> _logger;
|
private readonly ILogger<MessageCommandService> _logger;
|
||||||
|
|
||||||
public MessageCommandService(
|
public MessageCommandService(
|
||||||
@@ -27,6 +29,7 @@ public class MessageCommandService : IMessageCommandService
|
|||||||
IGroupsRepository groupsRepository,
|
IGroupsRepository groupsRepository,
|
||||||
IVerifyFriendship verifyFriendship,
|
IVerifyFriendship verifyFriendship,
|
||||||
IPrivateChatsRepository privateChats,
|
IPrivateChatsRepository privateChats,
|
||||||
|
IMediaService mediaService,
|
||||||
ILogger<MessageCommandService> logger)
|
ILogger<MessageCommandService> logger)
|
||||||
{
|
{
|
||||||
_messagesRepository = messagesRepository;
|
_messagesRepository = messagesRepository;
|
||||||
@@ -34,6 +37,7 @@ public class MessageCommandService : IMessageCommandService
|
|||||||
_groupsRepository = groupsRepository;
|
_groupsRepository = groupsRepository;
|
||||||
_verifyFriendship = verifyFriendship;
|
_verifyFriendship = verifyFriendship;
|
||||||
_privateChats = privateChats;
|
_privateChats = privateChats;
|
||||||
|
_mediaService = mediaService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +101,15 @@ public class MessageCommandService : IMessageCommandService
|
|||||||
}).ToList() ?? new List<MediaAttachments>()
|
}).ToList() ?? new List<MediaAttachments>()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If there is media, we link them.
|
||||||
|
if (sendParams.Media != null && sendParams.Media.Any())
|
||||||
|
{
|
||||||
|
foreach (var media in sendParams.Media)
|
||||||
|
{
|
||||||
|
await _mediaService.AttachToMessageAsync(media.MediaId, messageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await _messagesRepository.AddAsync(message);
|
await _messagesRepository.AddAsync(message);
|
||||||
_logger.LogInformation("Message {MessageId} from {SenderId} to {RecipientId} ({RecipientType}) saved successfully.", messageId, sendParams.FromUserId, sendParams.RecipientId, sendParams.RecipientType);
|
_logger.LogInformation("Message {MessageId} from {SenderId} to {RecipientId} ({RecipientType}) saved successfully.", messageId, sendParams.FromUserId, sendParams.RecipientId, sendParams.RecipientType);
|
||||||
return new SendMessageResult(true, null, message);
|
return new SendMessageResult(true, null, message);
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using Govor.Application.Interfaces;
|
||||||
|
using Govor.Application.Profiles;
|
||||||
|
using Govor.Core.Repositories.Users;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Govor.Application.Services;
|
||||||
|
|
||||||
|
public class ProfileService : IProfileService
|
||||||
|
{
|
||||||
|
private readonly ILogger<ProfileService> _logger;
|
||||||
|
private readonly IUsersRepository _userRepository;
|
||||||
|
|
||||||
|
public ProfileService(IUsersRepository userRepository, ILogger<ProfileService> logger)
|
||||||
|
{
|
||||||
|
_userRepository = userRepository;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<UserProfile> GetUserProfileAsync(Guid userId)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Gettings user {userId} profile", userId);
|
||||||
|
var user = await _userRepository.FindByIdAsync(userId);
|
||||||
|
|
||||||
|
return new UserProfile
|
||||||
|
{
|
||||||
|
Id = user.Id,
|
||||||
|
Username = user.Username,
|
||||||
|
Description = user.Description,
|
||||||
|
IconId = user.IconId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SetDescription(string description, Guid userId)
|
||||||
|
{
|
||||||
|
var user = await _userRepository.FindByIdAsync(userId);
|
||||||
|
|
||||||
|
user.Description = description;
|
||||||
|
await _userRepository.UpdateAsync(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SetNewIcon(Guid userId, Guid iconId)
|
||||||
|
{
|
||||||
|
var user = await _userRepository.FindByIdAsync(userId);
|
||||||
|
|
||||||
|
user.IconId = iconId;
|
||||||
|
await _userRepository.UpdateAsync(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ public class VerifyFriendship : IVerifyFriendship
|
|||||||
private readonly ILogger<VerifyFriendship> _logger;
|
private readonly ILogger<VerifyFriendship> _logger;
|
||||||
private const string FriendshipNotAcceptedError = "Friendship between user {0} and friend {1} does not exist or is not accepted.";
|
private const string FriendshipNotAcceptedError = "Friendship between user {0} and friend {1} does not exist or is not accepted.";
|
||||||
|
|
||||||
public VerifyFriendship(IFriendshipsRepository friendshipsRepository, ILogger<VerifyFriendship> logger = null)
|
public VerifyFriendship(IFriendshipsRepository friendshipsRepository, ILogger<VerifyFriendship> logger)
|
||||||
{
|
{
|
||||||
_friendshipsRepository = friendshipsRepository ?? throw new ArgumentNullException(nameof(friendshipsRepository));
|
_friendshipsRepository = friendshipsRepository ?? throw new ArgumentNullException(nameof(friendshipsRepository));
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@@ -42,14 +42,16 @@ public class VerifyFriendship : IVerifyFriendship
|
|||||||
throw new FriendshipException(errorMessage);
|
throw new FriendshipException(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger?.LogInformation(
|
_logger.LogInformation("hello");
|
||||||
|
|
||||||
|
_logger.LogInformation(
|
||||||
"Friendship verified successfully for targetUserId={TargetUserId}, friendUserId={FriendUserId}",
|
"Friendship verified successfully for targetUserId={TargetUserId}, friendUserId={FriendUserId}",
|
||||||
targetUserId, friendUserId);
|
targetUserId, friendUserId);
|
||||||
}
|
}
|
||||||
catch (NotFoundByKeyException<Guid> ex)
|
catch (NotFoundByKeyException<Guid> ex)
|
||||||
{
|
{
|
||||||
var errorMessage = string.Format(FriendshipNotAcceptedError, targetUserId, friendUserId);
|
var errorMessage = string.Format(FriendshipNotAcceptedError, targetUserId, friendUserId);
|
||||||
_logger?.LogError(errorMessage);
|
_logger.LogError(errorMessage);
|
||||||
|
|
||||||
throw new FriendshipException(errorMessage);
|
throw new FriendshipException(errorMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Govor.Contracts.DTOs;
|
||||||
|
|
||||||
|
public class UserProfileDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Username { get; set; } = string.Empty;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public Guid? IconId { get; set; }
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using Govor.Core.Models;
|
||||||
using Govor.Core.Models.Messages;
|
using Govor.Core.Models.Messages;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Govor.Contracts.Requests;
|
namespace Govor.Contracts.Requests;
|
||||||
|
|
||||||
@@ -14,4 +15,6 @@ public class MediaUploadRequest
|
|||||||
public string MimeType { get; set; } = string.Empty;
|
public string MimeType { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public string EncryptedKey { get; set; } = string.Empty;
|
public string EncryptedKey { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public MediaOwnerType OwnerType { get; set; } = MediaOwnerType.Message;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Govor.Core.Models.Messages;
|
using Govor.Core.Models.Messages;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Govor.Contracts.Requests.SignalR;
|
namespace Govor.Contracts.Requests.SignalR;
|
||||||
|
|
||||||
@@ -6,6 +7,8 @@ public record MessageRequest
|
|||||||
{
|
{
|
||||||
public Guid RecipientId { get; init; }
|
public Guid RecipientId { get; init; }
|
||||||
public RecipientType RecipientType { get; init; }
|
public RecipientType RecipientType { get; init; }
|
||||||
|
[Required]
|
||||||
|
[MaxLength(100_000, ErrorMessage = "EncryptedContent cannot exceed 100,000 characters.")]
|
||||||
public string EncryptedContent { get; init; } = string.Empty;
|
public string EncryptedContent { get; init; } = string.Empty;
|
||||||
public Guid? ReplyToMessageId { get; set; }
|
public Guid? ReplyToMessageId { get; set; }
|
||||||
public List<MediaReference> MediaAttachments { get; set; } = new();
|
public List<MediaReference> MediaAttachments { get; set; } = new();
|
||||||
|
|||||||
@@ -10,4 +10,15 @@ public class MediaFile
|
|||||||
public MediaType MediaType { get; set; }
|
public MediaType MediaType { get; set; }
|
||||||
public string MineType { get; set; }
|
public string MineType { get; set; }
|
||||||
public DateTime DateCreated { get; set; }
|
public DateTime DateCreated { get; set; }
|
||||||
|
|
||||||
|
public MediaOwnerType OwnerType { get; set; } = MediaOwnerType.Message;
|
||||||
|
public Guid? OwnerId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MediaOwnerType
|
||||||
|
{
|
||||||
|
Message = 0,
|
||||||
|
Avatar = 1,
|
||||||
|
GroupAvatar = 2,
|
||||||
|
System = 3 // (Emoge, icons è e.t.c)
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,8 @@ public class UserSession
|
|||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
public DateTime ExpiresAt { get; set; }
|
public DateTime ExpiresAt { get; set; }
|
||||||
public bool IsRevoked { get; set; } = false;
|
public bool IsRevoked { get; set; } = false;
|
||||||
|
// public DateTime? RevokedAt { get; set; } TODO: Clear old UserSessions
|
||||||
|
|
||||||
public UserCryptoSession CryptoSession { get; set; }
|
public UserCryptoSession CryptoSession { get; set; }
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? obj)
|
||||||
|
|||||||
@@ -1,582 +0,0 @@
|
|||||||
// <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("20250707142430_InitialCreate")]
|
|
||||||
partial class InitialCreate
|
|
||||||
{
|
|
||||||
/// <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.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")
|
|
||||||
.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.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")
|
|
||||||
.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.Message", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.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("PrivateChatId");
|
|
||||||
|
|
||||||
b.ToTable("Messages");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.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.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.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.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")
|
|
||||||
.WithMany("ReceivedFriendRequests")
|
|
||||||
.HasForeignKey("AddresseeId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Govor.Core.Models.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.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.MediaAttachments", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Govor.Core.Models.MediaFile", "MediaFile")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("MediaFileId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Govor.Core.Models.Message", "Message")
|
|
||||||
.WithMany("MediaAttachments")
|
|
||||||
.HasForeignKey("MessageId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("MediaFile");
|
|
||||||
|
|
||||||
b.Navigation("Message");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Message", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Govor.Core.Models.PrivateChat", null)
|
|
||||||
.WithMany("Messages")
|
|
||||||
.HasForeignKey("PrivateChatId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.MessageReaction", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Govor.Core.Models.Message", "Message")
|
|
||||||
.WithMany("Reactions")
|
|
||||||
.HasForeignKey("MessageId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Govor.Core.Models.User", "User")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Message");
|
|
||||||
|
|
||||||
b.Navigation("User");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.MessageView", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Govor.Core.Models.Message", null)
|
|
||||||
.WithMany("MessageViews")
|
|
||||||
.HasForeignKey("MessageId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.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");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Invitation", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.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.User", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("ReceivedFriendRequests");
|
|
||||||
|
|
||||||
b.Navigation("SentFriendRequests");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,593 +0,0 @@
|
|||||||
// <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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,596 +0,0 @@
|
|||||||
// <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("20250713101943_AddUploaderIdToMediaFile")]
|
|
||||||
partial class AddUploaderIdToMediaFile
|
|
||||||
{
|
|
||||||
/// <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<Guid>("UploaderId")
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Govor.Data.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class usersessions : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserSessions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
RefreshToken = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
DeviceInfo = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
ExpiresAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
IsRevoked = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserSessions", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserSessions_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserSessions_UserId",
|
|
||||||
table: "UserSessions",
|
|
||||||
column: "UserId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserSessions");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Govor.Data.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class CryptKeys : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "DeviceInfo",
|
|
||||||
table: "UserSessions",
|
|
||||||
type: "varchar(256)",
|
|
||||||
maxLength: 256,
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "varchar(200)",
|
|
||||||
oldMaxLength: 200)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4")
|
|
||||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<Guid>(
|
|
||||||
name: "InvitationId",
|
|
||||||
table: "GroupMemberships",
|
|
||||||
type: "char(36)",
|
|
||||||
nullable: true,
|
|
||||||
collation: "ascii_general_ci",
|
|
||||||
oldClrType: typeof(Guid),
|
|
||||||
oldType: "char(36)")
|
|
||||||
.OldAnnotation("Relational:Collation", "ascii_general_ci");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "MemberSince",
|
|
||||||
table: "GroupMemberships",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserCryptoSessions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
UserSessionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
PublicIdentityKey = table.Column<byte[]>(type: "longblob", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserCryptoSessions", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserCryptoSessions_UserSessions_UserSessionId",
|
|
||||||
column: x => x.UserSessionId,
|
|
||||||
principalTable: "UserSessions",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "OneTimePreKeys",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
UserCryptoSessionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
PublicKey = table.Column<byte[]>(type: "longblob", nullable: false),
|
|
||||||
IsUsed = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
|
|
||||||
UploadedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OneTimePreKeys", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OneTimePreKeys_UserCryptoSessions_UserCryptoSessionId",
|
|
||||||
column: x => x.UserCryptoSessionId,
|
|
||||||
principalTable: "UserCryptoSessions",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "SignedPreKeys",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
UserCryptoSessionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
PublicSignedPreKey = table.Column<byte[]>(type: "longblob", nullable: false),
|
|
||||||
SignedPreKeySignature = table.Column<byte[]>(type: "longblob", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_SignedPreKeys", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_SignedPreKeys_UserCryptoSessions_UserCryptoSessionId",
|
|
||||||
column: x => x.UserCryptoSessionId,
|
|
||||||
principalTable: "UserCryptoSessions",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_OneTimePreKeys_UploadedAt",
|
|
||||||
table: "OneTimePreKeys",
|
|
||||||
column: "UploadedAt");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_OneTimePreKeys_UserCryptoSessionId_IsUsed",
|
|
||||||
table: "OneTimePreKeys",
|
|
||||||
columns: new[] { "UserCryptoSessionId", "IsUsed" });
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_SignedPreKeys_UserCryptoSessionId",
|
|
||||||
table: "SignedPreKeys",
|
|
||||||
column: "UserCryptoSessionId",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserCryptoSessions_UserSessionId",
|
|
||||||
table: "UserCryptoSessions",
|
|
||||||
column: "UserSessionId",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "OneTimePreKeys");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "SignedPreKeys");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserCryptoSessions");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "MemberSince",
|
|
||||||
table: "GroupMemberships");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "DeviceInfo",
|
|
||||||
table: "UserSessions",
|
|
||||||
type: "varchar(200)",
|
|
||||||
maxLength: 200,
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "varchar(256)",
|
|
||||||
oldMaxLength: 256)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4")
|
|
||||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<Guid>(
|
|
||||||
name: "InvitationId",
|
|
||||||
table: "GroupMemberships",
|
|
||||||
type: "char(36)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
|
||||||
collation: "ascii_general_ci",
|
|
||||||
oldClrType: typeof(Guid),
|
|
||||||
oldType: "char(36)",
|
|
||||||
oldNullable: true)
|
|
||||||
.OldAnnotation("Relational:Collation", "ascii_general_ci");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+99
-99
@@ -3,17 +3,17 @@ using System;
|
|||||||
using Govor.Data;
|
using Govor.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace Govor.Data.Migrations
|
namespace Govor.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(GovorDbContext))]
|
[DbContext(typeof(GovorDbContext))]
|
||||||
[Migration("20250730142221_CryptKeys")]
|
[Migration("20251019125424_InitialCreate")]
|
||||||
partial class CryptKeys
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -21,34 +21,34 @@ namespace Govor.Data.Migrations
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.6")
|
.HasAnnotation("ProductVersion", "8.0.6")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
.HasColumnType("varchar(500)");
|
.HasColumnType("character varying(500)");
|
||||||
|
|
||||||
b.Property<Guid>("ImageId")
|
b.Property<Guid>("ImageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<bool>("IsChannel")
|
b.Property<bool>("IsChannel")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsPrivate")
|
b.Property<bool>("IsPrivate")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(100)
|
.HasMaxLength(100)
|
||||||
.HasColumnType("varchar(100)");
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -59,16 +59,16 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("AddresseeId")
|
b.Property<Guid>("AddresseeId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("RequesterId")
|
b.Property<Guid>("RequesterId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -83,13 +83,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -102,32 +102,32 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
.HasColumnType("varchar(500)");
|
.HasColumnType("character varying(500)");
|
||||||
|
|
||||||
b.Property<DateTime>("EndDate")
|
b.Property<DateTime>("EndDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("InvitationCode")
|
b.Property<string>("InvitationCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(200)
|
.HasMaxLength(200)
|
||||||
.HasColumnType("varchar(200)");
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
b.Property<int>("MaxParticipants")
|
b.Property<int>("MaxParticipants")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid>("UserMakerId")
|
b.Property<Guid>("UserMakerId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -142,22 +142,22 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid?>("InvitationId")
|
b.Property<Guid?>("InvitationId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<bool>("IsBanned")
|
b.Property<bool>("IsBanned")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<DateTime>("MemberSince")
|
b.Property<DateTime>("MemberSince")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -172,30 +172,30 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Code")
|
b.Property<string>("Code")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreated")
|
b.Property<DateTime>("DateCreated")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("EndDate")
|
b.Property<DateTime>("EndDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<bool>("IsActive")
|
b.Property<bool>("IsActive")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsAdmin")
|
b.Property<bool>("IsAdmin")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<int>("MaxParticipants")
|
b.Property<int>("MaxParticipants")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -206,26 +206,26 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreated")
|
b.Property<DateTime>("DateCreated")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("MediaType")
|
b.Property<string>("MediaType")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("MineType")
|
b.Property<string>("MineType")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("varchar(128)");
|
.HasColumnType("character varying(128)");
|
||||||
|
|
||||||
b.Property<Guid>("UploaderId")
|
b.Property<Guid>("UploaderId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Url")
|
b.Property<string>("Url")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -236,13 +236,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MediaFileId")
|
b.Property<Guid>("MediaFileId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -257,38 +257,38 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid?>("ChatGroupId")
|
b.Property<Guid?>("ChatGroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime?>("EditedAt")
|
b.Property<DateTime?>("EditedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("EncryptedContent")
|
b.Property<string>("EncryptedContent")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<bool>("IsEdited")
|
b.Property<bool>("IsEdited")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<Guid?>("PrivateChatId")
|
b.Property<Guid?>("PrivateChatId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("RecipientId")
|
b.Property<Guid>("RecipientId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<int>("RecipientType")
|
b.Property<int>("RecipientType")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid?>("ReplyToMessageId")
|
b.Property<Guid?>("ReplyToMessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("SenderId")
|
b.Property<Guid>("SenderId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("SentAt")
|
b.Property<DateTime>("SentAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -303,21 +303,21 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("ReactedAt")
|
b.Property<DateTime>("ReactedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("ReactionCode")
|
b.Property<string>("ReactionCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("varchar(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -333,16 +333,16 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("ViewedAt")
|
b.Property<DateTime>("ViewedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -356,13 +356,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserAId")
|
b.Property<Guid>("UserAId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserBId")
|
b.Property<Guid>("UserBId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ namespace Govor.Data.Migrations
|
|||||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("UserId");
|
b.HasKey("UserId");
|
||||||
|
|
||||||
@@ -383,22 +383,22 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<bool>("IsUsed")
|
b.Property<bool>("IsUsed")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("tinyint(1)")
|
.HasColumnType("boolean")
|
||||||
.HasDefaultValue(false);
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
b.Property<byte[]>("PublicKey")
|
b.Property<byte[]>("PublicKey")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<DateTime>("UploadedAt")
|
b.Property<DateTime>("UploadedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("UserCryptoSessionId")
|
b.Property<Guid>("UserCryptoSessionId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -413,18 +413,18 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<byte[]>("PublicSignedPreKey")
|
b.Property<byte[]>("PublicSignedPreKey")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<byte[]>("SignedPreKeySignature")
|
b.Property<byte[]>("SignedPreKeySignature")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<Guid>("UserCryptoSessionId")
|
b.Property<Guid>("UserCryptoSessionId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -438,14 +438,14 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<byte[]>("PublicIdentityKey")
|
b.Property<byte[]>("PublicIdentityKey")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<Guid>("UserSessionId")
|
b.Property<Guid>("UserSessionId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -459,31 +459,31 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateOnly>("CreatedOn")
|
b.Property<DateOnly>("CreatedOn")
|
||||||
.HasColumnType("date");
|
.HasColumnType("date");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<Guid>("IconId")
|
b.Property<Guid>("IconId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("InviteId")
|
b.Property<Guid>("InviteId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
b.Property<string>("PasswordHash")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Username")
|
b.Property<string>("Username")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("WasOnline")
|
b.Property<DateTime>("WasOnline")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -496,28 +496,28 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("DeviceInfo")
|
b.Property<string>("DeviceInfo")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("varchar(256)");
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
b.Property<DateTime>("ExpiresAt")
|
b.Property<DateTime>("ExpiresAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<bool>("IsRevoked")
|
b.Property<bool>("IsRevoked")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("RefreshToken")
|
b.Property<string>("RefreshToken")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
+223
-119
@@ -11,89 +11,76 @@ namespace Govor.Data.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.AlterDatabase()
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ChatGroups",
|
name: "ChatGroups",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
|
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false),
|
||||||
Description = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: false)
|
ImageId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
IsChannel = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
ImageId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
IsPrivate = table.Column<bool>(type: "boolean", nullable: false)
|
||||||
IsChannel = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
||||||
IsPrivate = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_ChatGroups", x => x.Id);
|
table.PrimaryKey("PK_ChatGroups", x => x.Id);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Invitations",
|
name: "Invitations",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
IsAdmin = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
Code = table.Column<string>(type: "longtext", nullable: false)
|
Code = table.Column<string>(type: "text", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
Description = table.Column<string>(type: "text", nullable: false),
|
||||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
EndDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
DateCreated = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
MaxParticipants = table.Column<int>(type: "integer", nullable: false)
|
||||||
EndDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
MaxParticipants = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Invitations", x => x.Id);
|
table.PrimaryKey("PK_Invitations", x => x.Id);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "MediaFiles",
|
name: "MediaFiles",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
Url = table.Column<string>(type: "longtext", nullable: false)
|
UploaderId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
Url = table.Column<string>(type: "text", nullable: false),
|
||||||
MediaType = table.Column<string>(type: "longtext", nullable: false)
|
MediaType = table.Column<string>(type: "text", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
MineType = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
||||||
MineType = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
|
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
DateCreated = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_MediaFiles", x => x.Id);
|
table.PrimaryKey("PK_MediaFiles", x => x.Id);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "PrivateChats",
|
name: "PrivateChats",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
UserAId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
UserAId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
UserBId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
UserBId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_PrivateChats", x => x.Id);
|
table.PrimaryKey("PK_PrivateChats", x => x.Id);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "GroupAdmins",
|
name: "GroupAdmins",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
GroupId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
GroupId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
UserId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -104,24 +91,20 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "ChatGroups",
|
principalTable: "ChatGroups",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Users",
|
name: "Users",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
Username = table.Column<string>(type: "longtext", nullable: false)
|
Username = table.Column<string>(type: "text", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
Description = table.Column<string>(type: "text", nullable: false),
|
||||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
PasswordHash = table.Column<string>(type: "text", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
IconId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
PasswordHash = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
IconId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
||||||
CreatedOn = table.Column<DateOnly>(type: "date", nullable: false),
|
CreatedOn = table.Column<DateOnly>(type: "date", nullable: false),
|
||||||
WasOnline = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
WasOnline = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
InviteId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
InviteId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -132,41 +115,44 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "Invitations",
|
principalTable: "Invitations",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Messages",
|
name: "Messages",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
SenderId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
SenderId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
RecipientId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
RecipientId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
RecipientType = table.Column<int>(type: "int", nullable: false),
|
RecipientType = table.Column<int>(type: "integer", nullable: false),
|
||||||
EncryptedContent = table.Column<string>(type: "longtext", nullable: false)
|
EncryptedContent = table.Column<string>(type: "text", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
SentAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
SentAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
IsEdited = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
IsEdited = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
EditedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||||
EditedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
ReplyToMessageId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||||
ReplyToMessageId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
ChatGroupId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||||
PrivateChatId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
|
PrivateChatId = table.Column<Guid>(type: "uuid", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Messages", x => x.Id);
|
table.PrimaryKey("PK_Messages", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Messages_ChatGroups_ChatGroupId",
|
||||||
|
column: x => x.ChatGroupId,
|
||||||
|
principalTable: "ChatGroups",
|
||||||
|
principalColumn: "Id");
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Messages_PrivateChats_PrivateChatId",
|
name: "FK_Messages_PrivateChats_PrivateChatId",
|
||||||
column: x => x.PrivateChatId,
|
column: x => x.PrivateChatId,
|
||||||
principalTable: "PrivateChats",
|
principalTable: "PrivateChats",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id");
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Admins",
|
name: "Admins",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
UserId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -177,17 +163,16 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Friendships",
|
name: "Friendships",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
RequesterId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
RequesterId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
AddresseeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
AddresseeId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
Status = table.Column<int>(type: "int", nullable: false)
|
Status = table.Column<int>(type: "integer", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -204,23 +189,20 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "GroupInvitations",
|
name: "GroupInvitations",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
GroupId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
GroupId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
UserMakerId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
UserMakerId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
InvitationCode = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
|
InvitationCode = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false),
|
||||||
Description = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: false)
|
EndDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
EndDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
MaxParticipants = table.Column<int>(type: "integer", nullable: false)
|
||||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
MaxParticipants = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -237,16 +219,38 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "UserSessions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
RefreshToken = table.Column<string>(type: "text", nullable: false),
|
||||||
|
DeviceInfo = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
IsRevoked = table.Column<bool>(type: "boolean", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_UserSessions", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_UserSessions_Users_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "MediaAttachments",
|
name: "MediaAttachments",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
MessageId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
MediaFileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
MediaFileId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -263,19 +267,17 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "Messages",
|
principalTable: "Messages",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "MessageReactions",
|
name: "MessageReactions",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
MessageId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
ReactionCode = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
ReactionCode = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
ReactedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
ReactedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -292,17 +294,16 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "MessageViews",
|
name: "MessageViews",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
MessageId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
ViewedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
ViewedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -313,18 +314,18 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "Messages",
|
principalTable: "Messages",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "GroupMemberships",
|
name: "GroupMemberships",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
GroupId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
GroupId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
InvitationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
InvitationId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||||
IsBanned = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
IsBanned = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
MemberSince = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -341,8 +342,67 @@ namespace Govor.Data.Migrations
|
|||||||
principalTable: "GroupInvitations",
|
principalTable: "GroupInvitations",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.SetNull);
|
onDelete: ReferentialAction.SetNull);
|
||||||
})
|
});
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "UserCryptoSessions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
UserSessionId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
PublicIdentityKey = table.Column<byte[]>(type: "bytea", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_UserCryptoSessions", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_UserCryptoSessions_UserSessions_UserSessionId",
|
||||||
|
column: x => x.UserSessionId,
|
||||||
|
principalTable: "UserSessions",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "OneTimePreKeys",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
UserCryptoSessionId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
PublicKey = table.Column<byte[]>(type: "bytea", nullable: false),
|
||||||
|
IsUsed = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
|
||||||
|
UploadedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_OneTimePreKeys", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_OneTimePreKeys_UserCryptoSessions_UserCryptoSessionId",
|
||||||
|
column: x => x.UserCryptoSessionId,
|
||||||
|
principalTable: "UserCryptoSessions",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SignedPreKeys",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
UserCryptoSessionId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
PublicSignedPreKey = table.Column<byte[]>(type: "bytea", nullable: false),
|
||||||
|
SignedPreKeySignature = table.Column<byte[]>(type: "bytea", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SignedPreKeys", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_SignedPreKeys_UserCryptoSessions_UserCryptoSessionId",
|
||||||
|
column: x => x.UserCryptoSessionId,
|
||||||
|
principalTable: "UserCryptoSessions",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Friendships_AddresseeId",
|
name: "IX_Friendships_AddresseeId",
|
||||||
@@ -400,6 +460,11 @@ namespace Govor.Data.Migrations
|
|||||||
table: "MessageReactions",
|
table: "MessageReactions",
|
||||||
column: "UserId");
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Messages_ChatGroupId",
|
||||||
|
table: "Messages",
|
||||||
|
column: "ChatGroupId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Messages_PrivateChatId",
|
name: "IX_Messages_PrivateChatId",
|
||||||
table: "Messages",
|
table: "Messages",
|
||||||
@@ -411,10 +476,37 @@ namespace Govor.Data.Migrations
|
|||||||
columns: new[] { "MessageId", "UserId" },
|
columns: new[] { "MessageId", "UserId" },
|
||||||
unique: true);
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_OneTimePreKeys_UploadedAt",
|
||||||
|
table: "OneTimePreKeys",
|
||||||
|
column: "UploadedAt");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_OneTimePreKeys_UserCryptoSessionId_IsUsed",
|
||||||
|
table: "OneTimePreKeys",
|
||||||
|
columns: new[] { "UserCryptoSessionId", "IsUsed" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_SignedPreKeys_UserCryptoSessionId",
|
||||||
|
table: "SignedPreKeys",
|
||||||
|
column: "UserCryptoSessionId",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_UserCryptoSessions_UserSessionId",
|
||||||
|
table: "UserCryptoSessions",
|
||||||
|
column: "UserSessionId",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Users_InviteId",
|
name: "IX_Users_InviteId",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
column: "InviteId");
|
column: "InviteId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_UserSessions_UserId",
|
||||||
|
table: "UserSessions",
|
||||||
|
column: "UserId");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -441,6 +533,12 @@ namespace Govor.Data.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "MessageViews");
|
name: "MessageViews");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "OneTimePreKeys");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SignedPreKeys");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "GroupInvitations");
|
name: "GroupInvitations");
|
||||||
|
|
||||||
@@ -450,14 +548,20 @@ namespace Govor.Data.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Messages");
|
name: "Messages");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "UserCryptoSessions");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ChatGroups");
|
name: "ChatGroups");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Users");
|
name: "PrivateChats");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "PrivateChats");
|
name: "UserSessions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Users");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Invitations");
|
name: "Invitations");
|
||||||
+255
-125
@@ -3,17 +3,17 @@ using System;
|
|||||||
using Govor.Data;
|
using Govor.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace Govor.Data.Migrations
|
namespace Govor.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(GovorDbContext))]
|
[DbContext(typeof(GovorDbContext))]
|
||||||
[Migration("20250718130008_usersessions")]
|
[Migration("20251103060801_MediaOwnerTypeAdded")]
|
||||||
partial class usersessions
|
partial class MediaOwnerTypeAdded
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -21,34 +21,34 @@ namespace Govor.Data.Migrations
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.6")
|
.HasAnnotation("ProductVersion", "8.0.6")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
.HasColumnType("varchar(500)");
|
.HasColumnType("character varying(500)");
|
||||||
|
|
||||||
b.Property<Guid>("ImageId")
|
b.Property<Guid>("ImageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<bool>("IsChannel")
|
b.Property<bool>("IsChannel")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsPrivate")
|
b.Property<bool>("IsPrivate")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(100)
|
.HasMaxLength(100)
|
||||||
.HasColumnType("varchar(100)");
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -59,16 +59,16 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("AddresseeId")
|
b.Property<Guid>("AddresseeId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("RequesterId")
|
b.Property<Guid>("RequesterId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -83,13 +83,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -102,32 +102,32 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
.HasColumnType("varchar(500)");
|
.HasColumnType("character varying(500)");
|
||||||
|
|
||||||
b.Property<DateTime>("EndDate")
|
b.Property<DateTime>("EndDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("InvitationCode")
|
b.Property<string>("InvitationCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(200)
|
.HasMaxLength(200)
|
||||||
.HasColumnType("varchar(200)");
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
b.Property<int>("MaxParticipants")
|
b.Property<int>("MaxParticipants")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid>("UserMakerId")
|
b.Property<Guid>("UserMakerId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -142,20 +142,22 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid?>("InvitationId")
|
b.Property<Guid?>("InvitationId")
|
||||||
.IsRequired()
|
.HasColumnType("uuid");
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.Property<bool>("IsBanned")
|
b.Property<bool>("IsBanned")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTime>("MemberSince")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -170,30 +172,30 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Code")
|
b.Property<string>("Code")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreated")
|
b.Property<DateTime>("DateCreated")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("EndDate")
|
b.Property<DateTime>("EndDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<bool>("IsActive")
|
b.Property<bool>("IsActive")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsAdmin")
|
b.Property<bool>("IsAdmin")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<int>("MaxParticipants")
|
b.Property<int>("MaxParticipants")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -204,26 +206,32 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreated")
|
b.Property<DateTime>("DateCreated")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("MediaType")
|
b.Property<string>("MediaType")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("MineType")
|
b.Property<string>("MineType")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("varchar(128)");
|
.HasColumnType("character varying(128)");
|
||||||
|
|
||||||
|
b.Property<Guid?>("OwnerId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("OwnerType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid>("UploaderId")
|
b.Property<Guid>("UploaderId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Url")
|
b.Property<string>("Url")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -234,13 +242,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MediaFileId")
|
b.Property<Guid>("MediaFileId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -255,38 +263,38 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid?>("ChatGroupId")
|
b.Property<Guid?>("ChatGroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime?>("EditedAt")
|
b.Property<DateTime?>("EditedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("EncryptedContent")
|
b.Property<string>("EncryptedContent")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<bool>("IsEdited")
|
b.Property<bool>("IsEdited")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<Guid?>("PrivateChatId")
|
b.Property<Guid?>("PrivateChatId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("RecipientId")
|
b.Property<Guid>("RecipientId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<int>("RecipientType")
|
b.Property<int>("RecipientType")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid?>("ReplyToMessageId")
|
b.Property<Guid?>("ReplyToMessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("SenderId")
|
b.Property<Guid>("SenderId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("SentAt")
|
b.Property<DateTime>("SentAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -301,21 +309,21 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("ReactedAt")
|
b.Property<DateTime>("ReactedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("ReactionCode")
|
b.Property<string>("ReactionCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("varchar(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -331,16 +339,16 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("ViewedAt")
|
b.Property<DateTime>("ViewedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -354,92 +362,134 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserAId")
|
b.Property<Guid>("UserAId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserBId")
|
b.Property<Guid>("UserBId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("PrivateChats");
|
b.ToTable("PrivateChats");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.UserSession", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.Property<string>("DeviceInfo")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(200)
|
|
||||||
.HasColumnType("varchar(200)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("ExpiresAt")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRevoked")
|
|
||||||
.HasColumnType("tinyint(1)");
|
|
||||||
|
|
||||||
b.Property<string>("RefreshToken")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("UserSessions");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("UserId");
|
b.HasKey("UserId");
|
||||||
|
|
||||||
b.ToTable("Admins");
|
b.ToTable("Admins");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.OneTimePreKey", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("IsUsed")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
b.Property<byte[]>("PublicKey")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UploadedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserCryptoSessionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UploadedAt");
|
||||||
|
|
||||||
|
b.HasIndex("UserCryptoSessionId", "IsUsed");
|
||||||
|
|
||||||
|
b.ToTable("OneTimePreKeys");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.SignedPreKey", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<byte[]>("PublicSignedPreKey")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<byte[]>("SignedPreKeySignature")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserCryptoSessionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserCryptoSessionId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("SignedPreKeys");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.UserCryptoSession", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<byte[]>("PublicIdentityKey")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserSessionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserSessionId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("UserCryptoSessions");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateOnly>("CreatedOn")
|
b.Property<DateOnly>("CreatedOn")
|
||||||
.HasColumnType("date");
|
.HasColumnType("date");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<Guid>("IconId")
|
b.Property<Guid>("IconId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("InviteId")
|
b.Property<Guid>("InviteId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
b.Property<string>("PasswordHash")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Username")
|
b.Property<string>("Username")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("WasOnline")
|
b.Property<DateTime>("WasOnline")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -448,6 +498,40 @@ namespace Govor.Data.Migrations
|
|||||||
b.ToTable("Users");
|
b.ToTable("Users");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("DeviceInfo")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExpiresAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("IsRevoked")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("RefreshToken")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserSessions");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Friendship", b =>
|
modelBuilder.Entity("Govor.Core.Models.Friendship", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Govor.Core.Models.Users.User", "Addressee")
|
b.HasOne("Govor.Core.Models.Users.User", "Addressee")
|
||||||
@@ -504,8 +588,7 @@ namespace Govor.Data.Migrations
|
|||||||
b.HasOne("Govor.Core.Models.GroupInvitation", null)
|
b.HasOne("Govor.Core.Models.GroupInvitation", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("InvitationId")
|
.HasForeignKey("InvitationId")
|
||||||
.OnDelete(DeleteBehavior.SetNull)
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
.IsRequired();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
|
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
|
||||||
@@ -566,15 +649,6 @@ namespace Govor.Data.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.UserSession", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Govor.Core.Models.Users.User", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Govor.Core.Models.Users.User", "User")
|
b.HasOne("Govor.Core.Models.Users.User", "User")
|
||||||
@@ -586,6 +660,39 @@ namespace Govor.Data.Migrations
|
|||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.OneTimePreKey", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Govor.Core.Models.Users.Crypto.UserCryptoSession", "UserCryptoSession")
|
||||||
|
.WithMany("OneTimePreKeys")
|
||||||
|
.HasForeignKey("UserCryptoSessionId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("UserCryptoSession");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.SignedPreKey", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Govor.Core.Models.Users.Crypto.UserCryptoSession", "UserCryptoSession")
|
||||||
|
.WithOne("SignedPreKey")
|
||||||
|
.HasForeignKey("Govor.Core.Models.Users.Crypto.SignedPreKey", "UserCryptoSessionId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("UserCryptoSession");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.UserCryptoSession", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Govor.Core.Models.Users.UserSession", "UserSession")
|
||||||
|
.WithOne("CryptoSession")
|
||||||
|
.HasForeignKey("Govor.Core.Models.Users.Crypto.UserCryptoSession", "UserSessionId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("UserSession");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Govor.Core.Models.Invitation", "Invite")
|
b.HasOne("Govor.Core.Models.Invitation", "Invite")
|
||||||
@@ -597,6 +704,15 @@ namespace Govor.Data.Migrations
|
|||||||
b.Navigation("Invite");
|
b.Navigation("Invite");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Govor.Core.Models.Users.User", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Admins");
|
b.Navigation("Admins");
|
||||||
@@ -627,12 +743,26 @@ namespace Govor.Data.Migrations
|
|||||||
b.Navigation("Messages");
|
b.Navigation("Messages");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.UserCryptoSession", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("OneTimePreKeys");
|
||||||
|
|
||||||
|
b.Navigation("SignedPreKey")
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ReceivedFriendRequests");
|
b.Navigation("ReceivedFriendRequests");
|
||||||
|
|
||||||
b.Navigation("SentFriendRequests");
|
b.Navigation("SentFriendRequests");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("CryptoSession")
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+15
-6
@@ -6,25 +6,34 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace Govor.Data.Migrations
|
namespace Govor.Data.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class AddUploaderIdToMediaFile : Migration
|
public partial class MediaOwnerTypeAdded : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.AddColumn<Guid>(
|
migrationBuilder.AddColumn<Guid>(
|
||||||
name: "UploaderId",
|
name: "OwnerId",
|
||||||
table: "MediaFiles",
|
table: "MediaFiles",
|
||||||
type: "char(36)",
|
type: "uuid",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "OwnerType",
|
||||||
|
table: "MediaFiles",
|
||||||
|
type: "integer",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
defaultValue: 0);
|
||||||
collation: "ascii_general_ci");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "UploaderId",
|
name: "OwnerId",
|
||||||
|
table: "MediaFiles");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OwnerType",
|
||||||
table: "MediaFiles");
|
table: "MediaFiles");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,8 @@ using System;
|
|||||||
using Govor.Data;
|
using Govor.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
@@ -18,34 +18,34 @@ namespace Govor.Data.Migrations
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.6")
|
.HasAnnotation("ProductVersion", "8.0.6")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
.HasColumnType("varchar(500)");
|
.HasColumnType("character varying(500)");
|
||||||
|
|
||||||
b.Property<Guid>("ImageId")
|
b.Property<Guid>("ImageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<bool>("IsChannel")
|
b.Property<bool>("IsChannel")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsPrivate")
|
b.Property<bool>("IsPrivate")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(100)
|
.HasMaxLength(100)
|
||||||
.HasColumnType("varchar(100)");
|
.HasColumnType("character varying(100)");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -56,16 +56,16 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("AddresseeId")
|
b.Property<Guid>("AddresseeId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("RequesterId")
|
b.Property<Guid>("RequesterId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -80,13 +80,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -99,32 +99,32 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
.HasColumnType("varchar(500)");
|
.HasColumnType("character varying(500)");
|
||||||
|
|
||||||
b.Property<DateTime>("EndDate")
|
b.Property<DateTime>("EndDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("InvitationCode")
|
b.Property<string>("InvitationCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(200)
|
.HasMaxLength(200)
|
||||||
.HasColumnType("varchar(200)");
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
b.Property<int>("MaxParticipants")
|
b.Property<int>("MaxParticipants")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid>("UserMakerId")
|
b.Property<Guid>("UserMakerId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -139,22 +139,22 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("GroupId")
|
b.Property<Guid>("GroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid?>("InvitationId")
|
b.Property<Guid?>("InvitationId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<bool>("IsBanned")
|
b.Property<bool>("IsBanned")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<DateTime>("MemberSince")
|
b.Property<DateTime>("MemberSince")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -169,30 +169,30 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Code")
|
b.Property<string>("Code")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreated")
|
b.Property<DateTime>("DateCreated")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("EndDate")
|
b.Property<DateTime>("EndDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<bool>("IsActive")
|
b.Property<bool>("IsActive")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsAdmin")
|
b.Property<bool>("IsAdmin")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<int>("MaxParticipants")
|
b.Property<int>("MaxParticipants")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -203,26 +203,32 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreated")
|
b.Property<DateTime>("DateCreated")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("MediaType")
|
b.Property<string>("MediaType")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("MineType")
|
b.Property<string>("MineType")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("varchar(128)");
|
.HasColumnType("character varying(128)");
|
||||||
|
|
||||||
|
b.Property<Guid?>("OwnerId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("OwnerType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid>("UploaderId")
|
b.Property<Guid>("UploaderId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Url")
|
b.Property<string>("Url")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -233,13 +239,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MediaFileId")
|
b.Property<Guid>("MediaFileId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -254,38 +260,38 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid?>("ChatGroupId")
|
b.Property<Guid?>("ChatGroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime?>("EditedAt")
|
b.Property<DateTime?>("EditedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("EncryptedContent")
|
b.Property<string>("EncryptedContent")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<bool>("IsEdited")
|
b.Property<bool>("IsEdited")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<Guid?>("PrivateChatId")
|
b.Property<Guid?>("PrivateChatId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("RecipientId")
|
b.Property<Guid>("RecipientId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<int>("RecipientType")
|
b.Property<int>("RecipientType")
|
||||||
.HasColumnType("int");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid?>("ReplyToMessageId")
|
b.Property<Guid?>("ReplyToMessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("SenderId")
|
b.Property<Guid>("SenderId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("SentAt")
|
b.Property<DateTime>("SentAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -300,21 +306,21 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("ReactedAt")
|
b.Property<DateTime>("ReactedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("ReactionCode")
|
b.Property<string>("ReactionCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("varchar(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -330,16 +336,16 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("MessageId")
|
b.Property<Guid>("MessageId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("ViewedAt")
|
b.Property<DateTime>("ViewedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -353,13 +359,13 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserAId")
|
b.Property<Guid>("UserAId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("UserBId")
|
b.Property<Guid>("UserBId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -369,7 +375,7 @@ namespace Govor.Data.Migrations
|
|||||||
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("UserId");
|
b.HasKey("UserId");
|
||||||
|
|
||||||
@@ -380,22 +386,22 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<bool>("IsUsed")
|
b.Property<bool>("IsUsed")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("tinyint(1)")
|
.HasColumnType("boolean")
|
||||||
.HasDefaultValue(false);
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
b.Property<byte[]>("PublicKey")
|
b.Property<byte[]>("PublicKey")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<DateTime>("UploadedAt")
|
b.Property<DateTime>("UploadedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid>("UserCryptoSessionId")
|
b.Property<Guid>("UserCryptoSessionId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -410,18 +416,18 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<byte[]>("PublicSignedPreKey")
|
b.Property<byte[]>("PublicSignedPreKey")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<byte[]>("SignedPreKeySignature")
|
b.Property<byte[]>("SignedPreKeySignature")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<Guid>("UserCryptoSessionId")
|
b.Property<Guid>("UserCryptoSessionId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -435,14 +441,14 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<byte[]>("PublicIdentityKey")
|
b.Property<byte[]>("PublicIdentityKey")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longblob");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<Guid>("UserSessionId")
|
b.Property<Guid>("UserSessionId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -456,31 +462,31 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateOnly>("CreatedOn")
|
b.Property<DateOnly>("CreatedOn")
|
||||||
.HasColumnType("date");
|
.HasColumnType("date");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<Guid>("IconId")
|
b.Property<Guid>("IconId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("InviteId")
|
b.Property<Guid>("InviteId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
b.Property<string>("PasswordHash")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Username")
|
b.Property<string>("Username")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("WasOnline")
|
b.Property<DateTime>("WasOnline")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@@ -493,28 +499,28 @@ namespace Govor.Data.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("DeviceInfo")
|
b.Property<string>("DeviceInfo")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("varchar(256)");
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
b.Property<DateTime>("ExpiresAt")
|
b.Property<DateTime>("ExpiresAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<bool>("IsRevoked")
|
b.Property<bool>("IsRevoked")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("RefreshToken")
|
b.Property<string>("RefreshToken")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ public class AdminsRepository(GovorDbContext context, IObjectValidator<Admin> va
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found admin by given id {admin.UserId}");
|
throw new UpdateException($"Not found admin by given id {admin.UserId}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ public class FriendshipsRepository : IFriendshipsRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found friendship by given id {friendship.Id}");
|
throw new UpdateException($"Not found friendship by given id {friendship.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ public class GroupRepository : IGroupsRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found group by given id {group.Id}");
|
throw new UpdateException($"Not found group by given id {group.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ public class InvitesRepository : IInvitesRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found invitation by given id {invitation.Id}");
|
throw new UpdateException($"Not found invitation by given id {invitation.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class MediaAttachmentsRepository : IMediaAttachmentsRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found attachments by given id {attachments.Id}");
|
throw new UpdateException($"Not found attachments by given id {attachments.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -128,6 +128,8 @@ public class MessagesRepository : IMessagesRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found message by given id {message.Id}");
|
throw new UpdateException($"Not found message by given id {message.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ public class PrivateChatsRepository : IPrivateChatsRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found private chat by given id {chat.Id}");
|
throw new UpdateException($"Not found private chat by given id {chat.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ public class UserSessionsRepository : IUserSessionsRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found user session by given id {userSession.Id}");
|
throw new UpdateException($"Not found user session by given id {userSession.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ public class UsersRepository : IUsersRepository
|
|||||||
|
|
||||||
if (rowsAffected == 0)
|
if (rowsAffected == 0)
|
||||||
throw new UpdateException($"Not found user by given id {user.Id}");
|
throw new UpdateException($"Not found user by given id {user.Id}");
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user