From 2a4770eef322e630db08cfef28c4c474fdeaee1a Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 28 Dec 2025 16:09:39 +0100 Subject: [PATCH] Enhance FileAttachment struct with validation checks for forbidden file types --- app/MindWork AI Studio/Chat/FileAttachment.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/MindWork AI Studio/Chat/FileAttachment.cs b/app/MindWork AI Studio/Chat/FileAttachment.cs index 7f70ace3..320f21c4 100644 --- a/app/MindWork AI Studio/Chat/FileAttachment.cs +++ b/app/MindWork AI Studio/Chat/FileAttachment.cs @@ -8,10 +8,20 @@ namespace AIStudio.Chat; public readonly record struct FileAttachment(FileAttachmentType Type, string FileName, string FilePath, long FileSizeBytes) { /// - /// Gets a value indicating whether the file still exists on the file system.` + /// Gets a value indicating whether the file still exists on the file system. /// public bool Exists => File.Exists(this.FilePath); + /// + /// Gets a value indicating whether the file type is forbidden and should not be attached. + /// + public bool IsForbidden => this.Type == FileAttachmentType.FORBIDDEN; + + /// + /// Gets a value indicating whether the file type is valid and allowed to be attached. + /// + public bool IsValid => this.Type != FileAttachmentType.FORBIDDEN; + /// /// Creates a FileAttachment from a file path by automatically determining the type, /// extracting the filename, and reading the file size.