Skip to content

Commit 039fdb4

Browse files
Merge pull request #167 from topcoder-platform/dev
[PROD] Post Release Patch 1.5.3
2 parents 87bcbb8 + 151c026 commit 039fdb4

10 files changed

+186
-61
lines changed

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@
6161
- first it would be waiting for `kafka-client` to create all the required topics and exit, you would see:
6262

6363
```
64-
tc-taas-es-procesor | Waiting for kafka-client to exit....
64+
tc-taas-es-processor | Waiting for kafka-client to exit....
6565
```
6666

6767
- after that, `taas-es-processor` would be started itself. Make sure it successfully connected to Kafka, you should see 9 lines with text `Subscribed to taas.`:
6868

6969
```
70-
tc-taas-es-procesor | 2021-01-22T14:27:48.971Z DEBUG no-kafka-client Subscribed to taas.jobcandidate.create:0 offset 0 leader kafka:9093
71-
tc-taas-es-procesor | 2021-01-22T14:27:48.972Z DEBUG no-kafka-client Subscribed to taas.job.create:0 offset 0 leader kafka:9093
72-
tc-taas-es-procesor | 2021-01-22T14:27:48.972Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.delete:0 offset 0 leader kafka:9093
73-
tc-taas-es-procesor | 2021-01-22T14:27:48.973Z DEBUG no-kafka-client Subscribed to taas.jobcandidate.delete:0 offset 0 leader kafka:9093
74-
tc-taas-es-procesor | 2021-01-22T14:27:48.974Z DEBUG no-kafka-client Subscribed to taas.jobcandidate.update:0 offset 0 leader kafka:9093
75-
tc-taas-es-procesor | 2021-01-22T14:27:48.975Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.create:0 offset 0 leader kafka:9093
76-
tc-taas-es-procesor | 2021-01-22T14:27:48.976Z DEBUG no-kafka-client Subscribed to taas.job.delete:0 offset 0 leader kafka:9093
77-
tc-taas-es-procesor | 2021-01-22T14:27:48.977Z DEBUG no-kafka-client Subscribed to taas.job.update:0 offset 0 leader kafka:9093
78-
tc-taas-es-procesor | 2021-01-22T14:27:48.978Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.update:0 offset 0 leader kafka:9093
70+
tc-taas-es-processor | 2021-01-22T14:27:48.971Z DEBUG no-kafka-client Subscribed to taas.jobcandidate.create:0 offset 0 leader kafka:9093
71+
tc-taas-es-processor | 2021-01-22T14:27:48.972Z DEBUG no-kafka-client Subscribed to taas.job.create:0 offset 0 leader kafka:9093
72+
tc-taas-es-processor | 2021-01-22T14:27:48.972Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.delete:0 offset 0 leader kafka:9093
73+
tc-taas-es-processor | 2021-01-22T14:27:48.973Z DEBUG no-kafka-client Subscribed to taas.jobcandidate.delete:0 offset 0 leader kafka:9093
74+
tc-taas-es-processor | 2021-01-22T14:27:48.974Z DEBUG no-kafka-client Subscribed to taas.jobcandidate.update:0 offset 0 leader kafka:9093
75+
tc-taas-es-processor | 2021-01-22T14:27:48.975Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.create:0 offset 0 leader kafka:9093
76+
tc-taas-es-processor | 2021-01-22T14:27:48.976Z DEBUG no-kafka-client Subscribed to taas.job.delete:0 offset 0 leader kafka:9093
77+
tc-taas-es-processor | 2021-01-22T14:27:48.977Z DEBUG no-kafka-client Subscribed to taas.job.update:0 offset 0 leader kafka:9093
78+
tc-taas-es-processor | 2021-01-22T14:27:48.978Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.update:0 offset 0 leader kafka:9093
7979
```
8080

8181
</details>

config/default.js

+5
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ module.exports = {
116116
// the emails address for receiving the issue report
117117
// REPORT_ISSUE_EMAILS may contain comma-separated list of email which is converted to array
118118
REPORT_ISSUE_EMAILS: (process.env.REPORT_ISSUE_EMAILS || '').split(','),
119+
// the emails address for receiving the issue report
120+
// REPORT_ISSUE_EMAILS may contain comma-separated list of email which is converted to array
121+
REQUEST_EXTENSION_EMAILS: (process.env.REQUEST_EXTENSION_EMAILS || '').split(','),
119122
// SendGrid email template ID for reporting issue
120123
REPORT_ISSUE_SENDGRID_TEMPLATE_ID: process.env.REPORT_ISSUE_SENDGRID_TEMPLATE_ID,
124+
// SendGrid email template ID for requesting extension
125+
REQUEST_EXTENSION_SENDGRID_TEMPLATE_ID: process.env.REQUEST_EXTENSION_SENDGRID_TEMPLATE_ID,
121126
// the URL where TaaS App is hosted
122127
TAAS_APP_URL: process.env.TAAS_APP_URL || 'https://platform.topcoder-dev.com/taas/myteams'
123128
}

