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);
 }
Esempio n. 6
0
 protected abstract bool CanDeleteMessage(ChatMember chatMember, Message message);
Esempio n. 7
0
 protected abstract bool CanEditMessage(ChatMember chatMember, Message message);
Esempio n. 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);
Esempio n. 14
0
 protected override bool CanDeleteMessage(ChatMember chatMember, Message message)
 {
     return(chatMember.Role == ChatMemberRole.Admin || chatMember.Id == message.SenderId);
 }
Esempio n. 15
0
 protected override bool CanEditMessage(ChatMember chatMember, Message message)
 {
     return(chatMember.Id == message.SenderId);
 }