// Check the status flag value, accepted values are: trusted (unsafe and untrusted are already managed)
if(status!=lime::PeerDeviceStatus::trusted){
LIME_LOGE<<"Trying to set a status for peer device "<<peerDeviceId<<" which is not acceptable (differs from unsafe, untrusted or trusted), ignore that";
// Check the status flag value, accepted values are: untrusted, unsafe
if(status!=lime::PeerDeviceStatus::unsafe
&&status!=lime::PeerDeviceStatus::untrusted){
throwBCTBX_EXCEPTION<<"Trying to set a status for peer device "<<peerDeviceId<<" without providing a Ik which is not acceptable (differs from unsafe or untrusted)";
LIME_LOGE<<"Trying to set a status for peer device "<<peerDeviceId<<" without providing a Ik which is not acceptable (differs from unsafe or untrusted)";
LIME_LOGW<<"Trying to set a status untrusted for peer device "<<peerDeviceId<<" but its current status is unsafe, ignore that call)";
return;
}
}
// update or insert
if(inLocalStorage){
sql<<"UPDATE Lime_PeerDevices SET Status = :Status WHERE Did = :id;",use(statusInteger),use(id);
}else{
// this constant is set into lime_peerDevices table, Ik field when it is not provided by set_peerDeviceStatus as this field can't be set to NULL in older version of the database
// same than above but using the actual key : try to set it to trusted, still using the fake Ik, it shall generate an exception as the Ik is invalid in storage
// Bob encrypts a message for Alice, alice device status shall be : untrusted(it is the first message bob sends but he already knows about alice's device)
// Bob encrypts a message for Alice, alice device status shall be : unknown(it is the first message bob sends and alice is not in cache)
// delete alice's key from Bob context, it will delete all session associated to Alice so when we encrypt a new message, it will fetch a new OPk as the previous one was deleted by alice
// alice tries again to decrypt but it will fail as the identity key in X3DH init packet is not matching the invalid one set in base by setting its status to unsafe
// delete alice's key from Bob context, it will delete all session associated to Alice so when we encrypt a new message, it will fetch a new OPk as the previous one was deleted by alice