Task Auto-Complete on Media Upload (Developer)
This feature automatically completes certain Tasks when a Media upload is created for a Job/Leg.
Feature Flag (Safe Rollout)β
Gated by customer config:
tasks.autoCompleteOnMediaUpload.enabled- default for
trucking:true - default for non-trucking app types:
false - tenant config can override either direction
- default for
- optional toggles:
tasks.autoCompleteOnMediaUpload.bol,tasks.autoCompleteOnMediaUpload.pod
Recommended Policy (Phase 1)β
- Keep API media presence (
bolPodEnforcement) as the canonical status blocker. - Keep task auto-complete on for trucking tenants unless they explicitly opt out.
- Do not rely on task completion as a second hard blocker in mobile status transitions.
Upload contract (what mobile/web must send)β
Uploads go through:
POST /api/v1/media(multipart)
Required fields:
docs(file field)refType:"leg"or"job"refId: the parent_idas a stringtype: must be normalized for automation:"bol"for Bill of Lading"pod"for Proof of Delivery
If type is "misc" / "document" / "signature", no auto-complete mapping will match.
Mapping rules (current)β
Server maps Media.type β TaskTemplate.name:
bolβpickup_sign_bolpodβdelivery_pod
The service resolves templates by name, allowing either:
- system templates:
{ scope: "system", parentCompany: null } - company templates:
{ parentCompany }
Then it finds matching pending tasks on that same parent (job/leg) and completes them.
Where it lives (API)β
- Service:
src/services/tasks/task-auto-complete.service.js - Wired in:
src/controllers/media.js(after successful upload)
Mobile wiring notesβ
In mobile, ensure the upload call ultimately hits POST /media with:
refType: "leg",refId: <legId>, andtype: "bol" | "pod"for Load documents.- If uploading a BOL/POD signature, set
typeto"bol"/"pod"(not only"signature").