@@ -11,10 +11,37 @@ module.exports.createNextMeeting = async function (client, opts) {
1111 return issues . create ( client , meetingToCreate )
1212}
1313
14+ module . exports . setMeetingIssueBody = async function ( client , opts ) {
15+ const issue = await getNextIssue ( client , opts )
16+ issue . body = typeof opts . template === 'function' ? opts . template ( issue ) : opts . template
17+ return issues . update ( client , issue )
18+ }
19+
20+ async function getNextIssue ( client , opts ) {
21+ const now = opts . now || DateTime . utc ( )
22+ const date = getNextScheduledMeeting ( opts . schedules , now )
23+ const title = typeof opts . issueTitle === 'function' ? opts . issueTitle ( { date } ) : opts . issueTitle
24+
25+ const issue = {
26+ owner : opts . owner ,
27+ repo : opts . repo ,
28+ title,
29+ date,
30+ agendaLabel : opts . agendaLabel ,
31+ agendaIssues : opts . agendaIssues ,
32+ labels : opts . labels ,
33+ meetingNotes : opts . meetingNotes || '' ,
34+ issue_number : ( opts . issue || { } ) . number || null ,
35+ body : ''
36+ }
37+ return issue
38+ }
39+
1440const shouldCreateNextMeetingIssue = module . exports . shouldCreateNextMeetingIssue = async function ( client , opts = { } ) {
1541 const now = opts . now || DateTime . utc ( )
1642 const createWithin = Duration . fromISO ( opts . createWithin )
17- const next = getNextScheduledMeeting ( opts . schedules , now )
43+ const issue = getNextIssue ( client , opts )
44+ const { date : next , title : nextIssueTitle } = issue
1845
1946 // Further out than the create within limit
2047 if ( next > now . plus ( createWithin ) ) {
@@ -27,7 +54,6 @@ const shouldCreateNextMeetingIssue = module.exports.shouldCreateNextMeetingIssue
2754 label : opts . labels
2855 } )
2956
30- const nextIssueTitle = typeof opts . issueTitle === 'function' ? opts . issueTitle ( { date : next } ) : opts . issueTitle
3157 const shouldCreate = ! meetings . find ( ( i ) => {
3258 return i . title === nextIssueTitle
3359 } )
@@ -36,25 +62,6 @@ const shouldCreateNextMeetingIssue = module.exports.shouldCreateNextMeetingIssue
3662 }
3763
3864 // Load issues for agenda
39- const agendaLabel = opts . agendaLabel
40- const agendaResp = await client . issues . listForRepo ( {
41- owner : opts . owner ,
42- repo : opts . repo ,
43- state : 'open' ,
44- labels : agendaLabel
45- } )
46-
47- const issue = {
48- owner : opts . owner ,
49- repo : opts . repo ,
50- title : nextIssueTitle ,
51- date : next ,
52- agendaLabel : agendaLabel ,
53- agendaIssues : agendaResp . data ,
54- labels : opts . labels ,
55- body : null
56- }
57- issue . body = typeof opts . template === 'function' ? opts . template ( issue ) : opts . template
5865 return issue
5966}
6067
0 commit comments