MCPcopy Create free account
hub / github.com/Noumena-Network/code / blockTask

Function blockTask

src/utils/tasks.ts:459–487  ·  view source on GitHub ↗
(
  taskListId: string,
  fromTaskId: string,
  toTaskId: string,
)

Source from the content-addressed store, hash-verified

457}
458
459export async function blockTask(
460 taskListId: string,
461 fromTaskId: string,
462 toTaskId: string,
463): Promise<boolean> {
464 const [fromTask, toTask] = await Promise.all([
465 getTask(taskListId, fromTaskId),
466 getTask(taskListId, toTaskId),
467 ])
468 if (!fromTask || !toTask) {
469 return false
470 }
471
472 // Update source task: A blocks B
473 if (!fromTask.blocks.includes(toTaskId)) {
474 await updateTask(taskListId, fromTaskId, {
475 blocks: [...fromTask.blocks, toTaskId],
476 })
477 }
478
479 // Update target task: B is blockedBy A
480 if (!toTask.blockedBy.includes(fromTaskId)) {
481 await updateTask(taskListId, toTaskId, {
482 blockedBy: [...toTask.blockedBy, fromTaskId],
483 })
484 }
485
486 return true
487}
488
489export type ClaimTaskResult = {
490 success: boolean

Callers 1

callFunction · 0.85

Calls 2

getTaskFunction · 0.85
updateTaskFunction · 0.85

Tested by

no test coverage detected