-
-
Save dcomartin/a6d35607da592eb035b772087aac1c0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GroupMembership | |
| { | |
| private const int MaxMembers = 100_000; | |
| private readonly HashSet<Guid> _members = new(); | |
| public Guid GroupChatId { get; private set; } | |
| public GroupMembership(Guid groupChatId) | |
| { | |
| GroupChatId = groupChatId; | |
| } | |
| public void AddMember(Guid userId) | |
| { | |
| if (_members.Count >= MaxMembers) | |
| throw new InvalidOperationException("Too many members"); | |
| _members.Add(userId); | |
| } | |
| public void RemoveMember(Guid userId) | |
| { | |
| _members.Remove(userId); | |
| } | |
| public IReadOnlyCollection<Guid> Members => _members; | |
| } | |
| public class GroupChat | |
| { | |
| public Guid Id { get; private set; } | |
| public GroupChat(Guid id) | |
| { | |
| Id = id; | |
| } | |
| public void PostMessage(Guid senderUserId, string message) | |
| { | |
| // Assume sender membership is already validated externally | |
| // Here we handle domain logic related to messaging | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment