@@ -2,36 +2,57 @@ const _ = require("lodash")
2
2
const gitUtils = require ( "../../utils/git" )
3
3
const timeUtils = require ( "../../utils/time" )
4
4
const stringUtils = require ( "../../utils/strings" )
5
+ const markupUtils = require ( "../../utils/markup" )
5
6
6
7
class UnapprovedRequestDescription {
7
- constructor ( request , config ) {
8
+ constructor ( request , config ) {
8
9
this . config = config
9
10
this . request = request
10
11
}
11
12
12
13
build = ( ) => {
14
+ const markup = markupUtils [ this . config . messenger . markup ]
15
+
13
16
const updated = new Date ( this . request . updated_at )
14
- const reaction = this . __getEmoji ( updated )
15
17
16
- const link = `[${ this . request . title } ](${ this . request . web_url } )`
18
+ const reaction = this . __getEmoji ( updated )
19
+ const link = markup . makeLink ( this . request . title , this . request . web_url )
17
20
const author = this . __authorString ( )
18
- const project = `[ ${ this . request . project . name } ]( ${ this . request . project . web_url } )`
21
+ const projectLink = markup . makeLink ( this . request . project . name , this . request . project . web_url )
19
22
const unresolvedAuthors = this . __unresolvedAuthorsString ( )
20
23
const approvedBy = this . __approvedByString ( )
21
24
const optionalDiff = this . __optionalDiffString ( )
22
25
23
- const parts = [ reaction , `**${ link } **` , optionalDiff , `(${ project } )` , `by **${ author } **` ]
24
-
25
- let message = [ _ . compact ( parts ) . join ( " " ) ]
26
+ const requestMessageParts = [
27
+ reaction ,
28
+ markup . makeBold ( link ) ,
29
+ optionalDiff ,
30
+ `(${ projectLink } )` ,
31
+ `by ${ markup . makeBold ( author ) } ` ,
32
+ ]
33
+ const requestMessageText = _ . compact ( requestMessageParts ) . join ( " " )
34
+ const primaryMessage = markup . makePrimaryInfo (
35
+ markup . makeText ( requestMessageText , { withMentions : false } ) ,
36
+ )
37
+ const secondaryMessageParts = [ ]
26
38
27
39
if ( unresolvedAuthors . length > 0 ) {
28
- message . push ( `unresolved threads by: ${ unresolvedAuthors } ` )
40
+ const text = `unresolved threads by: ${ unresolvedAuthors } `
41
+ const msg = markup . makeText ( text , { withMentions : true } )
42
+
43
+ secondaryMessageParts . push ( msg )
29
44
}
30
45
if ( approvedBy . length > 0 ) {
31
- message . push ( `already approved by: ${ approvedBy } ` )
46
+ const text = `already approved by: ${ approvedBy } `
47
+ const msg = markup . makeText ( text , { withMentions : false } )
48
+
49
+ secondaryMessageParts . push ( msg )
32
50
}
33
51
34
- return message . join ( "\n" )
52
+ const secondaryMessage = markup . makeAdditionalInfo ( secondaryMessageParts )
53
+ const message = markup . composeBody ( primaryMessage , secondaryMessage )
54
+
55
+ return message
35
56
}
36
57
37
58
__getConfigSetting = ( settingName , defaultValue = null ) => {
@@ -111,18 +132,18 @@ class UnapprovedRequestDescription {
111
132
_ . partialRight (
112
133
_ . filter ,
113
134
discussion => discussion . notes . some (
114
- note => note . resolvable && ! note . resolved
115
- )
135
+ note => note . resolvable && ! note . resolved ,
136
+ ) ,
116
137
) ,
117
138
_ . partialRight ( _ . map , selectNotes ) ,
118
139
_ . partialRight (
119
140
_ . map ,
120
- notes => notes . map ( note => note . author )
141
+ notes => notes . map ( note => note . author ) ,
121
142
) ,
122
143
_ . partialRight ( _ . flatten ) ,
123
144
_ . partialRight (
124
145
_ . uniqBy ,
125
- author => author . username
146
+ author => author . username ,
126
147
) ,
127
148
)
128
149
0 commit comments