import { request } from '../lib/apiClient' /** * Persisted mailbox messages. * * NOTE: this endpoint currently has no auth dependency server-side * (backend/inbox/app.py). We send the bearer anyway, so adding * Depends(get_current_user) later is a zero-diff change on this side. */ export function listMessages() { return request('/inbox/fetch') } /** * Persisted applications — the shape the All Applications tab renders. * * Unlike /inbox/fetch this one IS permissioned server-side * (require_permission(INBOX_VIEW)), so a caller without the tag gets a 403. * * `assigned` is tri-valued: omit for no filter, true for rows with an * assigned_job_post_id, false for the Job Matching queue. */ export function listApplications({ search, top, skip, recordId, isread, applicationStatus, assigned } = {}) { return request('/inbox/all-applications', { // `isread` is tri-valued on the wire: omit it for every tab (server defaults // to true = no filter), send false for the Unread tab only. buildUrl drops // undefined but keeps false, so `isread: undefined` sends no param at all. // Same for `application_status`: omit for every tab (server defaults to // CLOSED = no filter), send PROCESS / REJECTED for those tabs only. params: { search, top, skip, record_id: recordId, isread, application_status: applicationStatus, assigned, }, }) } /** * One persisted message by id — the detail behind an inbox row. * * `record_id` is the inbox_messages PRIMARY KEY, not the Graph message_id: * get_inbox_message_by_id runs uuid.UUID(record_id) and matches on `id`, so the * external string id would fail the parse and 404. The `id` field on both * /inbox/fetch and /inbox/all-applications rows is already that primary key. */ export function getMessage(recordId) { return request('/inbox/fetch', { params: { record_id: recordId } }) } /** Triggers the Graph proxy to pull new mail and persist it. */ export function syncMailbox({ token, top, skip } = {}) { return request('/email/fetch', { params: { token, top, skip } }) } /** Marks one persisted inbox row read (local DB only). */ export function markRead(recordId) { return request(`/inbox/${recordId}/read`, { method: 'POST' }) } /** Assign (or clear with null) the job post for one application. Requires inbox.edit. */ export function assignJobPost(recordId, jobPostId) { return request(`/inbox/${recordId}/assign-job-post`, { method: 'PATCH', body: { job_post_id: jobPostId }, }) } /** Re-queue the matching agent for one application. Requires inbox.edit. */ export function rematch(recordId) { return request(`/inbox/${recordId}/match`, { method: 'POST' }) }