Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ProcessMaker/Http/Controllers/Api/V1_1/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ProcessRequestToken;
use ProcessMaker\ProcessTranslations\TranslationManager;
use ProcessMaker\Services\TaskCompletionRawService;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class TaskController extends Controller
{
public function __construct(
private readonly TaskCompletionRawService $taskCompletionRawService,
) {
}

protected $defaultFields = [
'id',
'element_id',
Expand Down Expand Up @@ -151,4 +158,26 @@ public function showInterstitial($taskId)

return $response;
}

/**
* Complete a task using the raw-query optimized path.
*/
public function update(Request $request, int $taskId)
{
if ($request->input('status') !== 'COMPLETED') {
abort(422, __('Only task completion is supported on this endpoint. Use PUT /api/1.0/tasks/{id} for other updates.'));
}

try {
$task = $this->taskCompletionRawService->completeTask(
$taskId,
json_optimize_decode($request->getContent(), true) ?: [],
$request->user(),
);
} catch (NotFoundHttpException $exception) {
return response()->json(['message' => $exception->getMessage()], 404);
}

return response()->json($task);
}
}
11 changes: 11 additions & 0 deletions ProcessMaker/Repositories/ExecutionInstanceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use ProcessMaker\Nayra\Contracts\Repositories\ExecutionInstanceRepositoryInterface;
use ProcessMaker\Nayra\Contracts\Repositories\StorageInterface;
use ProcessMaker\Nayra\RepositoryTrait;
use ProcessMaker\Repositories\TokenPersistenceRawRepository;
use ProcessMaker\SanitizeHelper;

/**
Expand Down Expand Up @@ -236,6 +237,16 @@ public function persistInstanceUpdated(ExecutionInstanceInterface $instance)
return;
}

if (
config('app.token_persistence_raw_enabled', false)
&& $instance instanceof ProcessRequest
) {
app(TokenPersistenceRawRepository::class)->persistInstanceUpdated($instance);
CaseUpdateStatus::dispatchSync($instance);

return;
}

// Save updated instance
if (!$instance->status) {
$instance->status = 'ACTIVE';
Expand Down
Loading
Loading