Skip to content

Commit 7249e1b

Browse files
authored
Merge branch 'newarchitecture' into SER-2737
2 parents 881162a + afe24a4 commit 7249e1b

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

api/utils/rights.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,15 +1155,25 @@ exports.hasAdminAccess = function(member, app_id, type) {
11551155
return true;
11561156
}
11571157

1158-
var isAdmin = true;
1158+
var isAdmin = false;
11591159
// check users who has permission property
11601160
if (hasPermissionObject) {
11611161
var types = type ? [type] : ["c", "r", "u", "d"];
1162+
var passesAllRules = true;
11621163
for (var i = 0; i < types.length; i++) {
1163-
if (member.permission[types[i]] && member.permission[types[i]][app_id] && !member.permission[types[i]][app_id].all) {
1164-
isAdmin = false;
1164+
if (member.permission[types[i]] && member.permission[types[i]][app_id]) {
1165+
if (!member.permission[types[i]][app_id].all) {
1166+
passesAllRules = false;
1167+
}
1168+
}
1169+
else {
1170+
passesAllRules = false;
11651171
}
11661172
}
1173+
if (passesAllRules) {
1174+
isAdmin = true;
1175+
}
1176+
11671177
}
11681178
// check legacy users who has admin_of property
11691179
// users should have at least one app in admin_of array

plugins/crashes/api/aggregator.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,16 @@ const setFieldsIfExist = function(fieldList, source, target) {
194194
{
195195
// Project needed properties from user properties (up) so they are available in document root.
196196
$project: {
197-
_id: '$fullDocument._id',
197+
__id: '$fullDocument._id',
198198
a: '$fullDocument.a',
199199
cd: '$fullDocument.cd',
200200
e: '$fullDocument.e',
201201
n: '$fullDocument.n',
202202
sg: '$fullDocument.sg',
203203
ts: '$fullDocument.ts',
204+
uid: '$fullDocument.uid',
205+
up: '$fullDocument.up',
206+
up_extra: '$fullDocument.up_extra',
204207
},
205208
},
206209
],
@@ -326,7 +329,7 @@ const setFieldsIfExist = function(fieldList, source, target) {
326329
groupInsert.startTs = moment(currEvent.ts).unix();
327330
groupInsert.latest_version = currEvent.sg.app_version;
328331
groupInsert.latest_version_for_sort = common.transformAppVersion(currEvent.sg.app_version);
329-
groupInsert.lrid = `${currEvent._id}`;
332+
groupInsert.lrid = `${currEvent.__id || currEvent._id}`;
330333
groupInsert.error = currEvent.sg.error || '';
331334

332335
setFieldsIfExist(buildSpecific, currEvent.sg, groupInsert);
@@ -466,15 +469,15 @@ const setFieldsIfExist = function(fieldList, source, target) {
466469
if (plugins.getConfig('crashes').same_app_version_crash_update) {
467470
if (crashGroup.latest_version && common.versionCompare(currEvent.sg.app_version.replace(/\./g, ':'), crashGroup.latest_version.replace(/\./g, ':')) >= 0) {
468471
group.error = currEvent.sg.error;
469-
group.lrid = `${currEvent._id}`;
472+
group.lrid = `${currEvent.__id || currEvent._id}`;
470473

471474
setFieldsIfExist(buildSpecific, currEvent.sg, group);
472475
}
473476
}
474477
else {
475478
if (crashGroup.latest_version && common.versionCompare(currEvent.sg.app_version.replace(/\./g, ':'), crashGroup.latest_version.replace(/\./g, ':')) > 0) {
476479
group.error = currEvent.sg.error;
477-
group.lrid = `${currEvent._id}`;
480+
group.lrid = `${currEvent.__id || currEvent._id}`;
478481

479482
setFieldsIfExist(buildSpecific, currEvent.sg, group);
480483
}
@@ -536,15 +539,16 @@ const setFieldsIfExist = function(fieldList, source, target) {
536539
{
537540
// Project needed properties from user properties (up) so they are available in document root.
538541
$project: {
539-
_id: '$fullDocument._id',
542+
__id: '$fullDocument._id',
540543
a: '$fullDocument.a',
541544
cd: '$fullDocument.cd',
542545
e: '$fullDocument.e',
543546
n: '$fullDocument.n',
547+
sg: '$fullDocument.sg',
544548
ts: '$fullDocument.ts',
545-
up_extra: '$fullDocument.up_extra',
549+
uid: '$fullDocument.uid',
546550
up: '$fullDocument.up',
547-
sg: '$fullDocument.sg'
551+
up_extra: '$fullDocument.up_extra',
548552
},
549553
},
550554
],
@@ -635,14 +639,16 @@ const setFieldsIfExist = function(fieldList, source, target) {
635639
{
636640
// Project needed properties from user properties (up) so they are available in document root.
637641
$project: {
638-
_id: '$fullDocument._id',
639-
_uid: '$fullDocument._uid',
642+
__id: '$fullDocument._id',
640643
a: '$fullDocument.a',
641644
cd: '$fullDocument.cd',
642645
e: '$fullDocument.e',
643646
n: '$fullDocument.n',
644647
sg: '$fullDocument.sg',
645648
ts: '$fullDocument.ts',
649+
uid: '$fullDocument.uid',
650+
up: '$fullDocument.up',
651+
up_extra: '$fullDocument.up_extra',
646652
},
647653
},
648654
],

plugins/views/api/api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ const FEATURE_NAME = 'views';
5353
const bulk = common.db.collection("app_viewsmeta").initializeUnorderedBulkOp();
5454
for (var k = 0; k < data.length; k++) {
5555
if (data[k].value !== "") {
56-
bulk.find({_id: common.db.ObjectID(data[k].key)}).updateOne({$set: {"display": data[k].value}});
56+
bulk.find({_id: common.db.ObjectID(data[k].key), a: (appId + "")}).updateOne({$set: {"display": data[k].value}});
5757
}
5858
else {
59-
bulk.find({_id: common.db.ObjectID(data[k].key)}).updateOne({$unset: {"display": true}});
59+
bulk.find({_id: common.db.ObjectID(data[k].key), a: (appId + "")}).updateOne({$unset: {"display": true}});
6060
}
6161
haveUpdate = true;
6262
}
@@ -101,7 +101,7 @@ const FEATURE_NAME = 'views';
101101
log.e(err1);
102102
}
103103
if (viewInfo) {
104-
common.db.collection("app_viewsmeta").findOne({'_id': viewid}, {}, function(err, viewrecord) {
104+
common.db.collection("app_viewsmeta").findOne({'_id': viewid, "a": (appId + "")}, {}, function(err, viewrecord) {
105105
if (viewrecord && viewrecord.view) {
106106
viewName = viewrecord.view;
107107
viewUrl = viewrecord.view;

plugins/views/tests/views.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ describe('Testing views plugin', function() {
357357
tableResponse.yesterday.iTotalDisplayRecords += 1;
358358
pushValues("yesterday", 0, { "u": 1, "t": 1, "s": 1, "view": "testview0"});
359359
if (days_this_month < 2) {
360-
pushValues("30days", 0, {"t": 1, "s": 1});
360+
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1});
361361
}
362362
else {
363363
pushValues("30days", 0, {"t": 1, "s": 1});
@@ -370,7 +370,12 @@ describe('Testing views plugin', function() {
370370
if (days_this_year > 1) {
371371
tableResponse.month.iTotalRecords = 1;
372372
tableResponse.month.iTotalDisplayRecords = 1;
373-
pushValues("month", 0, {"t": 1, "s": 1});
373+
if (days_this_month < 25) {
374+
pushValues("month", 0, {"u": 1, "t": 1, "s": 1});
375+
}
376+
else {
377+
pushValues("month", 0, {"t": 1, "s": 1});
378+
}
374379
//tableResponse["month"]['aaData'][0]['n']=1;
375380
}
376381

0 commit comments

Comments
 (0)