Save devices without user binding
This commit is contained in:
parent
cc411fb88e
commit
fe8a3e2217
|
@ -95,11 +95,37 @@ async function updateDB(onlineDevices) {
|
|||
}
|
||||
})
|
||||
} catch (e) {
|
||||
logError({
|
||||
tags: ['wifiDevices'],
|
||||
message: `Error trying to upsert device with mac "${device.mac}"`,
|
||||
data: { error: e, device }
|
||||
})
|
||||
// If is a binding problem, probably the device has an user outside of AD, so save it anyway...
|
||||
if (e.code == 'P2016')
|
||||
try {
|
||||
await forceUserDisconnect(device.mac)
|
||||
await prisma.wifiDevice.upsert({
|
||||
where: { mac: device.mac },
|
||||
create: {
|
||||
...device,
|
||||
hostname,
|
||||
firstSeen: device.firstSeen || new Date(),
|
||||
user: undefined
|
||||
},
|
||||
update: {
|
||||
...device,
|
||||
hostname,
|
||||
user: undefined
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
logError({
|
||||
tags: ['wifiDevices'],
|
||||
message: `Error trying to upsert device with mac "${device.mac}". It has an user, but not in AD. And fails anyway...`,
|
||||
data: { error: e, device }
|
||||
})
|
||||
}
|
||||
else
|
||||
logError({
|
||||
tags: ['wifiDevices'],
|
||||
message: `Error trying to upsert device with mac "${device.mac}"`,
|
||||
data: { error: e, device }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user