public async Task <Guid> CreateChatAsync(CreateChatRequest request, Guid userId) { var chat = await _repository.CreateChatAsync(request.Name); foreach (var memberId in request.MemberIds) { await _repository.CreateChatMemberAsync(chat.Id, memberId); } // Add creator as a member await _repository.CreateChatMemberAsync(chat.Id, userId, ChatMemberStatus.Active, request.CreatorPublicKey); return(chat.Id); }