public void InviteMember(Guid actorId, Guid targetUserId, string nickname)
        {
            if (GetMember(targetUserId) != null)
            {
                return;
            }

            var actor = GetMember(actorId);

            if (actor == null)
            {
                throw new UserNotFoundException(actorId);
            }

            if (!CanInvite(actor))
            {
                throw new InsufficientRightsException(actorId, nameof(InviteMember));
            }

            var newChatMember = new ChatMember(targetUserId, nickname, ChatMemberRole.User);
            var memberList    = new List <ChatMember>(Members);

            memberList.Add(newChatMember);
            Members = memberList;
        }
 protected override bool CanDemote(ChatMember chatMember)
 {
     return(chatMember.Id == CreatorId);
 }
 protected override bool CanInvite(ChatMember chatMember)
 {
     return(chatMember.Role == ChatMemberRole.Admin);
 }
 protected override bool CanDeleteMessage(ChatMember chatMember, Message message)
 {
     return(chatMember.Role == ChatMemberRole.Admin);
 }
 protected override bool CanSendMessage(ChatMember chatMember)
 {
     return(chatMember.Role == ChatMemberRole.Admin);
 }
예제 #6
0
 protected abstract bool CanDeleteMessage(ChatMember chatMember, Message message);
예제 #7
0
 protected abstract bool CanEditMessage(ChatMember chatMember, Message message);
예제 #8
0
 protected abstract bool CanSendMessage(ChatMember chatMember);
 public PrivateChat(Guid id, IEnumerable <Message> messages, ChatMember creator, ChatMember companion)
     : base(id, messages, new[] { creator, companion })
 {
 }
 protected override bool CanDeleteMessage(ChatMember chatMember, Message message)
 {
     return(message.SenderId == chatMember.Id);
 }
 protected override bool CanSendMessage(ChatMember chatMember)
 {
     return(true);
 }
 protected abstract bool CanDemote(ChatMember chatMember);
 protected abstract bool CanInvite(ChatMember chatMember);
예제 #14
0
 protected override bool CanDeleteMessage(ChatMember chatMember, Message message)
 {
     return(chatMember.Role == ChatMemberRole.Admin || chatMember.Id == message.SenderId);
 }
예제 #15
0
 protected override bool CanEditMessage(ChatMember chatMember, Message message)
 {
     return(chatMember.Id == message.SenderId);
 }