示例#1
0
        public async Task ShareFileToChannelAsync(int channelId, int fileId, int userId, int workspaceId)
        {
            if (!(await EligibleForTheFileAsync(fileId, userId, workspaceId)))
            {
                throw new ArgumentException($"File access required.");
            }

            var message = new ChannelMessage(channelId, string.Empty, userId, workspaceId, true);
            var file    = await _context.Files.SingleAsync(f => f.Id == fileId);

            message.AddMessageFileAttachment(file);

            await PostMessageToChannelCommonAsync(message);
        }
示例#2
0
        public async Task PostFileMessageToChannelAsync(IList <IFormFile> files, int channelId, int userId, int workspaceId)
        {
            if (!files.Any())
            {
                throw new ArgumentException($"File list is empty.");
            }

            var savedFiles = await UploadAndSaveFilesForMessageAsync(files, userId, workspaceId);

            var message = new ChannelMessage(channelId, string.Empty, userId, workspaceId, true);

            foreach (var file in savedFiles)
            {
                message.AddMessageFileAttachment(file);
            }

            await PostMessageToChannelCommonAsync(message);
        }