File tree 2 files changed +31
-1
lines changed 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -554,6 +554,28 @@ function * postToBusApi (payload) {
554
554
yield busApiClient . postEvent ( payload )
555
555
}
556
556
557
+ /**
558
+ * Function to remove metadata details from reviews for members who shouldn't see them
559
+ * @param {Array } reviews
560
+ * @param {Array } roles
561
+ */
562
+ function cleanseReviews ( reviews , roles ) {
563
+ const cleansedReviews = [ ]
564
+
565
+ _ . forEach ( reviews , ( review ) => {
566
+ const admin = _ . filter ( roles , role => role === 'Administrator' )
567
+ const copilot = _ . filter ( roles , role => role === 'Copilot' )
568
+
569
+ // User is neither admin nor copilot
570
+ if ( admin . length === 0 && copilot . length === 0 ) {
571
+ _ . unset ( review , 'metadata' )
572
+ }
573
+
574
+ cleansedReviews . push ( review )
575
+ } )
576
+ return cleansedReviews
577
+ }
578
+
557
579
module . exports = {
558
580
wrapExpress,
559
581
autoWrapExpress,
@@ -566,5 +588,6 @@ module.exports = {
566
588
checkGetAccess,
567
589
checkReviewGetAccess,
568
590
downloadFile,
569
- postToBusApi
591
+ postToBusApi,
592
+ cleanseReviews
570
593
}
Original file line number Diff line number Diff line change 2
2
* Submission Controller
3
3
*/
4
4
5
+ const _ = require ( 'lodash' )
5
6
const SubmissionService = require ( '../services/SubmissionService' )
6
7
const helper = require ( '../common/helper' )
7
8
@@ -38,6 +39,12 @@ function * downloadSubmission (req, res) {
38
39
*/
39
40
function * listSubmissions ( req , res ) {
40
41
const data = yield SubmissionService . listSubmissions ( req . query )
42
+ data . rows = _ . map ( data . rows , ( submission ) => {
43
+ if ( submission . review ) {
44
+ submission . review = helper . cleanseReviews ( submission . review , req . authUser . roles )
45
+ }
46
+ return submission
47
+ } )
41
48
helper . setPaginationHeaders ( req , res , data )
42
49
}
43
50
You can’t perform that action at this time.
0 commit comments