@@ -154,7 +154,7 @@ function getObjectsArray(model, branch, revId, groupData, convertSharedIDsToStri
154
154
155
155
if ( shared_ids ) {
156
156
157
- const res = await sharedIdsToExternalIds ( account , container , shared_ids . map ( utils . stringToUUID ) ) ;
157
+ const res = await sharedIdsToExternalIds ( account , container , conRevId , shared_ids . map ( utils . stringToUUID ) ) ;
158
158
159
159
if ( res ) {
160
160
return { account, model : container , [ res . key ] : res . value } ;
@@ -184,10 +184,9 @@ function getObjectsArray(model, branch, revId, groupData, convertSharedIDsToStri
184
184
/**
185
185
* Converts all shared IDs to external ids if applicable and return the objects array.
186
186
*/
187
- function getObjectsArrayAsExternalIds ( data ) {
187
+ function getObjectsArrayAsExternalIds ( account , model , branch , rId , data ) {
188
188
return Promise . all ( data . objects . map ( async ( containerEntry ) => {
189
- const { account, model} = containerEntry ;
190
- if ( ! ( account && model ) ) {
189
+ if ( ! ( containerEntry . account && containerEntry . model ) ) {
191
190
return Promise . reject ( responseCodes . INVALID_GROUP ) ;
192
191
}
193
192
@@ -205,9 +204,16 @@ function getObjectsArrayAsExternalIds(data) {
205
204
return data ;
206
205
}
207
206
207
+ const { _id : conRevId } = await getHistory (
208
+ account , containerEntry . model ,
209
+ model === containerEntry . model ? branch : "master" ,
210
+ model === containerEntry . model && ! branch ? rId : undefined ,
211
+ { _id : 1 }
212
+ ) ;
213
+
208
214
const sharedIds = containerEntry . shared_ids . map ( utils . stringToUUID ) ;
209
215
210
- const externalIds = await sharedIdsToExternalIds ( account , model , sharedIds ) ;
216
+ const externalIds = await sharedIdsToExternalIds ( containerEntry . account , containerEntry . model , conRevId , sharedIds ) ;
211
217
212
218
if ( externalIds ) {
213
219
return { account, model, [ externalIds . key ] : externalIds . values } ;
@@ -224,7 +230,7 @@ const Group = {};
224
230
Group . create = async function ( account , model , branch = "master" , rid = null , sessionId , creator = "" , data ) {
225
231
const newGroup = { } ;
226
232
227
- const convertedObjects = await getObjectsArrayAsExternalIds ( data , false ) ;
233
+ const convertedObjects = await getObjectsArrayAsExternalIds ( account , model , branch , rid , data , false ) ;
228
234
229
235
let typeCorrect = ( ! data . objects !== ! data . rules ) ;
230
236
@@ -296,7 +302,7 @@ Group.findByUID = async function (account, model, branch, revId, uid, showIfcGui
296
302
}
297
303
298
304
if ( convertToIfcGuids ) {
299
- foundGroup . objects = await getObjectsArrayAsExternalIds ( foundGroup ) ;
305
+ foundGroup . objects = await getObjectsArrayAsExternalIds ( account , mode , branch , revId , foundGroup ) ;
300
306
} else {
301
307
try {
302
308
foundGroup . objects = await getObjectIds ( account , model , branch , revId , foundGroup , showIfcGuids ) ;
@@ -367,7 +373,7 @@ Group.getList = async function (account, model, branch, revId, ids, queryParams,
367
373
Group . update = async function ( account , model , branch = "master" , revId = null , sessionId , user = "" , groupId , data ) {
368
374
const group = await Group . findByUID ( account , model , branch , revId , groupId ) ;
369
375
370
- const convertedObjects = await getObjectsArrayAsExternalIds ( data , false ) ;
376
+ const convertedObjects = await getObjectsArrayAsExternalIds ( account , model , branch , revId , data , false ) ;
371
377
const toUpdate = { } ;
372
378
const toUnset = { } ;
373
379
0 commit comments