| 2730 | } |
| 2731 | |
| 2732 | static char *application_index_async_response(const char *project_key, const char *state, |
| 2733 | bool joined) { |
| 2734 | yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); |
| 2735 | yyjson_mut_val *root = doc ? yyjson_mut_obj(doc) : NULL; |
| 2736 | char *json = NULL; |
| 2737 | if (root) { |
| 2738 | yyjson_mut_doc_set_root(doc, root); |
| 2739 | yyjson_mut_obj_add_strcpy(doc, root, "project", project_key); |
| 2740 | yyjson_mut_obj_add_str(doc, root, "state", state); |
| 2741 | yyjson_mut_obj_add_bool(doc, root, "async", true); |
| 2742 | yyjson_mut_obj_add_bool(doc, root, "joined", joined); |
| 2743 | yyjson_mut_obj_add_str(doc, root, "poll", |
| 2744 | "call index_repository with the same repo_path and status: true " |
| 2745 | "until state is succeeded, failed or cancelled"); |
| 2746 | json = yyjson_mut_write(doc, 0, NULL); |
| 2747 | } |
| 2748 | yyjson_mut_doc_free(doc); |
| 2749 | char *result = cbm_mcp_text_result(json ? json : "{}", false); |
| 2750 | safe_free(json); |
| 2751 | return result; |
| 2752 | } |
| 2753 | |
| 2754 | /* #2144 user decision: refuse async where the job would certainly die with its |
| 2755 | * requester. A temporary (non-permanent) daemon stops and cancels every job |
no test coverage detected