public Task AddAsync(SlackMessage message, CancellationToken cancellationToken = new CancellationToken()) { var channel = Utility.FirstOrDefault(_context.Channel, message.Channel); var iconUrl = Utility.FirstOrDefault(_context.IconUrl, message.IconUrl); var iconEmoji = Utility.FirstOrDefault(_context.IconEmoji, message.IconEmoji); var userName = Utility.FirstOrDefault(_context.UserName, message.Username); if (!string.IsNullOrWhiteSpace(message.Username) && message.AsUser) { _logger.LogWarning("The AsUser flag cannot be used in conjunction with the username property. It was switched to false"); message.AsUser = false; } message.Channel = channel; message.IconUrl = iconUrl; message.Username = userName; Validate(message); var blockCleaner = new SlackBlockCleaner(message.Blocks); blockCleaner.Clean(); _messages.Enqueue(message); return(Task.CompletedTask); }
public void sectionblock_fields_collection_should_be_null_if_it_contains_no_elements() { var block = new SlackSectionBlock(); var blockCleaner = new SlackBlockCleaner(new[] { block }); blockCleaner.Clean(); block.Fields.Should().BeNull(); }
public void actionblock_with_multi_menu_static_block_element_the_selectedoptions_collection_should_be_null_if_it_contains_no_elements() { var block = new SlackActionBlock(); var element = new SlackMultiSelectMenuStaticBlockElement(); block.Elements.Add(element); var blockCleaner = new SlackBlockCleaner(new[] { block }); blockCleaner.Clean(); element.SelectedOptions.Should().BeNull(); }
public void inputblock_with_checkbox_block_element_the_selectedoptions_collection_should_be_null_if_it_contains_no_elements() { var block = new SlackInputBlock(); var element = new SlackCheckboxBlockElement(); block.Element = element; var blockCleaner = new SlackBlockCleaner(new[] { block }); blockCleaner.Clean(); element.SelectedOptions.Should().BeNull(); }
public void inputblock_with_multi_menu_external_source_block_element_the_initialoptions_collection_should_be_null_if_it_contains_no_elements() { var block = new SlackInputBlock(); var element = new SlackMultiSelectMenuExternalSourceBlockElement(); block.Element = element; var blockCleaner = new SlackBlockCleaner(new[] { block }); blockCleaner.Clean(); element.InitialOptions.Should().BeNull(); }
public void inputblock_with_multi_menu_static_block_element_the_options_collection_should_be_null_if_it_contains_no_elements() { var block = new SlackInputBlock(); var element = new SlackMultiSelectMenuStaticBlockElement(); block.Element = element; var blockCleaner = new SlackBlockCleaner(new[] { block }); blockCleaner.Clean(); element.Options.Should().BeNull(); }
public void sectionblock_with_menu_static_block_element_the_options_collection_should_be_null_if_it_contains_no_elements() { var block = new SlackSectionBlock(); var element = new SlackSelectMenuStaticBlockElement(); block.Accessory = element; var blockCleaner = new SlackBlockCleaner(new[] { block }); blockCleaner.Clean(); element.Options.Should().BeNull(); }