public async Task PostJoinChannelSystemMessageAsync(int channelId, List <int> userIds, int workspaceId)
        {
            var userNames = await _userQueryService.GetUserNamesAsync(userIds.Skip(1).ToList(), workspaceId);

            var channel = await _channelQueryService.GetChannelByIdAsync(channelId, workspaceId);

            var content = $"joined {channel.Name}" + (string.IsNullOrEmpty(userNames) ? "." : $" along with {userNames}.");
            var message = new ChannelMessage(channelId, content, userIds.First(), workspaceId, false, true);

            await PostMessageToChannelCommonAsync(message);
        }
Example #2
0
        public async Task <ActionResult <ChannelDto> > GetAsync(int id)
        {
            var channel = await _channelQueryService.GetChannelByIdAsync(id, User.GetWorkspaceId());

            if (channel == null)
            {
                return(NotFound());
            }

            return(channel);
        }
Example #3
0
        private async Task AddMessageChannelDescriptionForChannel(MessageLoadDto messageLoad, int channelId, int workspaceId)
        {
            var channel = await _channelQueryService.GetChannelByIdAsync(channelId, workspaceId);

            var createdByUser = await _userQueryService.GetUserByIdAsync(channel.CreatedByUserId);

            messageLoad.MessageChannelDescriptionDto = new MessageChannelDescriptionDto {
                CreatedByUser      = createdByUser,
                CreatedDateString  = channel.CreatedDateString,
                MessageChannelName = channel.Name
            };
        }
Example #4
0
        public async Task AddUserToChannelAsync(int channelId, int userId, int workspaceId)
        {
            var user = await _userQueryService.GetUserByIdAsync(userId, workspaceId);

            var channel = await _channelQueryService.GetChannelByIdAsync(channelId, workspaceId);

            if (user == null || channel == null)
            {
                throw new ArgumentException("Cannot find user or channel");
            }

            await AddUsersToChannelAsync(new List <int>(new[] { userId }), channelId, workspaceId);
        }