1
1
import { DiffOutputItem } from 'openapi-diff-node'
2
2
import {
3
3
RichTextBlock ,
4
+ RichTextElement ,
4
5
RichTextList ,
5
6
RichTextQuote ,
6
7
RichTextSection ,
@@ -61,7 +62,8 @@ export class Slack {
61
62
private token : string ,
62
63
private channelId : string ,
63
64
private memberIdListToMention : string [ ] ,
64
- private githubConfig : Config [ 'githubConfig' ]
65
+ private githubConfig : Config [ 'githubConfig' ] ,
66
+ private apiDocumentationUrl ?: string
65
67
) {
66
68
this . client = new WebClient ( token )
67
69
}
@@ -86,6 +88,37 @@ export class Slack {
86
88
) } `
87
89
const color = STATUS_TO_LOCALE_KEY [ diff . status ] . color
88
90
91
+ const additionalInfoList : RichTextElement [ ] = [
92
+ {
93
+ type : 'text' ,
94
+ text : this . githubConfig . headCommitInfo . sha . slice ( 0 , 7 ) ,
95
+ style : {
96
+ code : true
97
+ }
98
+ } ,
99
+ {
100
+ type : 'text' ,
101
+ text : ` - `
102
+ } ,
103
+ {
104
+ type : 'link' ,
105
+ url : `https://github.com/${ this . githubConfig . repository } /commit/${ this . githubConfig . headCommitInfo . sha } ` ,
106
+ text : this . githubConfig . headCommitInfo . message
107
+ }
108
+ ]
109
+
110
+ if ( this . apiDocumentationUrl ) {
111
+ additionalInfoList . push ( {
112
+ type : 'text' ,
113
+ text : ` | `
114
+ } )
115
+ additionalInfoList . push ( {
116
+ type : 'link' ,
117
+ url : this . apiDocumentationUrl ,
118
+ text : `${ translate ( 'button.goto-api-documentation' ) } `
119
+ } )
120
+ }
121
+
89
122
const res = await this . client . chat . postMessage ( {
90
123
channel : this . channelId ,
91
124
text : mainText ,
@@ -145,24 +178,7 @@ export class Slack {
145
178
elements : [
146
179
{
147
180
type : 'rich_text_section' ,
148
- elements : [
149
- {
150
- type : 'text' ,
151
- text : this . githubConfig . headCommitInfo . sha . slice ( 0 , 7 ) ,
152
- style : {
153
- code : true
154
- }
155
- } ,
156
- {
157
- type : 'text' ,
158
- text : ` - `
159
- } ,
160
- {
161
- type : 'link' ,
162
- url : `https://github.com/${ this . githubConfig . repository } /commit/${ this . githubConfig . headCommitInfo . sha } ` ,
163
- text : this . githubConfig . headCommitInfo . message
164
- }
165
- ]
181
+ elements : additionalInfoList
166
182
}
167
183
]
168
184
}
0 commit comments