Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(gitea): record the external link before publishing task.created

Andrej2d5447ab0ccb
diff --git a/apps/api/src/plugins/gitea/webhooks/issue-opened.ts b/apps/api/src/plugins/gitea/webhooks/issue-opened.ts
index 935d2324b..fee2a4414 100644
--- a/apps/api/src/plugins/gitea/webhooks/issue-opened.ts
+++ b/apps/api/src/plugins/gitea/webhooks/issue-opened.ts
@@ -126,17 +126,8 @@ export async function handleGiteaIssueOpened(
continue;
}
- await publishEvent("task.created", {
- ...createdTask,
- taskId: createdTask.id,
- userId: createdTask.userId ?? "",
- type: "task",
- content: null,
- source: "gitea",
- externalId: issue.number.toString(),
- actor: issue.user?.login ?? issue.user?.username ?? "gitea-webhook",
- });
-
+ // Must run before task.created: the plugin's onTaskCreated uses link
+ // existence to skip self-originated tasks, else it duplicates the issue.
await createExternalLink({
taskId: createdTask.id,
integrationId: integration.id,
@@ -151,6 +142,17 @@ export async function handleGiteaIssueOpened(
},
});
+ await publishEvent("task.created", {
+ ...createdTask,
+ taskId: createdTask.id,
+ userId: createdTask.userId ?? "",
+ type: "task",
+ content: null,
+ source: "gitea",
+ externalId: issue.number.toString(),
+ actor: issue.user?.login ?? issue.user?.username ?? "gitea-webhook",
+ });
+
const project = await db.query.projectTable.findFirst({
where: eq(projectTable.id, projectId),
});