Пример #1
0
        public async Task <MessageLoadDto> GetMessagesForChannelAsync(int channelId, int userId, int workspaceId, int?currentMessageId)
        {
            if (!_channelQueryService.IsUserSubscribedToChannel(channelId, userId))
            {
                throw new ArgumentException($"User is not subsribed to channel.");
            }

            var messageGroupsBaseQuery = _context.ChannelMessages
                                         .Include(m => m.Sender)
                                         .Where(m => m.ChannelId == channelId && m.WorkspaceId == workspaceId);
            var messageLoad = await GetMessageLoadAsync(messageGroupsBaseQuery, currentMessageId);

            await AddMessageChannelDescriptionForChannel(messageLoad, channelId, workspaceId);

            return(messageLoad);
        }
Пример #2
0
        public async Task InviteOtherMembersToChannelAsync(int channelId, List <int> userIds, int userId, int workspaceId)
        {
            if (userIds == null || userIds.Count < 1)
            {
                throw new ArgumentException("Invalid users");
            }

            if (!_channelQueryService.IsUserSubscribedToChannel(channelId, userId))
            {
                throw new ArgumentException("User is not subsribed to channel.");
            }

            await AddUsersToChannelAsync(userIds, channelId, workspaceId);
        }