generated from ubiquity-os/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from sshivaditya2019/issuesim
- Loading branch information
Showing
6 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Context } from "../types"; | ||
import { IssueTransferPayload } from "../types/payload"; | ||
|
||
export async function issueTransfer(context: Context) { | ||
const { | ||
logger, | ||
adapters: { supabase }, | ||
} = context; | ||
const { changes, issue } = (context as { payload: IssueTransferPayload }).payload; | ||
const nodeId = issue.node_id; | ||
const { new_issue, new_repository } = changes; | ||
//Fetch the new details of the issue | ||
const newIssueNodeId = new_issue.node_id; | ||
const markdown = new_issue.body + " " + new_issue.title || null; | ||
const authorId = new_issue.user?.id || -1; | ||
const isPrivate = new_repository.private; | ||
|
||
//Delete the issue from the old repository | ||
//Create the new issue in the new repository | ||
try { | ||
await supabase.issue.deleteIssue(nodeId); | ||
await supabase.issue.createIssue(newIssueNodeId, new_issue, isPrivate, markdown, authorId); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
logger.error(`Error transferring issue:`, { error: error, stack: error.stack }); | ||
throw error; | ||
} else { | ||
logger.error(`Error transferring issue:`, { err: error, error: new Error() }); | ||
throw error; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { EmitterWebhookEvent as WebhookEvent } from "@octokit/webhooks"; | ||
export type CommentPayload = WebhookEvent<"issue_comment">["payload"]; | ||
export type IssuePayload = WebhookEvent<"issues">["payload"]; | ||
export type IssueTransferPayload = WebhookEvent<"issues.transferred">["payload"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters