diff --git a/README.md b/README.md index 0619b52..bff1fbc 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ To set up the `.dev.vars` file, you will need to provide the following variables matchThreshold: 0.95 warningThreshold: 0.75 jobMatchingThreshold: 0.75 + redactPrivateRepoComments: false ``` diff --git a/src/handlers/add-comments.ts b/src/handlers/add-comments.ts index 54745a1..e54f9b8 100644 --- a/src/handlers/add-comments.ts +++ b/src/handlers/add-comments.ts @@ -10,7 +10,7 @@ export async function addComments(context: Context) { const markdown = payload.comment.body; const authorId = payload.comment.user?.id || -1; const nodeId = payload.comment.node_id; - const isPrivate = payload.repository.private; + const isPrivate = context.config.redactPrivateRepoComments ? false : payload.repository.private; const issueId = payload.issue.node_id; try { diff --git a/src/handlers/add-issue.ts b/src/handlers/add-issue.ts index 969a5c2..642d20f 100644 --- a/src/handlers/add-issue.ts +++ b/src/handlers/add-issue.ts @@ -10,7 +10,7 @@ export async function addIssue(context: Context) { const markdown = payload.issue.body + " " + payload.issue.title || null; const authorId = payload.issue.user?.id || -1; const nodeId = payload.issue.node_id; - const isPrivate = payload.repository.private; + const isPrivate = !context.config.redactPrivateRepoComments && payload.repository.private; try { if (!markdown) { diff --git a/src/handlers/update-comments.ts b/src/handlers/update-comments.ts index b1b9d18..859063b 100644 --- a/src/handlers/update-comments.ts +++ b/src/handlers/update-comments.ts @@ -8,7 +8,7 @@ export async function updateComment(context: Context) { } = context; const { payload } = context as { payload: CommentPayload }; const nodeId = payload.comment.node_id; - const isPrivate = payload.repository.private; + const isPrivate = !context.config.redactPrivateRepoComments && payload.repository.private; const markdown = payload.comment.body || null; // Fetch the previous comment and update it in the db try { diff --git a/src/handlers/update-issue.ts b/src/handlers/update-issue.ts index 763b2ba..7495959 100644 --- a/src/handlers/update-issue.ts +++ b/src/handlers/update-issue.ts @@ -9,7 +9,7 @@ export async function updateIssue(context: Context) { const { payload } = context as { payload: IssuePayload }; const payloadObject = payload; const nodeId = payload.issue.node_id; - const isPrivate = payload.repository.private; + const isPrivate = !context.config.redactPrivateRepoComments && payload.repository.private; const markdown = payload.issue.body + " " + payload.issue.title || null; // Fetch the previous issue and update it in the db try { diff --git a/src/types/plugin-inputs.ts b/src/types/plugin-inputs.ts index 226beee..730bb19 100644 --- a/src/types/plugin-inputs.ts +++ b/src/types/plugin-inputs.ts @@ -23,6 +23,7 @@ export const pluginSettingsSchema = T.Object( matchThreshold: T.Number({ default: 0.95 }), warningThreshold: T.Number({ default: 0.75 }), jobMatchingThreshold: T.Number({ default: 0.75 }), + redactPrivateRepoComments: T.Boolean({ default: false }), }, { default: {} } ); diff --git a/tests/main.test.ts b/tests/main.test.ts index 14cbd7d..73c8a24 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -280,6 +280,7 @@ describe("Plugin tests", () => { warningThreshold: 0.75, matchThreshold: 0.95, jobMatchingThreshold: 0.95, + redactPrivateRepoComments: false, }, adapters: {} as Context["adapters"], logger: new Logs("debug"),