Refactor: migrate Core -> Domain and reorganize projects

Large refactor that renames/moves core types into a new Govor.Domain surface and reorganizes the Application layer. Models, configurations, migrations and many files moved from Govor.Core/Govor.Data to Govor.Domain; numerous Application services, interfaces and implementations were relocated or added (authentication, friends, messages, medias, push notifications, user sessions, storage, synching, private chats, etc.). Tests updated to use Govor.Domain namespaces and adjusted project references (removed Govor.Data reference from API tests). Also updated API, Hub and mapping code and project files to reflect the new structure and naming. This is primarily a codebase-wide namespace and module reorganization to establish a Domain project and restructure application services.
This commit is contained in:
Artemy
2026-07-16 19:27:45 +07:00
parent 1d35356c8c
commit 6d1c53beeb
371 changed files with 2729 additions and 6694 deletions
+10
View File
@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace Govor.Domain.Models.Users;
public class Admin
{
[Key]
public Guid UserId { get; set; }
public User User { get; set; } = null!;
}
@@ -0,0 +1,12 @@
namespace Govor.Domain.Models.Users.Crypto;
public class OneTimePreKey
{
public Guid Id { get; set; }
public Guid UserCryptoSessionId { get; set; }
public UserCryptoSession UserCryptoSession { get; set; }
public byte[] PublicKey { get; set; }
public bool IsUsed { get; set; }
public DateTime UploadedAt { get; set; } = DateTime.UtcNow;
}
@@ -0,0 +1,10 @@
namespace Govor.Domain.Models.Users.Crypto;
public class SignedPreKey
{
public Guid Id { get; set; }
public Guid UserCryptoSessionId { get; set; }
public UserCryptoSession UserCryptoSession { get; set; }
public byte[] PublicSignedPreKey { get; set; }
public byte[] SignedPreKeySignature { get; set; }
}
@@ -0,0 +1,14 @@
namespace Govor.Domain.Models.Users.Crypto;
public class UserCryptoSession
{
public Guid Id { get; set; }
public Guid UserSessionId { get; set; }
public UserSession UserSession { get; set; }
public byte[] PublicIdentityKey { get; set; }
public SignedPreKey SignedPreKey { get; set; }
public ICollection<OneTimePreKey> OneTimePreKeys { get; set; }
}
@@ -0,0 +1,15 @@
namespace Govor.Domain.Models.Users;
public class PrivacyRuleEntity
{
public Guid Id { get; set; }
public Guid OwnerId { get; set; }
public PrivacyTargetArea Area { get; set; }
public WhoCan AccessType { get; set; } // Everyone, Friends, None
public List<Guid> Whitelist { get; set; } = new();
public List<Guid> Blacklist { get; set; } = new();
public PrivacyUserSettings OwnerSettings { get; set; } = null!;
}
@@ -0,0 +1,47 @@
namespace Govor.Domain.Models.Users;
public class PrivacyUserSettings
{
public Guid UserId { get; set; }
public bool IsGlobalAccount { get; set; }
public DeletingMessagesVia DeletingVia { get; set; }
public int DeletingIn { get; set; }
public bool IsInvisibleMode { get; set; }
public List<PrivacyRuleEntity> Rules { get; set; } = new();
}
public enum WhoCan
{
None = 0,
OnlyFriends = 1,
Everyone = 2,
}
public enum DeletingMessagesVia
{
None = 0,
Hours = 1,
Days = 2,
Months = 3,
Years = 4
}
public enum PrivacyTargetArea
{
CanSend = 0,
CanSeeTimeWas = 1,
CanSeeImage = 2,
CanSendImage = 3,
}
public enum PrivacyRuleType
{
Allow = 0,
Deny = 1
}
+25
View File
@@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
namespace Govor.Domain.Models.Users;
public class User
{
public Guid Id {get; set;}
public string Username {get; set;}
public string Description {get; set;}
public string PasswordHash {get; set;}
public Guid IconId {get; set;}
public DateOnly CreatedOn {get; set;}
public DateTime WasOnline {get; set;}
public Guid InviteId {get; set;}
public Invitation? Invite { get; set; }
public List<Friendship> SentFriendRequests { get; set; } = new();
public List<Friendship> ReceivedFriendRequests { get; set; } = new();
public override bool Equals(object? obj)
{
var user = obj as User;
return Id == user.Id;
}
}
@@ -0,0 +1,18 @@
namespace Govor.Domain.Models.Users;
public class UserPushToken
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid UserId { get; set; }
public Guid? UserSessionId { get; set; }
public string Token { get; set; } = string.Empty; // FCM/APNs
public string Provider { get; set; } = "FCM"; // FCM | APNs | Web | Huawei
public string Platform { get; set; } = string.Empty; // android | ios | web
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
public DateTime? LastUsedAt { get; set; }
public bool IsActive { get; set; } = true;
}
+36
View File
@@ -0,0 +1,36 @@
using Govor.Domain.Models.Users.Crypto;
namespace Govor.Domain.Models.Users;
public class UserSession
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid UserId { get; set; }
public string RefreshTokenHash { get; set; } = string.Empty;
public string DeviceInfo { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime ExpiresAt { get; set; }
public bool IsRevoked { get; set; } = false;
public User User { get; set; } = null!;
public UserCryptoSession CryptoSession { get; set; } = null!;
public override bool Equals(object? obj)
{
if (obj is not UserSession userSession)
return false;
return Id == userSession.Id &&
UserId == userSession.UserId &&
RefreshTokenHash == userSession.RefreshTokenHash &&
DeviceInfo == userSession.DeviceInfo &&
CreatedAt == userSession.CreatedAt &&
ExpiresAt == userSession.ExpiresAt &&
IsRevoked == userSession.IsRevoked;
}
public override int GetHashCode()
{
return HashCode.Combine(Id, UserId, RefreshTokenHash, DeviceInfo, CreatedAt, ExpiresAt, IsRevoked);
}
}