From 31960fcd11daa2dfaf8ae409c80b572c9b22940f Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
Date: Sat, 8 Nov 2025 15:22:14 +0000
Subject: feat: Add support for user uploaded files (#2100)

* feat: add user file upload support for bookmarks

Add a new "user-uploaded" asset type that allows users to upload and
attach their own files to bookmarks from the attachment box in the
bookmark preview page.

Changes:
- Add USER_UPLOADED asset type to database schema
- Add userUploaded to zAssetTypesSchema for type safety
- Update attachment permissions to allow attaching/detaching user files
- Add fileName field to asset schema for displaying custom filenames
- Add "Upload File" button in AttachmentBox component
- Display actual filename for user-uploaded files
- Allow any file type for user uploads (respects existing upload limits)
- Add Upload icon for user-uploaded files

Fixes #1863 related asset attachment improvements

* fix: ensure fileName is returned and remove edit button for user uploads

- Fix attachAsset mutation to fetch and return complete asset with fileName
  instead of just returning the input (which lacks fileName)
- Remove replace/edit button for user-uploaded files - users can only
  delete and re-upload instead
- This ensures the filename displays correctly in the UI immediately
  after upload

Fixes fileName propagation issue for user-uploaded assets

* fix asset file name

* remove filename from attach asset api

---------

Co-authored-by: Claude <noreply@anthropic.com>
---
 apps/web/lib/attachments.tsx | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'apps/web/lib/attachments.tsx')

diff --git a/apps/web/lib/attachments.tsx b/apps/web/lib/attachments.tsx
index ce34b295..67941098 100644
--- a/apps/web/lib/attachments.tsx
+++ b/apps/web/lib/attachments.tsx
@@ -4,6 +4,7 @@ import {
   FileCode,
   Image,
   Paperclip,
+  Upload,
   Video,
 } from "lucide-react";
 
@@ -18,5 +19,6 @@ export const ASSET_TYPE_TO_ICON: Record<ZAssetType, React.ReactNode> = {
   video: <Video className="size-4" />,
   bookmarkAsset: <Paperclip className="size-4" />,
   linkHtmlContent: <FileCode className="size-4" />,
+  userUploaded: <Upload className="size-4" />,
   unknown: <Paperclip className="size-4" />,
 };
-- 
cgit v1.3-1-g0d28

