Skip to content

Commit a772b2d

Browse files
committed
Merge branch 'develop' into feature/link-attachments
2 parents b2147b9 + 33bdb8a commit a772b2d

File tree

7 files changed

+655
-36
lines changed

7 files changed

+655
-36
lines changed

src/routes/projectMemberInvites/create.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,11 @@ module.exports = [
366366
})
367367
))
368368
.then((values) => {
369-
const success = _.assign({}, { success: values });
369+
const response = _.assign({}, { success: values });
370370
if (failed.length) {
371-
res.status(403).json(_.assign({}, util.maskInviteEmails('$.success[?(@.email)]', success, req), { failed }));
371+
res.status(403).json(_.assign({}, response, { failed }));
372372
} else {
373-
res.status(201).json(util.maskInviteEmails('$.success[?(@.email)]', success, req));
373+
res.status(201).json(response);
374374
}
375375
})
376376
.catch(err => next(err));

src/routes/projectMemberInvites/create.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ describe('Project Member Invite create', () => {
347347
should.exist(resJson);
348348
resJson.role.should.equal('customer');
349349
resJson.projectId.should.equal(project2.id);
350-
// temporary disable this feature, because it has some side effects
351-
// resJson.email.should.equal('he**o@wo**d.com'); // email is masked
352350
resJson.email.should.equal('hello@world.com');
353351
server.services.pubsub.publish.calledWith('project.member.invite.created').should.be.true;
354352
done();
@@ -401,8 +399,6 @@ describe('Project Member Invite create', () => {
401399
resJson.role.should.equal('customer');
402400
resJson.projectId.should.equal(project2.id);
403401
resJson.userId.should.equal(12345);
404-
// temporary disable this feature, because it has some side effects
405-
// resJson.email.should.equal('he**o@wo**d.com'); // email is masked
406402
resJson.email.should.equal('hello@world.com');
407403
server.services.pubsub.publish.calledWith('project.member.invite.created').should.be.true;
408404
done();

src/routes/projects/get.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,18 @@ const ES_PROJECT_TYPE = config.get('elasticsearchConfig.docType');
2222
// var permissions = require('tc-core-library-js').middleware.permissions
2323
const permissions = tcMiddleware.permissions;
2424
const PROJECT_ATTRIBUTES = _.without(_.keys(models.Project.rawAttributes), 'utm', 'deletedAt');
25-
const PROJECT_MEMBER_ATTRIBUTES = _.without(_.keys(models.ProjectMember.rawAttributes), 'deletedAt');
25+
const PROJECT_MEMBER_ATTRIBUTES = _.concat(_.without(_.keys(models.ProjectMember.rawAttributes), 'deletedAt'),
26+
['firstName', 'lastName', 'handle', 'email']);
2627
const PROJECT_MEMBER_INVITE_ATTRIBUTES = _.without(_.keys(models.ProjectMemberInvite.rawAttributes), 'deletedAt');
2728
const PROJECT_ATTACHMENT_ATTRIBUTES = _.without(_.keys(models.ProjectAttachment.rawAttributes), 'deletedAt');
29+
const PROJECT_PHASE_ATTRIBUTES = _.without(
30+
_.keys(models.ProjectPhase.rawAttributes),
31+
'deletedAt',
32+
);
33+
const PROJECT_PHASE_PRODUCTS_ATTRIBUTES = _.without(
34+
_.keys(models.PhaseProduct.rawAttributes),
35+
'deletedAt',
36+
);
2837

2938
/**
3039
* Parse the ES search criteria and prepare search request body
@@ -52,13 +61,21 @@ const parseElasticSearchCriteria = (projectId, fields) => {
5261
sourceInclude = sourceInclude.concat(_.map(memberFields, single => `invites.${single}`));
5362
}
5463

64+
if (_.get(fields, 'project_phases', null)) {
65+
const phaseFields = _.get(fields, 'project_phases');
66+
sourceInclude = sourceInclude.concat(_.map(phaseFields, single => `phases.${single}`));
67+
}
68+
if (_.get(fields, 'project_phases_products', null)) {
69+
const phaseFields = _.get(fields, 'project_phases_products');
70+
sourceInclude = sourceInclude.concat(_.map(phaseFields, single => `phases.products.${single}`));
71+
}
5572
if (_.get(fields, 'attachments', null)) {
5673
const attachmentFields = _.get(fields, 'attachments');
5774
sourceInclude = sourceInclude.concat(_.map(attachmentFields, single => `attachments.${single}`));
5875
}
5976

6077
if (sourceInclude) {
61-
searchCriteria._sourceInclude = sourceInclude; // eslint-disable-line no-underscore-dangle
78+
searchCriteria._sourceIncludes = sourceInclude; // eslint-disable-line no-underscore-dangle
6279
}
6380

6481

@@ -87,9 +104,14 @@ const retrieveProjectFromES = (projectId, req) => {
87104
projects: PROJECT_ATTRIBUTES,
88105
project_members: PROJECT_MEMBER_ATTRIBUTES,
89106
project_member_invites: PROJECT_MEMBER_INVITE_ATTRIBUTES,
107+
project_phases: PROJECT_PHASE_ATTRIBUTES,
108+
project_phases_products: PROJECT_PHASE_PRODUCTS_ATTRIBUTES,
90109
attachments: PROJECT_ATTACHMENT_ATTRIBUTES,
91110
});
92111

112+
// if user is not admin, ignore email field for project_members
113+
fields = util.ignoreEmailField(req, fields);
114+
93115
const searchCriteria = parseElasticSearchCriteria(projectId, fields) || {};
94116
return new Promise((accept, reject) => {
95117
const es = util.getElasticSearchClient();
@@ -108,6 +130,7 @@ const retrieveProjectFromDB = (projectId, req) => {
108130
projects: PROJECT_ATTRIBUTES,
109131
project_members: PROJECT_MEMBER_ATTRIBUTES,
110132
});
133+
111134
return models.Project
112135
.findOne({
113136
where: { id: projectId },

0 commit comments

Comments
 (0)