@@ -9,18 +9,13 @@ module.exports = async function (req, res) {
99 "Content-type" : "application/json" ,
1010 } ;
1111
12- const channel = req . body . channel ;
13- const members = req . body . members ;
14- const topic = req . body . topic ;
15- const type = req . body . type ;
16-
1712 const rcCreateChannelResponse = await axios ( {
1813 method : "post" ,
1914 url : `${ constants . rocketChatDomain } /api/v1/channels.create` ,
2015 headers : headers ,
2116 data : {
22- name : channel ,
23- members : members ,
17+ name : req . body . channel ,
18+ members : req . body . members ,
2419 } ,
2520 } ) ;
2621
@@ -30,24 +25,37 @@ module.exports = async function (req, res) {
3025 headers : headers ,
3126 data : {
3227 roomId : rcCreateChannelResponse . data . channel . _id ,
33- topic : topic ,
28+ topic : req . body . topic ,
3429 } ,
3530 } ) ;
3631
37- if ( type === "p" ) {
32+ if ( req . body . type === "p" ) {
3833 const rcSetChannelType = await axios ( {
3934 method : "post" ,
4035 url : `${ constants . rocketChatDomain } /api/v1/channels.setType` ,
4136 headers : headers ,
4237 data : {
4338 roomId : rcCreateChannelResponse . data . channel . _id ,
44- type : type ,
39+ type : req . body . type ,
4540 } ,
4641 } ) ;
4742 rcCreateChannelResponse . data . channel [ "type" ] =
4843 rcSetChannelType . data . channel . t ;
4944 }
5045
46+ // Set associated repository in channel custom fields
47+ await axios ( {
48+ method : "post" ,
49+ url : `${ constants . rocketChatDomain } /api/v1/channels.setCustomFields` ,
50+ headers : headers ,
51+ data : {
52+ roomId : rcCreateChannelResponse . data . channel . _id ,
53+ customFields : {
54+ "github_repository" : req . body . channel . replace ( "_" , "/" )
55+ }
56+ } ,
57+ } )
58+
5159 rcCreateChannelResponse . data . channel [ "topic" ] =
5260 rcSetChannelTopic . data . topic ;
5361
0 commit comments