Allow source code-related files

This commit is contained in:
Thorsten Sommer 2026-01-05 19:32:34 +01:00
parent 47975870b4
commit 60e5c8f2e2
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 53 additions and 1 deletions

View File

@ -95,7 +95,8 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi
// Check if it's an allowed document file (PDF, Text, or Office):
if (FileTypeFilter.PDF.FilterExtensions.Contains(extension) ||
FileTypeFilter.Text.FilterExtensions.Contains(extension) ||
FileTypeFilter.AllOffice.FilterExtensions.Contains(extension))
FileTypeFilter.AllOffice.FilterExtensions.Contains(extension) ||
FileTypeFilter.AllSourceCode.FilterExtensions.Contains(extension))
return FileAttachmentType.DOCUMENT;
// All other file types are forbidden:

View File

@ -25,5 +25,56 @@ public readonly record struct FileTypeFilter(string FilterName, string[] FilterE
public static FileTypeFilter AllAudio => new(TB("All Audio Files"), ["mp3", "wav", "wave", "aac", "flac", "ogg", "m4a", "wma", "alac", "aiff", "m4b"]);
public static FileTypeFilter AllSourceCode => new(TB("All Source Code Files"),
[
// C#:
"cs",
// Java:
"java",
// Python:
"py",
// JavaScript/TypeScript:
"js", "ts",
// C/C++:
"c", "cpp", "h", "hpp",
// Ruby:
"rb",
// Go:
"go",
// Rust:
"rs",
// Lua:
"lua",
// PHP:
"php",
// HTML/CSS:
"html", "css",
// Swift/Kotlin:
"swift", "kt",
// Shell scripts:
"sh", "bash",
// Logging files:
"log",
// JSON/YAML/XML:
"json", "yaml", "yml", "xml",
// Config files:
"ini", "cfg", "toml", "plist",
]);
public static FileTypeFilter Executables => new(TB("Executable Files"), ["exe", "app", "bin", "appimage"]);
}