@@ -6,59 +6,18 @@ const {
66 ISSUE_LABEL_HELP_WANTED ,
77 BOT_MESSAGE_ISSUE_NOT_OPEN ,
88 BOT_MESSAGE_ALREADY_ASSIGNED ,
9+ COMMUNITY_REPOS ,
910} = require ( './constants' ) ;
1011const {
1112 isCloseContributor,
1213 sendBotMessage,
1314 escapeIssueTitleForSlackMessage,
1415 hasRecentBotComment,
16+ hasLabel,
17+ getIssues,
18+ getPullRequests,
1519} = require ( './utils' ) ;
1620
17- async function hasLabel ( name , owner , repo , issueNumber , github , core ) {
18- let labels = [ ] ;
19- try {
20- const response = await github . rest . issues . listLabelsOnIssue ( {
21- owner,
22- repo,
23- issue_number : issueNumber ,
24- } ) ;
25- labels = response . data . map ( label => label . name ) ;
26- } catch ( error ) {
27- core . warning ( `Failed to fetch labels on issue #${ issueNumber } : ${ error . message } ` ) ;
28- labels = [ ] ;
29- }
30- return labels . some ( label => label . toLowerCase ( ) === name . toLowerCase ( ) ) ;
31- }
32-
33- async function getIssues ( assignee , state , owner , repo , github , core ) {
34- try {
35- const response = await github . rest . issues . listForRepo ( {
36- owner,
37- repo,
38- assignee,
39- state,
40- } ) ;
41- return response . data . filter ( issue => ! issue . pull_request ) ;
42- } catch ( error ) {
43- core . warning ( `Failed to fetch issues: ${ error . message } ` ) ;
44- return [ ] ;
45- }
46- }
47-
48- async function getPullRequests ( assignee , state , owner , repo , github , core ) {
49- try {
50- const response = await github . rest . pulls . list ( {
51- owner,
52- repo,
53- state,
54- } ) ;
55- return response . data . filter ( pr => pr . user . login === assignee ) ;
56- } catch ( error ) {
57- core . warning ( `Failed to fetch pull requests: ${ error . message } ` ) ;
58- return [ ] ;
59- }
60- }
61-
6221// Format information about author's assigned open issues
6322// as '(Issues #1 #2 | PRs #3)' and PRs for Slack message
6423function formatAuthorActivity ( issues , pullRequests ) {
@@ -201,8 +160,8 @@ module.exports = async ({ github, context, core }) => {
201160
202161 if ( contactSupport ) {
203162 const [ assignedOpenIssues , openPRs ] = await Promise . all ( [
204- getIssues ( commentAuthor , 'open' , owner , repo , github , core ) ,
205- getPullRequests ( commentAuthor , 'open' , owner , repo , github , core ) ,
163+ getIssues ( commentAuthor , 'open' , owner , COMMUNITY_REPOS , github , core ) ,
164+ getPullRequests ( commentAuthor , 'open' , owner , COMMUNITY_REPOS , github , core ) ,
206165 ] ) ;
207166 const authorActivity = formatAuthorActivity ( assignedOpenIssues , openPRs ) ;
208167 slackMessage += ` _${ authorActivity } _` ;
0 commit comments