-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: watermark documents on bulk download #1691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe bulk download API handler was updated to integrate watermarking functionality. It now retrieves and processes watermark-related fields, determines if files require watermarking, and includes watermark configuration and viewer metadata in the payload sent to the Lambda ZIP creation function. The folder structure and file selection logic were also adjusted to support these enhancements. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API_Handler
participant Prisma_DB
participant Lambda_Zip
User->>API_Handler: Initiates bulk download request
API_Handler->>Prisma_DB: Fetch link, viewer, and file info (including watermark fields)
Prisma_DB-->>API_Handler: Returns data with watermark config, viewer info, file metadata
API_Handler->>API_Handler: Build folder structure, determine needsWatermark for files
API_Handler->>Lambda_Zip: Send ZIP creation request with watermarkConfig and viewer metadata
Lambda_Zip-->>API_Handler: Returns ZIP file or download link
API_Handler-->>User: Responds with ZIP file or download link
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pages/api/links/download/bulk.ts (2)
253-270: Use optional chaining for cleaner code.The file key selection logic is correct, but the conditional check can be simplified.
Apply this diff to use optional chaining:
- folderDocs && - folderDocs.forEach((doc) => { + folderDocs?.forEach((doc) => {🧰 Tools
🪛 Biome (1.9.4)
[error] 253-270: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
291-303: Consider using consistent date/time formatting.The watermark configuration looks good, but the date/time formatting may vary across different server locales.
Consider using ISO format or specifying a locale for consistent date/time representation:
- date: new Date(view.viewedAt).toLocaleDateString(), - time: new Date(view.viewedAt).toLocaleTimeString(), + date: new Date(view.viewedAt).toLocaleDateString('en-US'), + time: new Date(view.viewedAt).toLocaleTimeString('en-US'),Or use ISO format:
- date: new Date(view.viewedAt).toLocaleDateString(), - time: new Date(view.viewedAt).toLocaleTimeString(), + date: new Date(view.viewedAt).toISOString().split('T')[0], + time: new Date(view.viewedAt).toISOString().split('T')[1].split('.')[0],
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (1)
pages/api/links/download/bulk.ts(9 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
pages/api/links/download/bulk.ts
[error] 253-270: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (5)
pages/api/links/download/bulk.ts (5)
8-8: LGTM!The import for the IP address utility is necessary for capturing viewer metadata in watermarks.
33-33: LGTM!The additional fields in the Prisma query are essential for watermarking functionality - viewer identification, watermark configuration, and document metadata.
Also applies to: 39-41, 69-69
157-163: LGTM!The extended type definition properly supports watermarking metadata while maintaining backward compatibility with optional properties.
180-181: LGTM!The function signature extension and watermarking logic correctly identify files that need watermarking (PDFs and images) when the feature is enabled.
Also applies to: 209-219
228-242: LGTM!The file key selection logic correctly uses the processed file for watermarked PDFs and falls back appropriately for other cases.
Summary by CodeRabbit