Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Commit 8a51470

Browse files
authored
Merge pull request #96 from djcruz93/fix-allow-restricted-activity-access
[FIX] Anyone can subscribe to github activity of private rooms using roomName
2 parents 7cccff9 + f6621ab commit 8a51470

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

server/controllers/webhooks.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ module.exports.handleGithubWebhook = async (req, res) => {
4444

4545
module.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) => {
218232
module.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

Comments
 (0)