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

Commit e1ca506

Browse files

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

models/Project.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const schema = new Schema({
2323
type: Number,
2424
required: true
2525
},
26-
repoUrl: {type: String, required: true},
26+
repoUrls: {
27+
type: [String],
28+
required: true
29+
},
2730
repoId: {type: String, required: false},
2831
rocketChatWebhook: {type: String, required: false},
2932
rocketChatChannelName: {type: String, required: false},

routes/middlewares/RepositoryFilter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = (provider) => async (req, res, next) => {
2626
const projects = await dbHelper.scan(Project, {
2727
archived: 'false'
2828
});
29-
const found = _.some(projects, (project) => _.includes(repoNames, project.repoUrl));
29+
const found = _.some(projects, (project) => _.intersection(repoNames, project.repoUrls).length > 0);
3030
if (found) {
3131
return next();
3232
}

routes/middlewares/SecurityChecker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = (provider) => async (req, res, next) => {
1919
const params = req.body;
2020
if (provider === 'github') {
2121
const projectDetails = await dbHelper.scan(Project, {
22-
repoUrl: params.repository.html_url
22+
repoUrls: { contains: params.repository.html_url }
2323
});
2424
_.forEach(projectDetails, (projectDetail) => {
2525
const hash = crypto.createHmac('sha1', projectDetail.secretWebhookKey).update(req.rawBody).digest('hex');
@@ -29,7 +29,7 @@ module.exports = (provider) => async (req, res, next) => {
2929
});
3030
} else if (provider === 'gitlab') {
3131
const projectDetails = await dbHelper.scan(Project, {
32-
repoUrl: params.project.web_url
32+
repoUrls: { contains: params.project.web_url }
3333
});
3434
_.forEach(projectDetails, (projectDetail) => { // eslint-disable-line lodash/prefer-filter
3535
if (projectDetail.secretWebhookKey === req.header('X-Gitlab-Token')) {

scripts/create-update-tables.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
async function pingTable(model) {
3131
return new Promise((resolve, reject) => {
32-
if (!(model.scan && typeof model.scan == 'function' && model.scan({}).exec)) {
32+
if (!(model.scan && typeof model.scan === 'function' && model.scan({}).exec)) {
3333
return resolve();
3434
}
3535
model.scan({id: 0}).exec((err, result) => {
@@ -40,4 +40,4 @@ async function pingTable(model) {
4040
return resolve();
4141
});
4242
});
43-
}
43+
}

utils/db-helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ async function scan(model, scanParams) {
2828

2929
module.exports = {
3030
scan
31-
};
31+
};

0 commit comments

Comments
 (0)