File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,20 @@ export class PayloadService extends BaseService {
174174 ) ,
175175 ) ;
176176
177+ // Due to the existence of a "devices" collection in the tenant index and a platform index,
178+ // we need to fetch the device content from the associated tenant if it exists.
179+ const updatedDevices = await Promise . all (
180+ devices . map ( ( device ) =>
181+ device . _source . engineId && device . _source . engineId . trim ( ) !== ""
182+ ? this . sdk . document . get < DeviceContent > (
183+ device . _source . engineId ,
184+ InternalCollection . DEVICES ,
185+ device . _id ,
186+ )
187+ : device ,
188+ ) ,
189+ ) ;
190+
177191 // If we have unknown devices, let's check if we should register them
178192 if ( errors . length > 0 ) {
179193 const { _source } = await this . sdk . document . get (
@@ -186,7 +200,7 @@ export class PayloadService extends BaseService {
186200 const newDevices = await this . provisionDevices ( deviceModel , errors , {
187201 refresh,
188202 } ) ;
189- devices . push ( ...newDevices ) ;
203+ updatedDevices . push ( ...newDevices ) ;
190204 } else {
191205 this . app . log . info (
192206 `Skipping new devices "${ errors . join (
@@ -196,7 +210,7 @@ export class PayloadService extends BaseService {
196210 }
197211 }
198212
199- return devices ;
213+ return updatedDevices ;
200214 }
201215
202216 private async provisionDevices (
You can’t perform that action at this time.
0 commit comments