config/email_template.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports = {
2222
recipients: config.REPORT_ISSUE_EMAILS,
2323
sendgridTemplateId: config.REPORT_ISSUE_SENDGRID_TEMPLATE_ID
2424
},
25+
2526
/* Report issue for a particular member
2627
*
2728
* - userHandle: the user handle. Example: "bili_2021"
@@ -39,5 +40,24 @@ module.exports = {
3940
'{{reportText}}',
4041
recipients: config.REPORT_ISSUE_EMAILS,
4142
sendgridTemplateId: config.REPORT_ISSUE_SENDGRID_TEMPLATE_ID
43+
},
44+
45+
/* Request extension for a particular member
46+
*
47+
* - userHandle: the user handle. Example: "bili_2021"
48+
* - projectId: the project ID. Example: 123412
49+
* - projectName: the project name. Example: "TaaS API Misc Updates"
50+
* - text: comment for the request. Example: "I would like to keep working with this member for 2 months..."
51+
*/
52+
'extension-request': {
53+
subject: 'Extension Requested for member {{userHandle}} on TaaS Team {{projectName}} ({{projectId}}).',
54+
body: 'User Handle: {{userHandle}}' + '\n' +
55+
'Project Name: {{projectName}}' + '\n' +
56+
'Project ID: {{projectId}}' + '\n' +
57+
`Project URL: ${config.TAAS_APP_URL}/{{projectId}}` + '\n' +
58+
'\n' +
59+
'{{text}}',
60+
recipients: config.REPORT_ISSUE_EMAILS,
61+
sendgridTemplateId: config.REQUEST_EXTENSION_SENDGRID_TEMPLATE_ID
4262
}
4363
}

docs/Topcoder-bookings-api.postman_collection.json

+85-47
Original file line numberDiff line numberDiff line change
@@ -4407,7 +4407,7 @@
44074407
},
44084408
"response": []
44094409
},
4410-
{
4410+
{
44114411
"name": "POST /taas-teams/email - team-issue-report",
44124412
"request": {
44134413
"method": "POST",
@@ -4483,51 +4483,89 @@
44834483
},
44844484
"response": []
44854485
},
4486-
{
4487-
"name": "POST /taas-teams/:id/members",
4488-
"request": {
4489-
"method": "POST",
4490-
"header": [
4491-
{
4492-
"key": "Authorization",
4493-
"type": "text",
4494-
"value": "Bearer {{token_administrator}}"
4495-
},
4496-
{
4497-
"key": "Content-Type",
4498-
"type": "text",
4499-
"value": "application/json"
4500-
}
4501-
],
4502-
"body": {
4503-
"mode": "raw",
4504-
"raw": "{\n \"handles\": [\n \"tester1234\",\n \"non-existing\"\n ],\n \"emails\": [\n \"[email protected]\",\n \"[email protected]\"\n ]\n}",
4505-
"options": {
4506-
"raw": {
4507-
"language": "json"
4508-
}
4509-
}
4510-
},
4511-
"url": {
4512-
"raw": "{{URL}}/taas-teams/:id/members",
4513-
"host": [
4514-
"{{URL}}"
4515-
],
4516-
"path": [
4517-
"taas-teams",
4518-
":id",
4519-
"members"
4520-
],
4521-
"variable": [
4522-
{
4523-
"key": "id",
4524-
"value": "16705"
4525-
}
4526-
]
4527-
}
4528-
},
4529-
"response": []
4530-
},
4486+
{
4487+
"name": "POST /taas-teams/email - extension-request",
4488+
"request": {
4489+
"method": "POST",
4490+
"header": [
4491+
{
4492+
"key": "Authorization",
4493+
"type": "text",
4494+
"value": "Bearer {{token_member}}"
4495+
},
4496+
{
4497+
"key": "Content-Type",
4498+
"type": "text",
4499+
"value": "application/json"
4500+
}
4501+
],
4502+
"body": {
4503+
"mode": "raw",
4504+
"raw": "{\n \"template\": \"extension-request\",\n \"data\": {\n \"projectName\": \"TaaS Project Name\",\n \"projectId\": 12345,\n \"userHandle\": \"pshah_manager\",\n \"reportText\": \"I would like to keep working with this member for 2 months...\"\n }\n}",
4505+
"options": {
4506+
"raw": {
4507+
"language": "json"
4508+
}
4509+
}
4510+
},
4511+
"url": {
4512+
"raw": "{{URL}}/taas-teams/email",
4513+
"host": [
4514+
"{{URL}}"
4515+
],
4516+
"path": [
4517+
"taas-teams",
4518+
"email"
4519+
]
4520+
}
4521+
},
4522+
"response": []
4523+
},
4524+
{
4525+
"name": "POST /taas-teams/:id/members",
4526+
"request": {
4527+
"method": "POST",
4528+
"header": [
4529+
{
4530+
"key": "Authorization",
4531+
"type": "text",
4532+
"value": "Bearer {{token_administrator}}"
4533+
},
4534+
{
4535+
"key": "Content-Type",
4536+
"type": "text",
4537+
"value": "application/json"
4538+
}
4539+
],
4540+
"body": {
4541+
"mode": "raw",
4542+
"raw": "{\n \"handles\": [\n \"tester1234\",\n \"non-existing\"\n ],\n \"emails\": [\n \"[email protected]\",\n \"[email protected]\"\n ]\n}",
4543+
"options": {
4544+
"raw": {
4545+
"language": "json"
4546+
}
4547+
}
4548+
},
4549+
"url": {
4550+
"raw": "{{URL}}/taas-teams/:id/members",
4551+
"host": [
4552+
"{{URL}}"
4553+
],
4554+
"path": [
4555+
"taas-teams",
4556+
":id",
4557+
"members"
4558+
],
4559+
"variable": [
4560+
{
4561+
"key": "id",
4562+
"value": "16705"
4563+
}
4564+
]
4565+
}
4566+
},
4567+
"response": []
4568+
},
45314569
{
45324570
"name": "GET /taas-teams/:id/members",
45334571
"request": {
@@ -9772,4 +9810,4 @@
97729810
]
97739811
}
97749812
]
9775-
}
9813+
}

