Fix read-only plugin target matching
This commit is contained in:
@@ -68,7 +68,7 @@ export async function inventory(config: PluginConfig): Promise<{ groups: unknown
|
||||
const meshesResponse = await request('meshes');
|
||||
const meshes = (meshesResponse.meshes ?? []).map((mesh) => ({
|
||||
id: mesh.id ?? mesh._id ?? '', name: mesh.name, description: mesh.description ?? mesh.desc,
|
||||
})).filter((mesh) => mesh.id && mesh.name === config.groupName);
|
||||
})).filter((mesh) => mesh.id && mesh.name.toLowerCase() === config.groupName.toLowerCase());
|
||||
if (meshes.length !== 1) throw new Error('Approved MeshCentral group was not found uniquely');
|
||||
|
||||
const group = meshes[0];
|
||||
@@ -77,7 +77,10 @@ export async function inventory(config: PluginConfig): Promise<{ groups: unknown
|
||||
id: node.id ?? node._id ?? '', name: node.name, groupId: node.meshid ?? groupId,
|
||||
online: node.online ?? node.conn === 1, os: node.device?.os ?? node.osdesc,
|
||||
ipAddresses: node.device?.ip ?? node.ip,
|
||||
}))).filter((node) => node.id && node.groupId === group.id && node.name === config.deviceName);
|
||||
// The nodes request is already scoped to the approved group. MeshCentral
|
||||
// may omit or normalize the per-node meshid differently, so do not apply
|
||||
// a second brittle group-id comparison here.
|
||||
}))).filter((node) => node.id && node.name.toLowerCase() === config.deviceName.toLowerCase());
|
||||
return { groups: meshes, devices };
|
||||
} finally {
|
||||
await new Promise<void>((resolve) => {
|
||||
|
||||
Reference in New Issue
Block a user