Repository navigation
Purav Taking over for Meenashi - collaboration ads creation page (clean re-port onto development) - #2385
Purav Taking over for Meenashi - collaboration ads creation page (clean re-port onto development)#2385pixelpix13 wants to merge 5 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
…oller validation - Introduced unit tests for collaborationController, covering file upload scenarios and response validations. - Enhanced jobController with input sanitization for category and title validation. - Updated job model to ensure proper URL generation for jobDetailsLink. - Added middleware tests for public job forms routes to ensure correct access control.
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
vidiyala99
left a comment
There was a problem hiding this comment.
Reviewed 070055f together with frontend OneCommunityGlobal/HighestGoodNetworkApp#5629 (details of the UI test there). I ran this branch on a test server against the shared dev data; nothing was created (the create request was blocked in the browser).
What works:
- Tests:
collaborationController.collabAds.test.js,jobsController.test.js,jobs.preValidate.test.jsandmiddleware.jobforms.test.jspass (4 suites, 57/57). - Read paths the new page uses:
GET /api/jobs/categories,GET /api/jobs/positions/:category(Administrative & Support returns its two positions) andGET /api/jobforms/all(41 forms) all work for the creation form. - Public routes don't expose responses: the middleware now lets every
GET /api/jobforms*through without a token, which also coversGET /jobforms/:formId/responses. I checked that this doesn't leak applicant data: without a token that route still returns403 "You are not authorized to view form responses.", becausegetFormResponsescheckscanManageJobFormsitself. Other routes stay protected (anonymousGET /api/userprofileis still 401).
Concerns with the new public upload (POST /api/jobforms/responses/upload, no auth), from reading the code; I didn't call it, since it uploads to the real Dropbox:
- The Dropbox path uses the client's file name as is:
${DROPBOX_PATH}/${uploadFile.originalname}. A name containing/creates folders under the upload path, and the name is otherwise unchecked. Please reduce it to a safe base name (strip path separators and control characters, cap the length), ideally with a generated prefix such as the form id plus a timestamp. - It's an unauthenticated write to the organization's Dropbox with no rate limit. Anyone can send unlimited 5 MB files, and
mimetypeis what the client declares. A per-IP rate limit, plus requiring a validformIdfor an active form, would make abuse much harder. - Minor: "File too large" and "Invalid file type" return HTTP 500; 413 and 415 (or 400) would let the frontend tell user errors from server failures.
Requesting changes for items 1 and 2, since the route is public.
RichaSapre
left a comment
There was a problem hiding this comment.
I reviewed the backend validation, permission enforcement, job creation, apply-link validation, and job-form middleware.
The targeted backend tests passed 57/57, and the Babel build compiled 773 files successfully. I did not identify a blocking backend issue.



Description
Backend support for the collaboration job ads creation feature: create collaboration job ads with new fields, accept public job-form applications (including Dropbox file upload), and gate ad creation behind the
createCollabJobAdspermission.This is a clean re-port of the feature-scoped work from #1872 onto current
development(not a full-branch merge of the old conflicted history).Pair with frontend: HighestGoodNetworkApp#5629 — check out both branches together for end-to-end create → list → details → apply flows.
What this PR adds
requirements,projects,ourCommunity; auto-fillsjobDetailsLinkwhen missing;POST /api/jobsvalidates inputs and requirescreateCollabJobAds.POST /api/jobforms/responses/upload(Dropbox, 5MB limit) andPOST /api/jobforms/responses(save answers + emailJOB_APPLICATION_RECIPIENT_EMAIL); no auth.GETand responsesPOST/ upload.isRequireddefaults totrue; answers storequestionText./api/jobs/positions/:category?.createCollabJobAdsregistered in initial permissions.Required environment variables
Dropbox refresh-token OAuth is required for file upload testing. Gmail OAuth (same pattern as prior collab ads PRs) is required if you want to verify application emails.
Related PRS (if any):
Main changes explained:
jobsmodelrequirements,projects,ourCommunity; pre-validate setsjobDetailsLinkfromBASE_FRONTEND_URLjobsControllercollaborationController+ routermiddlewareJobFormsModelisRequireddefaulttruejobApplicationsModelquestionTexton answerscreateInitialPermissionscreateCollabJobAdsHow to test:
Setup
manoj-collaboration-ads-creation-pageon HGNRest and the matching branch on HighestGoodNetworkApp for frontend PR #5629.npm installif needed..env.npm run buildthennpm start(API athttp://localhost:4500).npm run start:local→http://localhost:5173.A) Login (for authenticated job create)
POST http://localhost:4500/api/login{ "email": "devadmin@hgn.net", "password": "DeveloperPassword100%!" }POST /api/jobs.B) Dropbox file upload — no authorization
POST {{baseUrl}}/api/jobforms/responses/uploadform-datakeyfile= selected file (PDF/DOC/DOCX/JPG/PNG/BMP, ≤ 5MB)C) Save job form responses — no authorization
POST {{baseUrl}}/api/jobforms/responsesformId(fromjobForms) andanswersfor that form’s questions. Forfilequestions, use the Dropbox link from step B. Fill allisRequiredquestions.Example:
{ "formId": "6920189d05b65c73344d265d", "answers": [ { "questionId": "6920189d05b65c73344d265e", "questionText": "Name", "answer": "test applicant" } ] }JOB_APPLICATION_RECIPIENT_EMAIL.D) Create collaboration job ad (
createCollabJobAds)POST {{baseUrl}}/api/jobscreateCollabJobAds)title/category,description,requirements,projects,ourCommunity,imageUrl,applyLink(must reference a real job form id in the path)imageUrl: Dropbox image link ending inraw=1(notdl=0). Suggested folder: https://www.dropbox.com/scl/fo/817lsk8fmvx5cdexbk07x/APOLV_TrgXHFLJATnj1xVFg?rlkey=rgs3pfrbav2hf6a2el6dtblnf&e=1&dl=0201+ saved job (jobDetailsLinkauto-filled if omitted).403. Invalid category/title/applyLink or short text → validation error.E) Permission / public access checks
createCollabJobAds→ can create jobs.GETjobforms andPOSTresponses/upload.F) Paired frontend E2E (#5629)
/jobAdsCreation).raw=1image + apply form)./collaborationwith the correct image/category filter.Screenshots or videos of changes:
POST /api/jobswith new fields +raw=1imageUrlNote:
development; review only the feature-scoped files in this PR.imageUrlshould end withraw=1, notdl=0.