docs/swagger.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ paths:
2323
Create job.
2424
2525
**Authorization** All topcoder members are allowed
26+
27+
Permission rules on field `isApplicationPageActive`:
28+
- M2M user is allowed to set the value of the field
29+
- Other users are not allowed to set the value of the field
30+
2631
security:
2732
- bearerAuth: []
2833
requestBody:
@@ -352,6 +357,10 @@ paths:
352357
Update the job.
353358
354359
**Authorization** Every topcoder member can update the job he/she created. bookingmanager and connectmember can update all jobs.
360+
361+
Permission rules on field `isApplicationPageActive`:
362+
- M2M user is allowed to update the value of the field
363+
- Other users are not allowed to update the value of the field
355364
security:
356365
- bearerAuth: []
357366
parameters:
@@ -413,6 +422,10 @@ paths:
413422
Update job.
414423
415424
**Authorization** Topcoder token with patch job scope is allowed
425+
426+
Permission rules on field `isApplicationPageActive`:
427+
- M2M user is allowed to update the value of the field
428+
- Other users are not allowed to update the value of the field
416429
security:
417430
- bearerAuth: []
418431
parameters:
@@ -1980,6 +1993,9 @@ components:
19801993
description: "The job candidates."
19811994
items:
19821995
$ref: '#/components/schemas/JobCandidate'
1996+
isApplicationPageActive:
1997+
type: boolean
1998+
default: false
19831999
createdAt:
19842000
type: string
19852001
format: date-time
@@ -2057,6 +2073,9 @@ components:
20572073
type: string
20582074
format: uuid
20592075
description: "The skill id."
2076+
isApplicationPageActive:
2077+
type: boolean
2078+
default: false
20602079
JobCandidate:
20612080
required:
20622081
- id
@@ -2186,6 +2205,9 @@ components:
21862205
type: string
21872206
format: uuid
21882207
description: "The skill id."
2208+
isApplicationPageActive:
2209+
type: boolean
2210+
default: false
21892211
ResourceBooking:
21902212
required:
21912213
- id

local/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
- 9200:9200
4646

