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

Commit e9516d8

Browse files
committed
fixes for webhook and label issue
1 parent b7a1a88 commit e9516d8

File tree

6 files changed

+71
-20
lines changed

6 files changed

+71
-20
lines changed

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
node_modules/
2+
.history
3+
.vscode
4+
.env
5+
public/
6+
7+
# compiled output
8+
/tmp
9+
/out-tsc
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
testem.log
34+
/typings
35+
36+
# e2e
37+
/e2e/*.js
38+
/e2e/*.map
39+
40+
# System Files
41+
.DS_Store
42+
Thumbs.db
43+
44+
src/public/
45+
.tmp

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- Nodejs 8 is required
66
- MongoDB 3.2
77
- kafka
8-
8+
- nodemon (for local development)
99

1010
## Install dependencies
1111

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"start:be": "nodemon src/app.js",
1717
"start:fe": "gulp build:watch",
1818
"build:fe": "gulp build",
19-
"build":"gulp build",
19+
"build": "gulp build",
2020
"test": "node ./node_modules/mocha/bin/mocha --recursive --timeout 999999 --colors tests/*.test.js --bail",
2121
"clean": "gulp clean",
2222
"publish": "gulp publish",

src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ _.forEach(routes, (verbs, path) => {
4242
if (v3jwt) {
4343
const decoded = jwtDecode(v3jwt);
4444
req.currentUser = {
45-
handle: decoded.handle,
45+
handle: decoded.handle.toLowerCase(),
4646
};
4747
}
4848
req.signature = `${def.controller}#${def.method}`;

src/front/src/app/upsertproject/upsertproject.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ angular.module('topcoderX').controller('ProjectController', ['currentUser', '$sc
2828
if ($rootScope.project) {
2929
$scope.title = 'Edit a Project';
3030
$scope.project = $rootScope.project;
31-
$scope.project.id = $rootScope.project._id;
31+
$scope.project.id = $rootScope.project.id;
3232
$scope.editing = true;
3333
} else {
3434
$scope.title = 'Add a Project';
@@ -100,7 +100,7 @@ angular.module('topcoderX').controller('ProjectController', ['currentUser', '$sc
100100
'repoToken': $scope.token,
101101
'baseUrl': HOOK_BASE_URL,
102102
'repoType': $scope.repoType,
103-
'challengeId': $scope.project.id
103+
'projectId': $scope.project.id
104104
};
105105
ProjectService.createHooks(objc).then(function () {
106106
Alert.info('Webhook Added Successfully', $scope);

src/services/ProjectService.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const Project = require('../models').Project;
1919

2020
const projectSchema = {
2121
project: {
22+
id: Joi.string().required(),
2223
title: Joi.string().required(),
2324
tcDirectId: Joi.number().required(),
2425
repoUrl: Joi.string().required(),
@@ -141,25 +142,27 @@ async function createLabel(body) {
141142
description: body.description,
142143
});
143144
}
145+
return;
144146
}
145147

146148
createLabel.schema = Joi.object().keys({
147-
repoType: Joi.string().required(),
148-
repoToken: Joi.string().required(),
149-
repoOwner: Joi.string().required(),
150-
repoName: Joi.string().required(),
151-
label: Joi.string().required(),
152-
description: Joi.string().required(),
153-
color: Joi.string().required(),
154-
baseUrl: Joi.string().required(),
149+
body: Joi.object().keys({
150+
repoType: Joi.string().required(),
151+
repoToken: Joi.string().required(),
152+
repoOwner: Joi.string().required(),
153+
repoName: Joi.string().required(),
154+
label: Joi.string().required(),
155+
description: Joi.string().required(),
156+
color: Joi.string().required(),
157+
}),
155158
});
156159

157160
/**
158161
* creates hook
159162
* @param {Object} body the request body
160163
*/
161164
async function createHook(body) {
162-
const projectDetail = await helper.ensureExists(Project, body.challengeId);
165+
const projectDetail = await helper.ensureExists(Project, body.projectId);
163166
if (body.repoType === 'github') {
164167
const client = gitHubApi.client(body.repoToken);
165168
const ghrepo = client.repo(`${body.repoOwner}/${body.repoName}`);
@@ -201,15 +204,18 @@ async function createHook(body) {
201204
}
202205
);
203206
}
207+
return;
204208
}
205209

206210
createHook.schema = Joi.object().keys({
207-
challengeId: Joi.string().required(),
208-
repoType: Joi.string().required(),
209-
repoOwner: Joi.string().required(),
210-
repoToken: Joi.string().required(),
211-
repoName: Joi.string().required(),
212-
baseUrl: Joi.string().required(),
211+
body: Joi.object().keys({
212+
projectId: Joi.string().required(),
213+
repoType: Joi.string().required(),
214+
repoOwner: Joi.string().required(),
215+
repoToken: Joi.string().required(),
216+
repoName: Joi.string().required(),
217+
baseUrl: Joi.string().required(),
218+
}),
213219
});
214220

215221
module.exports = {

0 commit comments

Comments
 (0)