diff --git a/README.md b/README.md index 71f9029..4ce9773 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The PR Channel Slackbot action does the following steps for each configured Slac - The action adds a response within the thread for each message containing a link to an open pull request. 5. **Copy Reactions**: - - Any reactions present on the original message are copied over to the response within the thread, ensuring continuity and visibility of feedback. + - Any reactions present on the original message are copied over to the response within the thread, ensuring continuity and visibility of feedback. This can be disabled via ### Example Output ![alt text](images/example.png) @@ -154,14 +154,15 @@ Example `pr_channel_slackbot_config.json`: "limit": 100 }, "project-bar-prs": { - "channelId": "C654321" + "channelId": "C654321", + "disableReactionCopying": true }, "project-baz-prs": { "channelId": "C987654", "limit": 50, "disabled": true } - } + }, } ``` @@ -179,13 +180,14 @@ The `reactions` section contains configuration for each reaction type used by th The `channels` section contains a map of human-readable channel names to channel configurations. The name of the keys here does not impact processing. It is recommended that the keys match the name of the assocaited channel for clarity. Each channel configuration can have the following fields: -1. `channelId` - (required) the ID of the channel. +* `channelId` - (required) the ID of the channel. > [!NOTE] > If you do not know the ID of a channel, you can easily retrieve it from a link to that channel. Simply right-click on the channel and select `Copy` > `Copy link`. The last part of the link will be the channel ID. For example, if your channel's link is `https://mycompany.slack.com/archives/C123456`, then the channel ID is `C123456`. -2. `limit` - (optional - default `50`) this limits how many messages in the channel will be reviewed for pull requests. Only the last `` messages will be checked. +* `limit` - (optional - default `50`) this limits how many messages in the channel will be reviewed for pull requests. Only the last `` messages will be checked. > [!NOTE] > It is recommended that you use a channel that is dedicated for pull requests to separate requests for reviews from other development-related conversations. If your team is consistently reviewing pull requests, a large limit should not be required. -3. `disabled` - (optional - default `false`) if you wish to disable a channel without completely removing it, you can mark it as disabled. +* `disabled` - (optional - default `false`) if you wish to disable a channel without completely removing it, you can mark it as disabled. +* `disableReactionCopying` - (optional - default `false`) disable copying of reactions from the original post to the threads when `true`. ## License diff --git a/dist/index.mjs b/dist/index.mjs index 95cf3cd..7496d39 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -42391,7 +42391,7 @@ async function run() { } messagesForChannel.push( - await (0,_workflow_mjs__WEBPACK_IMPORTED_MODULE_1__/* .buildPrMessage */ .wB)(channelId, message, pullRequests[0], reactionConfig) + await (0,_workflow_mjs__WEBPACK_IMPORTED_MODULE_1__/* .buildPrMessage */ .wB)(channelId, message, pullRequests[0], reactionConfig, channelConfig) ); } await (0,_slack_mjs__WEBPACK_IMPORTED_MODULE_2__/* .postOpenPrs */ .JZ)(channelId, messagesForChannel); @@ -42560,6 +42560,7 @@ function distinct(array) { * @typedef {Object} ChannelConfig * @property {string} channelId * @property {number} limit + * @property {boolean} disableReactionCopying */ /** * @typedef {Object} PrMessage @@ -42586,7 +42587,8 @@ function getConfig() { const channelConfig = Object.values(rawChannelConfig) .map(it => ({ ...it, - limit: it.limit ?? 50 + limit: it.limit ?? 50, + disableReactionCopying: it.disableReactionCopying ?? false })) .filter(it => it.channelId && !it.disabled); @@ -42656,13 +42658,16 @@ function isResolved(message, reactionConfig) { * @param {SlackMessage} message * @param {PullRequest} pullRequest * @param {ReactionConfig} reactionConfig + * @param {ChannelConfig} channelConfig * @returns {Promise} */ -async function buildPrMessage(channelId, message, pullRequest, reactionConfig) { +async function buildPrMessage(channelId, message, pullRequest, reactionConfig, channelConfig) { /** @type {Array} */ - const existingReactions = (message.reactions ?? []) - .map(reaction => reaction.name) - .filter(it => it); + const existingReactions = channelConfig.disableReactionCopying + ? [] + : (message.reactions ?? []) + .map(reaction => reaction.name) + .filter(it => it); const reviewReactions = await (0,github/* getReviewReactions */.zp)(pullRequest, reactionConfig); const allReactions = distinct([...existingReactions, ...reviewReactions]); const permalink = await (0,slack/* getPermalink */.t5)(channelId, message.ts); diff --git a/example-config.json b/example-config.json index 73f0d8f..ce7f393 100644 --- a/example-config.json +++ b/example-config.json @@ -12,7 +12,8 @@ ], "changesRequested": [ "changes-requested" - ] + ], + "copyExisting": false }, "channels": { "project-foo-prs": { diff --git a/src/index.mjs b/src/index.mjs index b7ab692..3144958 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -23,7 +23,7 @@ export async function run() { } messagesForChannel.push( - await buildPrMessage(channelId, message, pullRequests[0], reactionConfig) + await buildPrMessage(channelId, message, pullRequests[0], reactionConfig, channelConfig) ); } await postOpenPrs(channelId, messagesForChannel); diff --git a/src/workflow.mjs b/src/workflow.mjs index 6429653..a56ced8 100644 --- a/src/workflow.mjs +++ b/src/workflow.mjs @@ -19,6 +19,7 @@ import { distinct } from './utils.mjs'; * @typedef {Object} ChannelConfig * @property {string} channelId * @property {number} limit + * @property {boolean} disableReactionCopying */ /** * @typedef {Object} PrMessage @@ -45,7 +46,8 @@ export function getConfig() { const channelConfig = Object.values(rawChannelConfig) .map(it => ({ ...it, - limit: it.limit ?? 50 + limit: it.limit ?? 50, + disableReactionCopying: it.disableReactionCopying ?? false })) .filter(it => it.channelId && !it.disabled); @@ -115,13 +117,16 @@ function isResolved(message, reactionConfig) { * @param {SlackMessage} message * @param {PullRequest} pullRequest * @param {ReactionConfig} reactionConfig + * @param {ChannelConfig} channelConfig * @returns {Promise} */ -export async function buildPrMessage(channelId, message, pullRequest, reactionConfig) { +export async function buildPrMessage(channelId, message, pullRequest, reactionConfig, channelConfig) { /** @type {Array} */ - const existingReactions = (message.reactions ?? []) - .map(reaction => reaction.name) - .filter(it => it); + const existingReactions = channelConfig.disableReactionCopying + ? [] + : (message.reactions ?? []) + .map(reaction => reaction.name) + .filter(it => it); const reviewReactions = await getReviewReactions(pullRequest, reactionConfig); const allReactions = distinct([...existingReactions, ...reviewReactions]); const permalink = await getPermalink(channelId, message.ts);