mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-22 12:22:23 +02:00
UBERF-9634 Handle unsupported markdown in github integration (port to develop) (#8260)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -188,7 +188,7 @@ export class CommentSyncManager implements DocSyncManager {
|
||||
})
|
||||
|
||||
const messageData: MessageData = {
|
||||
message: await this.provider.getMarkup(integration, event.comment.body)
|
||||
message: await this.provider.getMarkupSafe(integration, event.comment.body)
|
||||
}
|
||||
|
||||
if (commentData !== undefined) {
|
||||
@@ -280,7 +280,7 @@ export class CommentSyncManager implements DocSyncManager {
|
||||
const account = existing?.modifiedBy ?? (await this.provider.getAccountU(comment.user))?._id ?? core.account.System
|
||||
|
||||
const messageData: MessageData = {
|
||||
message: await this.provider.getMarkup(container.container, comment.body)
|
||||
message: await this.provider.getMarkupSafe(container.container, comment.body)
|
||||
}
|
||||
if (existing === undefined) {
|
||||
try {
|
||||
|
||||
@@ -796,7 +796,7 @@ export abstract class IssueSyncManagerBase {
|
||||
|
||||
// if (k === 'description' && pv != null) {
|
||||
// const mdown = await this.provider.getMarkdown(pv)
|
||||
// pv = await this.provider.getMarkup(container.container, mdown, this.stripGuestLink)
|
||||
// pv = await this.provider.getMarkupSafe(container.container, mdown, this.stripGuestLink)
|
||||
// }
|
||||
// if (pv != null && pv !== v) {
|
||||
// // We have conflict of values, assume platform is more proper one.
|
||||
@@ -1014,7 +1014,7 @@ export abstract class IssueSyncManagerBase {
|
||||
// if (platformUpdate.description != null) {
|
||||
// // Need to convert to markdown
|
||||
// issueUpdate.body = await this.provider.getMarkdown(platformUpdate.description ?? '')
|
||||
// issueData.description = await this.provider.getMarkup(
|
||||
// issueData.description = await this.provider.getMarkupSafe(
|
||||
// container.container,
|
||||
// issueUpdate.body ?? '',
|
||||
// this.stripGuestLink
|
||||
|
||||
@@ -220,7 +220,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
const update: IssueUpdate = {}
|
||||
const du: DocumentUpdate<DocSyncInfo> = {}
|
||||
if (event.changes.body !== undefined) {
|
||||
update.description = await this.provider.getMarkup(integration, event.issue.body, this.stripGuestLink)
|
||||
update.description = await this.provider.getMarkupSafe(integration, event.issue.body, this.stripGuestLink)
|
||||
du.markdown = await this.provider.getMarkdown(update.description)
|
||||
}
|
||||
if (event.changes.title !== undefined) {
|
||||
@@ -413,7 +413,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
addHulyLink: false, // Do not need, since we create comment on Github about issue is connected.
|
||||
current: {
|
||||
title: issueExternal.title,
|
||||
description: await this.provider.getMarkup(container.container, issueExternal.body, this.stripGuestLink)
|
||||
description: await this.provider.getMarkupSafe(container.container, issueExternal.body, this.stripGuestLink)
|
||||
}
|
||||
}
|
||||
needCreateConnectedAtHuly = true
|
||||
@@ -501,7 +501,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
|
||||
const issueData = {
|
||||
title: issueExternal.title,
|
||||
description: await this.provider.getMarkup(container.container, issueExternal.body, this.stripGuestLink),
|
||||
description: await this.provider.getMarkupSafe(container.container, issueExternal.body, this.stripGuestLink),
|
||||
assignee: assignees[0]?.person,
|
||||
repository: info.repository,
|
||||
remainingTime: 0
|
||||
@@ -767,7 +767,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
},
|
||||
{ url: issueExternal.url, id: existing._id }
|
||||
)
|
||||
issueData.description = await this.provider.getMarkup(container.container, body, this.stripGuestLink)
|
||||
issueData.description = await this.provider.getMarkupSafe(container.container, body, this.stripGuestLink)
|
||||
} else if (hasFieldStateChanges) {
|
||||
await this.ctx.withLog(
|
||||
'==> updateIssue',
|
||||
|
||||
@@ -174,7 +174,7 @@ export class ProjectsSyncManager implements DocSyncManager {
|
||||
|
||||
const messageData: MilestoneData = {
|
||||
label: milestoneExternal.label,
|
||||
description: await this.provider.getMarkup(container.container, milestoneExternal.description)
|
||||
description: await this.provider.getMarkupSafe(container.container, milestoneExternal.description)
|
||||
}
|
||||
|
||||
await this.handleDiffUpdateMilestone(existing, info, messageData, container, milestoneExternal)
|
||||
|
||||
@@ -211,7 +211,11 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
update.title = event.pull_request.title
|
||||
}
|
||||
if (event.changes.body !== undefined) {
|
||||
update.description = await this.provider.getMarkup(integration, event.pull_request.body, this.stripGuestLink)
|
||||
update.description = await this.provider.getMarkupSafe(
|
||||
integration,
|
||||
event.pull_request.body,
|
||||
this.stripGuestLink
|
||||
)
|
||||
du.markdown = await this.provider.getMarkdown(update.description)
|
||||
}
|
||||
if (event.changes.base !== undefined) {
|
||||
@@ -464,7 +468,11 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
}
|
||||
const pullRequestData: GithubPullRequestData = {
|
||||
title: pullRequestExternal.title,
|
||||
description: await this.provider.getMarkup(container.container, pullRequestExternal.body, this.stripGuestLink),
|
||||
description: await this.provider.getMarkupSafe(
|
||||
container.container,
|
||||
pullRequestExternal.body,
|
||||
this.stripGuestLink
|
||||
),
|
||||
assignee: assignees[0]?.person ?? null,
|
||||
reviewers: reviewers.map((it: any) => it.person),
|
||||
draft: pullRequestExternal.isDraft,
|
||||
@@ -1067,7 +1075,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
},
|
||||
{ url: issueExternal.url }
|
||||
)
|
||||
issueData.description = await this.provider.getMarkup(container.container, body, this.stripGuestLink)
|
||||
issueData.description = await this.provider.getMarkupSafe(container.container, body, this.stripGuestLink)
|
||||
} else if (hasFieldsUpdate) {
|
||||
await this.ctx.withLog('==> updatePullRequest:', {}, async () => {
|
||||
this.ctx.info('update-fields', {
|
||||
|
||||
@@ -245,7 +245,7 @@ export class ReviewCommentSyncManager implements DocSyncManager {
|
||||
)
|
||||
if (reviewObj !== undefined) {
|
||||
const lastModified = Date.now()
|
||||
const body = await this.provider.getMarkup(integration, event.comment.body)
|
||||
const body = await this.provider.getMarkupSafe(integration, event.comment.body)
|
||||
await derivedClient.diffUpdate(
|
||||
reviewData,
|
||||
{
|
||||
@@ -343,7 +343,7 @@ export class ReviewCommentSyncManager implements DocSyncManager {
|
||||
}
|
||||
|
||||
const messageData: ReviewCommentData = {
|
||||
body: await this.provider.getMarkup(container.container, reviewComment.body),
|
||||
body: await this.provider.getMarkupSafe(container.container, reviewComment.body),
|
||||
diffHunk: reviewComment.diffHunk,
|
||||
isMinimized: reviewComment.isMinimized,
|
||||
reviewUrl: reviewComment.pullRequestReview.url,
|
||||
@@ -414,7 +414,7 @@ export class ReviewCommentSyncManager implements DocSyncManager {
|
||||
|
||||
if (Object.keys(platformUpdate).length > 0) {
|
||||
if (platformUpdate.body !== undefined) {
|
||||
const body = await this.provider.getMarkup(container.container, platformUpdate.body)
|
||||
const body = await this.provider.getMarkupSafe(container.container, platformUpdate.body)
|
||||
const okit = (await this.provider.getOctokit(account)) ?? container.container.octokit
|
||||
const q = `mutation updateReviewComment($commentID: ID!, $body: String!) {
|
||||
updatePullRequestReviewComment(input: {
|
||||
|
||||
@@ -305,7 +305,7 @@ export class ReviewSyncManager implements DocSyncManager {
|
||||
const account = existing?.modifiedBy ?? (await this.provider.getAccount(review.author))?._id ?? core.account.System
|
||||
|
||||
const messageData: ReviewData = {
|
||||
body: await this.provider.getMarkup(container.container, review.body),
|
||||
body: await this.provider.getMarkupSafe(container.container, review.body),
|
||||
state: toReviewState(review.state),
|
||||
comments: (review.comments?.nodes ?? []).map((it) => it.url)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user