@@ -3,6 +3,7 @@ import { HttpStatus } from '@nestjs/common';
33import { Task } from 'omniboxd/tasks/tasks.entity' ;
44import { TaskCallbackDto } from 'omniboxd/wizard/dto/task-callback.dto' ;
55import { isEmpty } from 'omniboxd/utils/is-empty' ;
6+ import { TaskDto } from 'omniboxd/tasks/dto/task.dto' ;
67
78/**
89 * Mock wizard worker that simulates the wizard worker service behavior
@@ -46,8 +47,10 @@ class MockWizardWorker {
4647 async pollOnce ( ) : Promise < void > {
4748 const task = await this . fetchTask ( ) ;
4849 if ( task ) {
49- const result = this . processTask ( task ) ;
50- await this . sendCallback ( task . id , result ) ;
50+ if ( task . namespace_id === this . client . namespace . id ) {
51+ const result = this . processTask ( task ) ;
52+ await this . sendCallback ( task . id , result ) ;
53+ }
5154 }
5255 }
5356
@@ -77,7 +80,7 @@ class MockWizardWorker {
7780 /**
7881 * Fetches a task from the backend (simulates wizard worker fetching)
7982 */
80- private async fetchTask ( ) : Promise < Task | null > {
83+ private async fetchTask ( ) : Promise < TaskDto | null > {
8184 try {
8285 const response = await this . makeRequest ( )
8386 . get ( '/internal/api/v1/wizard/task' )
@@ -91,7 +94,7 @@ class MockWizardWorker {
9194 throw new Error ( `Failed to fetch task: ${ response . status } ` ) ;
9295 }
9396
94- return response . body as Task ;
97+ return response . body as TaskDto ;
9598 } catch ( error ) {
9699 if ( error . code === 'ECONNRESET' || error . timeout ) {
97100 console . warn ( 'Connection issue when fetching task, retrying...' ) ;
@@ -104,7 +107,7 @@ class MockWizardWorker {
104107 /**
105108 * Processes a task based on its function type
106109 */
107- private processTask ( task : Task ) : { output ?: any ; exception ?: string } {
110+ private processTask ( task : TaskDto ) : { output ?: any ; exception ?: string } {
108111 try {
109112 switch ( task . function ) {
110113 case 'collect' :
@@ -130,7 +133,7 @@ class MockWizardWorker {
130133 /**
131134 * Simulates collect task processing
132135 */
133- private processCollectTask ( task : Task ) : { output : any } {
136+ private processCollectTask ( task : TaskDto ) : { output : any } {
134137 const input = task . input as { html : string ; url : string ; title ?: string } ;
135138
136139 return {
@@ -145,7 +148,7 @@ class MockWizardWorker {
145148 /**
146149 * Simulates extract_tags task processing
147150 */
148- private processExtractTagsTask ( task : Task ) : { output : any } {
151+ private processExtractTagsTask ( task : TaskDto ) : { output : any } {
149152 console . log ( { taskId : task . id , function : 'extractTags' } ) ;
150153 return {
151154 output : {
@@ -157,7 +160,7 @@ class MockWizardWorker {
157160 /**
158161 * Simulates generate_title task processing
159162 */
160- private processGenerateTitleTask ( task : Task ) : { output : any } {
163+ private processGenerateTitleTask ( task : TaskDto ) : { output : any } {
161164 console . log ( { taskId : task . id , function : 'generateTitle' } ) ;
162165 return {
163166 output : {
@@ -170,7 +173,7 @@ class MockWizardWorker {
170173 /**
171174 * Simulates file_reader task processing
172175 */
173- private processFileReaderTask ( task : Task ) : { output : any } {
176+ private processFileReaderTask ( task : TaskDto ) : { output : any } {
174177 const input = task . input as {
175178 title : string ;
176179 original_name ?: string ;
@@ -194,7 +197,7 @@ class MockWizardWorker {
194197 /**
195198 * Simulates upsert_index task processing
196199 */
197- private processUpsertIndexTask ( task : Task ) : { output : any } {
200+ private processUpsertIndexTask ( task : TaskDto ) : { output : any } {
198201 console . log ( { taskId : task . id , function : 'upsertIndex' } ) ;
199202 return {
200203 output : {
0 commit comments