Enhance job state update functionality in DocumentPrinterClient
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good

- Introduced a `notify` parameter in the `editObject` method of `SocketClient` to control notification behavior during job state updates.
- Updated the `updateJobState` method in `DocumentPrinterClient` to conditionally set the `notify` parameter based on the job state type, improving the handling of job notifications.
This commit is contained in:
Tom Butcher 2026-08-19 18:58:38 +01:00
parent bec253cde8
commit 470a0edd80
2 changed files with 12 additions and 1 deletions

View File

@ -299,10 +299,13 @@ export class DocumentPrinterClient {
async updateJobState(jobId, state) { async updateJobState(jobId, state) {
logger.info(`Updating job state for ${jobId}`); logger.info(`Updating job state for ${jobId}`);
const notify =
state?.type !== "deploying" && state?.type !== "queued";
await this.socketClient.editObject({ await this.socketClient.editObject({
_id: jobId, _id: jobId,
objectType: "documentJob", objectType: "documentJob",
updateData: { state: state }, updateData: { state: state },
notify,
}); });
logger.info(`Updated job state for ${jobId}:`, state); logger.info(`Updated job state for ${jobId}:`, state);
} }

View File

@ -430,7 +430,14 @@ export class SocketClient {
}); });
} }
async editObject({ objectType, _id, populate, updateData, auditLog = true }) { async editObject({
objectType,
_id,
populate,
updateData,
auditLog = true,
notify = true,
}) {
logger.trace("Editing object...", { logger.trace("Editing object...", {
objectType, objectType,
_id, _id,
@ -445,6 +452,7 @@ export class SocketClient {
populate, populate,
updateData, updateData,
auditLog, auditLog,
notify,
}, },
(result) => { (result) => {
if (result && result.error) { if (result && result.error) {