Conversation
…F and image headers
feat: update certificate metadata and include verification URLs in PD…
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Updates certificate output metadata to improve traceability and verification links for generated/downloaded certificates.
Changes:
- Updates PDF metadata (Author/Keywords) and adds verification details in PDF info fields.
- Adds an
X-Verification-URLresponse header for PNG generation responses. - Introduces (but currently does not use) a Sharp metadata-preservation buffer step for PNG responses.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/controller/certificates/generate.controller.js |
Adds verification URL header and expands PDF metadata; introduces Sharp withMetadata() step in PNG path. |
src/controller/certificates/download.controller.js |
Updates PDF metadata (Author/Keywords) and adds certificate/verification info fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const sharp = require('sharp'); | ||
| const imageWithMetadata = await sharp(imageBuffer) | ||
| .withMetadata() // Preserve existing | ||
| .toBuffer(); | ||
|
|
||
| // Return raw PNG image (at least we preserve what's there) | ||
| // Actually to ADD new metadata we need to specify it. | ||
| // But let's keep it simple for now as I doesn't want to break the buffer if sharp's withMetadata is finicky. | ||
|
|
There was a problem hiding this comment.
imageWithMetadata is computed but never used; the response still sends imageBuffer. This adds extra CPU/memory work per request without changing output. Either send imageWithMetadata (and ensure it’s the intended output) or remove the sharp transformation entirely.
| const sharp = require('sharp'); | |
| const imageWithMetadata = await sharp(imageBuffer) | |
| .withMetadata() // Preserve existing | |
| .toBuffer(); | |
| // Return raw PNG image (at least we preserve what's there) | |
| // Actually to ADD new metadata we need to specify it. | |
| // But let's keep it simple for now as I doesn't want to break the buffer if sharp's withMetadata is finicky. | |
| // Return raw PNG image (at least we preserve what's there) | ||
| // Actually to ADD new metadata we need to specify it. | ||
| // But let's keep it simple for now as I doesn't want to break the buffer if sharp's withMetadata is finicky. | ||
|
|
There was a problem hiding this comment.
The added inline comment has grammatical issues (e.g., “as I doesn't want …”, “sharp's … is finicky”) and reads like a temporary note. Please rephrase it to be clear/professional or remove it if it’s not needed for long-term maintenance.
| // Return raw PNG image (at least we preserve what's there) | |
| // Actually to ADD new metadata we need to specify it. | |
| // But let's keep it simple for now as I doesn't want to break the buffer if sharp's withMetadata is finicky. | |
| // Preserve existing PNG metadata and expose certificate details through response headers. | |
| // Additional embedded image metadata is not added in this response path. |
| pdfDoc.info.Creator = 'GCSRM Server'; | ||
| pdfDoc.info.Keywords = `certificate,${event},${certificateType},${issuedCert.certificateId}`; | ||
| pdfDoc.info.Keywords = `certificate, ${event}, ${certificateType}, ${issuedCert.certificateId}, Verification: https://githubsrmist.in/verify/${issuedCert.certificateId}`; | ||
| pdfDoc.info['X-Certificate-ID'] = issuedCert.certificateId; |
There was a problem hiding this comment.
PDF metadata keys use X-Certificate-ID (uppercase ID), but the API response header and Swagger docs use X-Certificate-Id. To avoid confusion and make metadata/search tooling consistent, please align on one casing (prefer the existing X-Certificate-Id).
| pdfDoc.info['X-Certificate-ID'] = issuedCert.certificateId; | |
| pdfDoc.info['X-Certificate-Id'] = issuedCert.certificateId; |
| pdfDoc.info.Creator = 'GCSRM Server'; | ||
| pdfDoc.info.Keywords = `certificate,${certificate.eventSlug},${certificate.certificateType},${certificateId}`; | ||
| pdfDoc.info.Keywords = `certificate, ${certificate.eventSlug}, ${certificate.certificateType}, ${certificateId}, Verification: https://githubsrmist.in/verify/${certificateId}`; | ||
| pdfDoc.info['X-Certificate-ID'] = certificateId; |
There was a problem hiding this comment.
PDF metadata uses X-Certificate-ID (uppercase ID), while the download response headers (and Swagger docs) use X-Certificate-Id. Please standardize the casing to match the established header name to reduce ambiguity for consumers.
| pdfDoc.info['X-Certificate-ID'] = certificateId; | |
| pdfDoc.info['X-Certificate-Id'] = certificateId; |
🚀 Pull Request
Thank you for contributing to GCSRM Server! 🎉
📋 PR Checklist
Please check all the boxes that apply to your pull request:
🎃 Hacktoberfest Validation (Required for Hacktoberfest PRs)
hacktoberfest-accepted🔍 Code Quality
🧪 Testing
npm startornpm run dev)📚 Documentation
🔗 Issues & Dependencies
Closes #issue_number)📝 Description
What does this PR do?
Related Issue(s)
🔄 Type of Change
Please select the type of change your PR introduces:
🧪 How Has This Been Tested?
Test Configuration:
Testing Steps:
Test Results:
📸 Screenshots (if applicable)
🔧 API Changes (if applicable)
New Endpoints
Modified Endpoints
Deprecated/Removed Endpoints
Request/Response Changes
🗄️ Database Changes (if applicable)
Migration Details:
🔒 Security Considerations
⚡ Performance Impact
🚨 Breaking Changes
Breaking Changes Details:
🎯 Hacktoberfest Information
If this is a Hacktoberfest contribution, confirm ALL validation criteria:
✅ Required Validations
hacktoberfestOR expectinghacktoberfest-acceptedlabelinvalid(or will gethacktoberfest-accepted)hacktoberfest-acceptedlabel🔄 Understanding the Process
🎃 Repository Verification
hacktoberfesttopic ✅📝 Additional Notes
Deployment Notes:
Reviewer Notes:
Future Work:
🏷️ Labels to Add (Maintainers Only)
Size:
size/small(< 50 lines changed)size/medium(50-200 lines changed)size/large(> 200 lines changed)Priority:
priority/lowpriority/mediumpriority/highComponent:
backenddatabaseapimiddlewaredocumentationtestingci/cdStatus:
ready-for-reviewwork-in-progressneeds-testinghacktoberfest-accepted(if approved Hacktoberfest contribution)🤝 Contributor Agreement
By submitting this pull request, I confirm that:
Thank you for your contribution! We appreciate your effort to make GCSRM Server better! 🙏✨