This commit is contained in:
2026-08-31 14:42:22 +08:00
72 changed files with 2479 additions and 168 deletions
@@ -52,6 +52,7 @@ namespace MessageService.Domain.Entities
UnreadCount = unreadCount;
ChatType = chatType;
LastMessage = lastMessage;
ModificationTime = DateTime.Now;
StreamKey = ChatType == ChatType.GROUP ? StreamKeyBuilder.Group(targetId) : StreamKeyBuilder.Private(userId, targetId);
AddDomainEvent(new ConversationCreatedDomainEvent(this));
}
@@ -61,18 +62,32 @@ namespace MessageService.Domain.Entities
if (LastReadSequenceId != null)
{
LastReadSequenceId = LastReadSequenceId.Value;
this.NotifyModified();
}
if (unreadCount != null)
{
UnreadCount += unreadCount.Value;
NotifyModified();
}
if (lastMsg != null)
{
LastMessage = lastMsg;
NotifyModified();
}
}
/// <summary>
/// 标记会话已读(清零未读数,更新最后已读消息序列号)
/// </summary>
public void MarkAsRead(long? lastReadSequenceId)
{
UnreadCount = 0;
if (lastReadSequenceId.HasValue)
LastReadSequenceId = lastReadSequenceId.Value;
}
public void UpdateProfile(string name, string avatar)
{
TargetAvatar = avatar;