Skip to content

Commit 3d280e7

Browse files
committed
fix: errors in /taas-teams endpoints
caused by permission updates for other endpoints via issue #70
1 parent 7dac65a commit 3d280e7

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/services/TeamService.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,24 @@ const ResourceBookingService = require('./ResourceBookingService')
1313

1414
/**
1515
* Function to get assigned resource bookings with specific projectIds
16+
* @param {Object} currentUser the user who perform this operation.
1617
* @param {Array} projectIds project ids
1718
* @returns the request result
1819
*/
19-
async function _getAssignedResourceBookingsByProjectIds (projectIds) {
20+
async function _getAssignedResourceBookingsByProjectIds (currentUser, projectIds) {
2021
const criteria = { status: 'assigned', projectIds }
21-
const { result } = await ResourceBookingService.searchResourceBookings(criteria, { returnAll: true })
22+
const { result } = await ResourceBookingService.searchResourceBookings(currentUser, criteria, { returnAll: true })
2223
return result
2324
}
2425

2526
/**
2627
* Function to get jobs by projectIds
28+
* @param {Object} currentUser the user who perform this operation.
2729
* @param {Array} projectIds project ids
2830
* @returns the request result
2931
*/
30-
async function _getJobsByProjectIds (projectIds) {
31-
const { result } = await JobService.searchJobs({ projectIds }, { returnAll: true })
32+
async function _getJobsByProjectIds (currentUser, projectIds) {
33+
const { result } = await JobService.searchJobs(currentUser, { projectIds }, { returnAll: true })
3234
return result
3335
}
3436

@@ -54,7 +56,7 @@ async function searchTeams (currentUser, criteria) {
5456
total,
5557
page,
5658
perPage,
57-
result: await getTeamDetail(projects)
59+
result: await getTeamDetail(currentUser, projects)
5860
}
5961
}
6062

@@ -75,16 +77,17 @@ searchTeams.schema = Joi.object().keys({
7577

7678
/**
7779
* Get team details
80+
* @param {Object} currentUser the user who perform this operation
7881
* @param {Object} projects the projects
7982
* @param {Object} isSearch the flag whether for search function
8083
* @returns {Object} the search result
8184
*/
82-
async function getTeamDetail (projects, isSearch = true) {
85+
async function getTeamDetail (currentUser, projects, isSearch = true) {
8386
const projectIds = _.map(projects, 'id')
8487
// Get all assigned resourceBookings filtered by projectIds
85-
const resourceBookings = await _getAssignedResourceBookingsByProjectIds(projectIds)
88+
const resourceBookings = await _getAssignedResourceBookingsByProjectIds(currentUser, projectIds)
8689
// Get all jobs filtered by projectIds
87-
const jobs = await _getJobsByProjectIds(projectIds)
90+
const jobs = await _getJobsByProjectIds(currentUser, projectIds)
8891

8992
// Get first week day and last week day
9093
const curr = new Date()
@@ -197,7 +200,7 @@ async function getTeamDetail (projects, isSearch = true) {
197200
*/
198201
async function getTeam (currentUser, id) {
199202
const project = await helper.getProjectById(currentUser, id)
200-
const result = await getTeamDetail([project], false)
203+
const result = await getTeamDetail(currentUser, [project], false)
201204
const teamDetail = result[0]
202205

203206
// add job skills for result
@@ -246,7 +249,7 @@ getTeam.schema = Joi.object().keys({
246249
*/
247250
async function getTeamJob (currentUser, id, jobId) {
248251
const project = await helper.getProjectById(currentUser, id)
249-
const jobs = await _getJobsByProjectIds([project.id])
252+
const jobs = await _getJobsByProjectIds(currentUser, [project.id])
250253
const job = _.find(jobs, { id: jobId })
251254

252255
if (!job) {

0 commit comments

Comments
 (0)