kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at cd7cada2f86b4e866a15b4323bb8d6d7ab5bba8b 60 lines 1.6 kB view raw
1import { findExternalLinkByTaskAndType } from "../../github/services/link-manager"; 2import type { PluginContext, TaskCommentCreatedEvent } from "../../types"; 3import type { GiteaConfig } from "../config"; 4import { createGiteaClient } from "../utils/gitea-api"; 5 6export async function handleTaskCommentCreated( 7 event: TaskCommentCreatedEvent, 8 context: PluginContext, 9): Promise<void> { 10 const config = context.config as GiteaConfig; 11 if (!config.baseUrl || !config.accessToken) { 12 return; 13 } 14 15 const { repositoryOwner, repositoryName } = config; 16 17 const existingLink = await findExternalLinkByTaskAndType( 18 event.taskId, 19 context.integrationId, 20 "issue", 21 ); 22 23 if (!existingLink) { 24 return; 25 } 26 27 try { 28 const client = createGiteaClient(config); 29 if (!/^\d+$/.test(existingLink.externalId)) { 30 console.error( 31 "Skipping Gitea comment sync for invalid external issue id", 32 { 33 taskId: event.taskId, 34 externalId: existingLink.externalId, 35 }, 36 ); 37 return; 38 } 39 40 const issueNumber = Number(existingLink.externalId); 41 42 if (!Number.isFinite(issueNumber) || issueNumber < 1) { 43 console.error("Skipping Gitea comment sync for invalid issue number", { 44 taskId: event.taskId, 45 externalId: existingLink.externalId, 46 issueNumber, 47 }); 48 return; 49 } 50 51 await client.createIssueComment( 52 repositoryOwner, 53 repositoryName, 54 issueNumber, 55 event.comment, 56 ); 57 } catch (error) { 58 console.error("Failed to create Gitea comment:", error); 59 } 60}