@@ -44,7 +44,6 @@ module.exports.handleGithubWebhook = async (req, res) => {
4444
4545module . exports . fetchGithubActivities = async ( req , res ) => {
4646 try {
47- // TODO Check if the user is part of the room for which activity subscription is requested
4847 const hook = await githubWebhook . findOne ( { hook_id : req . query . hook_id } ) ;
4948 if ( ! hook ) {
5049 res . status ( 404 ) . write ( "error: Activity Not Found\n\n" ) ;
@@ -89,16 +88,31 @@ module.exports.fetchWebhook = async (req, res) => {
8988 error : "Room name required as query parameter" ,
9089 } ) ;
9190 }
91+
92+ // Check if the user is part of the room for which activity subscription is requested
93+ await axios ( {
94+ method : "get" ,
95+ url : `${ constants . rocketChatDomain } /api/v1/channels.info?roomName=${ req . query . room_name } ` ,
96+ headers : {
97+ "X-Auth-Token" : req . cookies . rc_token || constants . rc_token ,
98+ "X-User-Id" : req . cookies . rc_uid || constants . rc_uid ,
99+ "Content-type" : "application/json" ,
100+ } ,
101+ } ) ;
102+
92103 const webhook = await githubWebhook . findOne ( {
93104 channel_name : req . query . room_name ,
94105 } ) ;
95106 if ( ! webhook ) {
96107 return res . status ( 200 ) . json ( { success : true , data : { } } ) ;
97108 }
98- return res . status ( 200 ) . json ( { success : true , data : {
99- webhook
100- } } )
101- } catch ( err ) {
109+ return res . status ( 200 ) . json ( {
110+ success : true ,
111+ data : {
112+ webhook,
113+ } ,
114+ } ) ;
115+ } catch ( err ) {
102116 console . log ( "ERROR" , err ) ;
103117 return res
104118 . status ( 500 )
@@ -218,7 +232,6 @@ module.exports.updateGithubWebhook = async (req, res) => {
218232module . exports . deleteGithubWebhook = async ( req , res ) => {
219233 try {
220234 if ( req . cookies [ "gh_private_repo_token" ] ) {
221-
222235 const headers = {
223236 accept : "application/vnd.github.v3+json" ,
224237 Authorization : `token ${ req . cookies [ "gh_private_repo_token" ] } ` ,
0 commit comments