[SILO-704] [SILO-705] fix: remove assignees + priority sync + fix unlink of issue sync + fix comment links (#4846)

This commit is contained in:
Saurabh Kumar
2025-11-24 20:13:38 +05:30
committed by GitHub
parent c19cfb18ff
commit 651464792f
4 changed files with 19 additions and 33 deletions
+2 -20
View File
@@ -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 = `<p>${comment.body || ""}</p>`;
let comment_html = `${commentHtml || "<p></p>"}`;
if (!creator) {
const commentBody = (comment.body || "").trim();
const commentBody = (commentHtml || "<p></p>").trim();
const currentUserReference = `<a href="${comment.user?.html_url}">${comment.user?.login}</a>`;
// 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,
};
};
@@ -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) {
@@ -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,
@@ -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;