4747
taas-es-processor:
48-
container_name: tc-taas-es-procesor
48+
container_name: tc-taas-es-processor
4949
build:
5050
context: ./generic-tc-service
5151
args:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Add isApplicationPageActive field to the Job model.
3+
*/
4+
5+
module.exports = {
6+
up: queryInterface => {
7+
return Promise.all([
8+
queryInterface.sequelize.query('ALTER TABLE bookings.jobs ADD is_application_page_active BOOLEAN NOT NULL DEFAULT false'),
9+
// this command looks like does nothing, because we already set default value to `null` and this column cannot be `NULL`
10+
// but we keep it as it was tested this way, and it looks harmful
11+
queryInterface.sequelize.query('UPDATE bookings.jobs SET is_application_page_active=false WHERE is_application_page_active is NULL'),
12+
])
13+
},
14+
down: queryInterface => {
15+
return Promise.all([
16+
queryInterface.sequelize.query('ALTER TABLE bookings.jobs DROP is_application_page_active')
17+
])
18+
}
19+
}

src/common/helper.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ esIndexPropertyMapping[config.get('esConfig.ES_INDEX_JOB')] = {
7070
workload: { type: 'keyword' },
7171
skills: { type: 'keyword' },
7272
status: { type: 'keyword' },
73+
isApplicationPageActive: { type: 'boolean' },
7374
createdAt: { type: 'date' },
7475
createdBy: { type: 'keyword' },
7576
updatedAt: { type: 'date' },

src/models/Job.js

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ module.exports = (sequelize) => {
9898
type: Sequelize.STRING(255),
9999
allowNull: false
100100
},
101+
isApplicationPageActive: {
102+
field: 'is_application_page_active',
103+
type: Sequelize.BOOLEAN,
104+
defaultValue: false,
105+
allowNull: false
106+
},
101107
createdBy: {
102108
field: 'created_by',
103109
type: Sequelize.UUID,

src/services/JobService.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ async function createJob (currentUser, job) {
148148
await helper.checkIsMemberOfProject(currentUser.userId, job.projectId)
149149
}
150150

151+
// the "isApplicationPageActive" field can be set/updated only by M2M user
152+
if (!_.isUndefined(job.isApplicationPageActive) && !currentUser.isMachine) {
153+
throw new errors.ForbiddenError('You are not allowed to set/update the value of field "isApplicationPageActive".')
154+
}
155+
151156
await _validateSkills(job.skills)
152157
job.id = uuid()
153158
job.createdBy = await helper.getUserId(currentUser.userId)
@@ -171,7 +176,8 @@ createJob.schema = Joi.object().keys({
171176
resourceType: Joi.stringAllowEmpty().allow(null),
172177
rateType: Joi.rateType().allow(null),
173178
workload: Joi.workload().allow(null),
174-
skills: Joi.array().items(Joi.string().uuid()).required()
179+
skills: Joi.array().items(Joi.string().uuid()).required(),
180+
isApplicationPageActive: Joi.boolean()
175181
}).required()
176182
}).required()
177183

@@ -188,6 +194,12 @@ async function updateJob (currentUser, id, data) {
188194
}
189195
let job = await Job.findById(id)
190196
const oldValue = job.toJSON()
197+
198+
// the "isApplicationPageActive" field can be set/updated only by M2M user
199+
if (!_.isUndefined(data.isApplicationPageActive) && !currentUser.isMachine) {
200+
throw new errors.ForbiddenError('You are not allowed to set/update the value of field "isApplicationPageActive".')
201+
}
202+
191203
const ubahnUserId = await helper.getUserId(currentUser.userId)
192204
if (!currentUser.hasManagePermission && !currentUser.isMachine) {
193205
// Check whether user can update the job.
@@ -232,7 +244,8 @@ partiallyUpdateJob.schema = Joi.object().keys({
232244
resourceType: Joi.stringAllowEmpty().allow(null),
233245
rateType: Joi.rateType().allow(null),
234246
workload: Joi.workload().allow(null),
235-
skills: Joi.array().items(Joi.string().uuid())
247+
skills: Joi.array().items(Joi.string().uuid()),
248+
isApplicationPageActive: Joi.boolean()
236249
}).required()
237250
}).required()
238251

@@ -262,7 +275,8 @@ fullyUpdateJob.schema = Joi.object().keys({
262275
rateType: Joi.rateType().allow(null).default(null),
263276
workload: Joi.workload().allow(null).default(null),
264277
skills: Joi.array().items(Joi.string().uuid()).required(),
265-
status: Joi.jobStatus().default('sourcing')
278+
status: Joi.jobStatus().default('sourcing'),
279+
isApplicationPageActive: Joi.boolean()
266280
}).required()
267281
}).required()
268282

0 commit comments

Comments
 (0)