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.

feat: implement handleTaskCreated with atproto record sync

+60 -1
+59
apps/api/src/plugins/tangled/events/task-created.ts
··· 1 + import { 2 + createExternalLink, 3 + findExternalLinkByTaskAndType, 4 + } from "../../github/services/link-manager"; 5 + import type { PluginContext, TaskCreatedEvent } from "../../types"; 6 + import type { TangledConfig } from "../config"; 7 + import { getTangledAgent } from "../utils/atproto-agent"; 8 + 9 + export async function handleTaskCreated( 10 + event: TaskCreatedEvent, 11 + context: PluginContext, 12 + ): Promise<void> { 13 + const config = context.config as TangledConfig; 14 + 15 + if (!config.repoAtUri) return; 16 + 17 + const existingLink = await findExternalLinkByTaskAndType( 18 + event.taskId, 19 + context.integrationId, 20 + "issue", 21 + ); 22 + 23 + if (existingLink) return; 24 + 25 + const agent = await getTangledAgent(); 26 + if (!agent) return; 27 + 28 + try { 29 + // create the record on the pds 30 + const result = await agent.com.atproto.repo.createRecord({ 31 + repo: agent.session?.did ?? "", 32 + collection: "sh.tangled.repo.issue", 33 + record: { 34 + $type: "sh.tangled.repo.issue", 35 + repo: config.repoAtUri, 36 + title: event.title, 37 + body: event.description ?? "", 38 + createdAt: new Date().toISOString(), 39 + }, 40 + }); 41 + 42 + await createExternalLink({ 43 + taskId: event.taskId, 44 + integrationId: context.integrationId, 45 + resourceType: "issue", 46 + externalId: result.data.uri, 47 + url: result.data.uri, 48 + title: event.title, 49 + metadata: { 50 + cid: result.data.cid, 51 + state: "open", // new issues are always open 52 + createdFrom: "kaneo", 53 + lastOutboundStateSyncAt: Date.now(), 54 + }, 55 + }); 56 + } catch (error) { 57 + console.error("Failed to create Tangled issue:", error); 58 + } 59 + }
+1 -1
apps/api/src/plugins/tangled/index.ts
··· 1 1 import type { IntegrationPlugin } from "../types"; 2 2 import { validateTangledConfig } from "./config"; 3 + import { handleTaskCreated } from "./events/task-created"; 3 4 4 - export async function handleTaskCreated() {} 5 5 export async function handleTaskStatusChanged() {} 6 6 export async function handleTaskPriorityChanged() {} 7 7 export async function handleTaskTitleChanged() {}