mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Add private chat support and group model enhancements
Introduces repositories, validators, and integration tests for private chats. Refactors group-related models to support invitations and memberships, updates group repository interfaces and implementations, and enhances message service logic to handle private chat creation and retrieval. Also registers new services and validators in DI, and updates related tests.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Govor.Core.Models;
|
||||
|
||||
namespace Govor.Core.Infrastructure.Validators;
|
||||
|
||||
public class PrivateChatValidator : IObjectValidator<PrivateChat>
|
||||
{
|
||||
public void Validate(PrivateChat chat)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(chat is null)
|
||||
throw new ArgumentNullException(nameof(chat));
|
||||
if(chat.Id == Guid.Empty)
|
||||
throw new ArgumentException("Id cannot be empty", nameof(chat));
|
||||
if(chat.UserAId == Guid.Empty)
|
||||
throw new ArgumentException("UserAId cannot be empty", nameof(chat.UserAId));
|
||||
if(chat.UserBId == Guid.Empty)
|
||||
throw new ArgumentException("UserBId cannot be empty", nameof(chat.UserBId));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidObjectException<PrivateChat>(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryValidate(PrivateChat chat)
|
||||
{
|
||||
try
|
||||
{
|
||||
Validate(chat);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user