MessageRepository + Tests

+ GetAllAsync rework
+ FindByIdAsync
+ rework FindBySenderAndReceiverIdAsync
This commit is contained in:
Artemy
2025-06-22 12:07:06 +07:00
parent a6e8ba1a65
commit 203bb5e5a4
5 changed files with 57 additions and 12 deletions
+15
View File
@@ -16,6 +16,21 @@ public class Message
public Guid? ReplyToMessageId { get; set; }
public Message? ReplyToMessage { get; set; } // navigation
public override bool Equals(object? obj)
{
if (obj is not Message other) return false;
return Id == other.Id &&
SenderId == other.SenderId &&
RecipientId == other.RecipientId &&
RecipientType == other.RecipientType &&
EncryptedContent == other.EncryptedContent &&
SentAt == other.SentAt &&
IsEdited == other.IsEdited &&
EditedAt == other.EditedAt &&
ReplyToMessageId == other.ReplyToMessageId;
}
}
public enum RecipientType
@@ -8,6 +8,6 @@ public interface IMessagesReader
Task<Message> FindByIdAsync(Guid messageId);
Task<List<Message>> FindBySenderIdAsync(Guid senderId);
Task<List<Message>> FindByReceiverIdAsync(Guid receiverId);
Task<List<Message>> FindBySenderAndReceiverIdAsync(Guid senderId, Guid receiverId);
Task<List<Message>> FindBySenderAndReceiverIdAsync(Guid senderId, Guid receiverId, RecipientType recipientType = RecipientType.User);
Task<List<Message>> FindBySentAtAsync(DateTime date);
}