const { WebClient } = require('@slack/web-api')
const web = new WebClient(auths.slack.oauth_access_token)
const { graphql } = require("@octokit/graphql");
const graphqlWithAuth = graphql.defaults({
headers: {
authorization: `token ${auths.github.oauth_access_token}`,
},
});
const { Octokit } = require("@octokit/rest");
const octokit = new Octokit({
auth: auths.github.oauth_access_token,
})
const { number: issue_number } = steps.trigger.event.issue
const opts = { ...steps.CONSTANTS, issue_number }
let numDays;
let channel = process.env.DEV_REL_ENG_SLACK_SUPPORT_CHANNEL
switch (steps.trigger.event.label.name) {
case 'actions-docs':
await octokit.rest.issues.createComment({
...opts,
body: `Thanks for the request! Did you know that anyone can [author and publish their own Pipedream actions](https://pipedream.com/docs/components/quickstart/nodejs/actions/)? Would you be interested in helping out with that? We're happy to answer any questions or support you in any way.
If you don't have the time, would you be willing to reach out to the app provider to see if they're interested in building these? When we work with an app partner, it improves the quality of the integration, and it helps when this kind of request comes from a customer like you.`,
});
await octokit.rest.issues.addLabels({
...opts,
labels: ["requested user help with component"]
})
break;
case 'source-docs':
await octokit.rest.issues.createComment({
...opts,
body: `Thanks for the request! Did you know that anyone can [author and publish their own Pipedream sources](https://pipedream.com/docs/components/quickstart/nodejs/sources/)? Would you be interested in helping out with that? We're happy to answer any questions or support you in any way.
If you don't have the time, would you be willing to reach out to the app provider to see if they're interested in building these? When we work with an app partner, it improves the quality of the integration, and it helps when this kind of request comes from a customer like you.`,
});
await octokit.rest.issues.addLabels({
...opts,
labels: ["requested user help with component"]
})
break;
case 'actions-and-sources-docs':
await octokit.rest.issues.createComment({
...opts,
body: `Thanks for the request! Did you know that anyone can [author and publish their own Pipedream actions](https://pipedream.com/docs/components/quickstart/nodejs/actions/) and [sources](https://pipedream.com/docs/components/quickstart/nodejs/sources/)? Would you be interested in helping out with that? We're happy to answer any questions or support you in any way.
If you don't have the time, would you be willing to reach out to the app provider to see if they're interested in building these? When we work with an app partner, it improves the quality of the integration, and it helps when this kind of request comes from a customer like you.`,
});
await octokit.rest.issues.addLabels({
...opts,
labels: ["requested user help with component"]
})
break;
case 'app':
await web.chat.postMessage({
text: `New app request: <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}>`,
channel: "#app-submissions",
})
break;
case 'added to app backlog':
await graphqlWithAuth({
query: `mutation addItemToProject(\$projectId: ID!, \$contentId: ID!) {
addProjectNextItem(input: {projectId: \$projectId, contentId: \$contentId}) {
projectNextItem {
id
}
}
}`,
projectId: "PN_kwDOApw2Qs4ACb_2",
contentId: steps.trigger.event.issue.node_id,
});
await octokit.rest.issues.createComment({
...opts,
body: `Thanks for the request! We've added this to [our integrations backlog](https://github.com/orgs/PipedreamHQ/projects/8/views/1), and we'll update this ticket with progress.`
})
break;
case 'remind-me-in-30':
case 'remind-me-in-90':
const splitLabel = steps.trigger.event.label.name.split('-')
const numDays = splitLabel[splitLabel.length - 1]
await web.chat.postMessage({
text: `I'll remind you to check <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}> in ${numDays} days`,
channel,
})
await web.chat.scheduleMessage({
text: `This is your ${numDays} day reminder to check on <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}>`,
channel,
post_at: Math.floor(+new Date() / 1000) + (60 * 60 * 24 * numDays)
})
await octokit.rest.issues.addLabels({
...opts,
labels: ["triaged"]
})
break;
case 'triaged':
default:
break;
}