Skip to content

Commit f35f7ec

Browse files
committed
Fix project-sync adding comments to issues
1 parent ec48179 commit f35f7ec

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

twists/project-sync/src/index.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,37 +366,50 @@ export default class ProjectSync extends Twist<ProjectSync> {
366366
// Get parent activity from note
367367
const activity = note.activity;
368368

369-
// Only sync activities with a source (synced from external services)
370-
const sourceId = activity.meta?.source as string | undefined;
371-
if (!sourceId) return;
372-
373-
// Filter out notes created by twists
369+
// Filter out notes created by twists to prevent loops
374370
if (note.author.type === ActorType.Twist) {
375371
return;
376372
}
377373

378-
const parsed = this.parseSource(sourceId);
379-
if (!parsed) return;
374+
// Only sync if note has content
375+
if (!note.content) {
376+
return;
377+
}
380378

381-
const { provider, issueId } = parsed;
379+
// Determine provider and issue ID from activity metadata
380+
let provider: ProjectProvider | null = null;
381+
let issueId: string | null = null;
382+
383+
if (activity.meta?.linearId) {
384+
provider = "linear";
385+
issueId = activity.meta.linearId as string;
386+
} else if (activity.meta?.jiraId) {
387+
provider = "jira";
388+
issueId = activity.meta.jiraId as string;
389+
} else if (activity.meta?.asanaId) {
390+
provider = "asana";
391+
issueId = activity.meta.asanaId as string;
392+
}
393+
394+
if (!provider || !issueId) {
395+
return;
396+
}
382397

383398
// Get auth token for this provider
384399
const authToken = await this.getAuthToken(provider);
385400
if (!authToken) {
386-
console.warn(`No auth token found for ${provider}, skipping sync`);
401+
console.warn(`No auth token found for ${provider}, skipping note sync`);
387402
return;
388403
}
389404

390405
const tool = this.getProviderTool(provider);
391406

392-
// Only sync if note has content
393-
if (!note.content) return;
394-
395407
try {
396408
// Sync note as comment
397409
if (tool.addIssueComment) {
398410
await tool.addIssueComment(authToken, issueId, note.content);
399-
console.log(`Synced note to ${provider} issue ${issueId}`);
411+
} else {
412+
console.warn(`Provider ${provider} does not support adding comments`);
400413
}
401414
} catch (error) {
402415
console.error(

0 commit comments

Comments
 (0)