@@ -38,7 +38,6 @@ module.exports.handleGithubWebhook = async (req, res) => {
3838
3939module . exports . fetchGithubActivities = async ( req , res ) => {
4040 try {
41- // TODO Check if the user is part of the room for which activity subscription is requested
4241 const hook = await githubWebhook . findOne ( { hook_id : req . query . hook_id } ) ;
4342 if ( ! hook ) {
4443 res . status ( 404 ) . write ( "error: Activity Not Found\n\n" ) ;
@@ -83,16 +82,31 @@ module.exports.fetchWebhook = async (req, res) => {
8382 error : "Room name required as query parameter" ,
8483 } ) ;
8584 }
85+
86+ // Check if the user is part of the room for which activity subscription is requested
87+ await axios ( {
88+ method : "get" ,
89+ url : `${ constants . rocketChatDomain } /api/v1/channels.info?roomName=${ req . query . room_name } ` ,
90+ headers : {
91+ "X-Auth-Token" : req . cookies . rc_token || constants . rc_token ,
92+ "X-User-Id" : req . cookies . rc_uid || constants . rc_uid ,
93+ "Content-type" : "application/json" ,
94+ } ,
95+ } ) ;
96+
8697 const webhook = await githubWebhook . findOne ( {
8798 channel_name : req . query . room_name ,
8899 } ) ;
89100 if ( ! webhook ) {
90101 return res . status ( 200 ) . json ( { success : true , data : { } } ) ;
91102 }
92- return res . status ( 200 ) . json ( { success : true , data : {
93- webhook
94- } } )
95- } catch ( err ) {
103+ return res . status ( 200 ) . json ( {
104+ success : true ,
105+ data : {
106+ webhook,
107+ } ,
108+ } ) ;
109+ } catch ( err ) {
96110 console . log ( "ERROR" , err ) ;
97111 return res
98112 . status ( 500 )
@@ -212,7 +226,6 @@ module.exports.updateGithubWebhook = async (req, res) => {
212226module . exports . deleteGithubWebhook = async ( req , res ) => {
213227 try {
214228 if ( req . cookies [ "gh_private_repo_token" ] ) {
215-
216229 const headers = {
217230 accept : "application/vnd.github.v3+json" ,
218231 Authorization : `token ${ req . cookies [ "gh_private_repo_token" ] } ` ,
0 commit comments