From 651464792f01a48243a8a5fa8f922e7783ce60c9 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar <70131915+Saurabhkmr98@users.noreply.github.com> Date: Mon, 24 Nov 2025 20:13:38 +0530 Subject: [PATCH] [SILO-704] [SILO-705] fix: remove assignees + priority sync + fix unlink of issue sync + fix comment links (#4846) --- .../silo/src/apps/github/helpers/transform.ts | 22 ++----------------- .../github/event-handlers/issue.handler.ts | 11 ---------- .../event-handlers/issue-comment.handler.ts | 15 +++++++++++-- .../plane/event-handlers/issue.handler.ts | 4 ++++ 4 files changed, 19 insertions(+), 33 deletions(-) diff --git a/apps/silo/src/apps/github/helpers/transform.ts b/apps/silo/src/apps/github/helpers/transform.ts index 25653bb179..ef47c473b4 100644 --- a/apps/silo/src/apps/github/helpers/transform.ts +++ b/apps/silo/src/apps/github/helpers/transform.ts @@ -98,8 +98,6 @@ export const transformGitHubIssue = async ( }, ]; - let planeAssignees: string[] = []; - let creator: string | undefined; if (issue.user && issue.user.type === "User") { @@ -141,16 +139,6 @@ export const transformGitHubIssue = async ( // Replace the mentioned github users in the issue body issue_html = replaceMentionedGhUsers(issue_html, workspaceSlug, userMap, planeUsers); - if (issue.assignees) { - planeAssignees = issue.assignees - .map((assignee) => { - if (assignee != null) { - return userMap[assignee.login]; - } - }) - .filter((assignee) => assignee != undefined) as string[]; - } - let labels = issue.labels?.map((label) => (typeof label === "string" ? label : label.name)) || []; labels = labels.filter((label) => label.toLowerCase() !== "plane"); @@ -183,9 +171,7 @@ export const transformGitHubIssue = async ( description_html: issue_html, created_at: issue.created_at, state: targetState, - priority: "none", labels: labels, - assignees: planeAssignees, links, }; }; @@ -215,10 +201,10 @@ export const transformGitHubComment = async ( } } - let comment_html = `
${comment.body || ""}
`; + let comment_html = `${commentHtml || ""}`; if (!creator) { - const commentBody = (comment.body || "").trim(); + const commentBody = (commentHtml || "").trim(); const currentUserReference = `${comment.user?.login}`; // Regular expression to match the existing creator reference @@ -290,7 +276,6 @@ export const transformPlaneIssue = async ( ?.url.split("/") .pop(); - const allAssignees = issue.assignees; // If there is a github label, remove it and add a plane label const issueLabels: ExIssueLabel[] = []; const allIssueLabelIds = (issue.labels || []).map((label) => (label as unknown as ExIssueLabel).id); @@ -299,8 +284,6 @@ export const transformPlaneIssue = async ( issueLabels.push(label); } }); - const assignees = - allAssignees?.map((assignee) => userMap[assignee]?.login).filter((assignee) => assignee != undefined) || []; const ghLabels = issueLabels?.map((label) => transformPlaneLabel(label)) || []; ghLabels.push({ @@ -349,7 +332,6 @@ export const transformPlaneIssue = async ( repo: repo, state: targetState, created_at: issue.created_at, - assignees: assignees as string[], labels: ghLabels, }; }; diff --git a/apps/silo/src/apps/github/workers/github/event-handlers/issue.handler.ts b/apps/silo/src/apps/github/workers/github/event-handlers/issue.handler.ts index 3e8da46eb6..43a35aef3d 100644 --- a/apps/silo/src/apps/github/workers/github/event-handlers/issue.handler.ts +++ b/apps/silo/src/apps/github/workers/github/event-handlers/issue.handler.ts @@ -183,17 +183,6 @@ export const syncIssueWithPlane = async (store: Store, action: IssueWebhookActio .filter((l) => l !== undefined) as string[]; } - if (planeIssue.assignees) { - planeIssue.assignees = planeIssue.assignees - .map((assignee) => { - const user = users.find((u) => u.id === assignee); - if (user) { - return user.id; - } - }) - .filter((u) => u !== undefined) as string[]; - } - if (planeIssue.created_by) { const user = users.find((u) => u.display_name === planeIssue.created_by); if (user) { diff --git a/apps/silo/src/apps/github/workers/plane/event-handlers/issue-comment.handler.ts b/apps/silo/src/apps/github/workers/plane/event-handlers/issue-comment.handler.ts index 4b8d0c091a..968dc0a538 100644 --- a/apps/silo/src/apps/github/workers/plane/event-handlers/issue-comment.handler.ts +++ b/apps/silo/src/apps/github/workers/plane/event-handlers/issue-comment.handler.ts @@ -1,7 +1,7 @@ import { E_INTEGRATION_ENTITY_CONNECTION_MAP } from "@plane/etl/core"; import type { GithubService } from "@plane/etl/github"; import { logger } from "@plane/logger"; -import type { ExIssue, ExIssueComment, PlaneWebhookPayload } from "@plane/sdk"; +import type { ExIssue, ExIssueComment, ExIssueLabel, PlaneWebhookPayload } from "@plane/sdk"; import type { TGithubEntityConnection, TGithubWorkspaceConnection, TWorkspaceCredential } from "@plane/types"; import { E_INTEGRATION_KEYS } from "@plane/types"; import { getGithubService, getGithubUserService } from "@/apps/github/helpers"; @@ -11,7 +11,7 @@ import { getPlaneAPIClient } from "@/helpers/plane-api-client"; import { getAPIClient } from "@/services/client"; import type { TaskHeaders } from "@/types"; import type { MQ, Store } from "@/worker/base"; -import { imagePrefix } from "./issue.handler"; +import { imagePrefix, shouldSync } from "./issue.handler"; const apiClient = getAPIClient(); @@ -97,6 +97,17 @@ const handleCommentSync = async (store: Store, payload: PlaneWebhookPayload) => return; } + if (!shouldSync(issue.labels as unknown as ExIssueLabel[])) { + logger.info(`${ghIntegrationKey} Issue doesn't have a github label, skipping comment sync`, { + workspace: payload.workspace, + project: payload.project, + entityConnectionId: entityConnection.id, + ghIntegrationKey, + issueId: payload.issue, + }); + return; + } + const githubService = getGithubService( workspaceConnection as TGithubWorkspaceConnection, credentials.source_access_token, diff --git a/apps/silo/src/apps/github/workers/plane/event-handlers/issue.handler.ts b/apps/silo/src/apps/github/workers/plane/event-handlers/issue.handler.ts index f296c756c1..101d8d2b6a 100644 --- a/apps/silo/src/apps/github/workers/plane/event-handlers/issue.handler.ts +++ b/apps/silo/src/apps/github/workers/plane/event-handlers/issue.handler.ts @@ -8,6 +8,7 @@ import { getGithubService, getGithubUserService } from "@/apps/github/helpers"; import { getConnDetailsForPlaneToGithubSync } from "@/apps/github/helpers/helpers"; import { transformPlaneIssue } from "@/apps/github/helpers/transform"; import { env } from "@/env"; +import { GITHUB_LABEL } from "@/helpers/constants"; import { getPlaneAPIClient } from "@/helpers/plane-api-client"; import { getIssueUrlFromSequenceId } from "@/helpers/urls"; import { getAPIClient } from "@/services/client"; @@ -37,6 +38,9 @@ export const handleIssueWebhook = async (headers: TaskHeaders, mq: MQ, store: St await handleIssueSync(store, payload); }; +export const shouldSync = (labels: { name: string }[]): boolean => + labels.some((label) => label.name.toLowerCase() === GITHUB_LABEL); + const handleIssueSync = async (store: Store, payload: PlaneWebhookPayload) => { try { const ghIntegrationKey = payload.isEnterprise ? E_INTEGRATION_KEYS.GITHUB_ENTERPRISE : E_INTEGRATION_KEYS.GITHUB;