[Fix] now correct iota ID loading

This commit is contained in:
Alex Emmet 2026-04-09 20:08:58 +02:00
commit 75b0c05455
2 changed files with 62 additions and 80 deletions

18
Cargo.lock generated
View file

@ -404,7 +404,7 @@ checksum = "c96bf972d85afc50bf5ab8fe2d54d1586b4e0b46c97c50a0c9e71e2f7bcd812a"
dependencies = [
"async-task",
"concurrent-queue",
"fastrand 2.4.0",
"fastrand 2.4.1",
"futures-lite 2.6.1",
"pin-project-lite",
"slab",
@ -1088,9 +1088,9 @@ dependencies = [
[[package]]
name = "fastrand"
version = "2.4.0"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a043dc74da1e37d6afe657061213aa6f425f855399a11d3463c6ecccc4dfda1f"
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
[[package]]
name = "fiat-crypto"
@ -1218,7 +1218,7 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"
dependencies = [
"fastrand 2.4.0",
"fastrand 2.4.1",
"futures-core",
"futures-io",
"parking",
@ -2196,7 +2196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1"
dependencies = [
"atomic-waker",
"fastrand 2.4.0",
"fastrand 2.4.1",
"futures-io",
]
@ -3376,9 +3376,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.51.0"
version = "1.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bd1c4c0fc4a7ab90fc15ef6daaa3ec3b893f004f915f2392557ed23237820cd"
checksum = "f66bf9585cda4b724d3e78ab34b73fb2bbaba9011b9bfdf69dc836382ea13b8c"
dependencies = [
"bytes",
"libc",
@ -3511,7 +3511,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "ttp-core"
version = "0.1.0"
source = "git+https://git.methanium.net/Tensamin/TTP.git#82b71c1be1fa73aeb0f228c4af364206fda8d712"
source = "git+https://git.methanium.net/Tensamin/TTP.git#2322bdced8183e970405d5017cd87ba805309a4c"
dependencies = [
"base64",
"byteorder",
@ -3523,7 +3523,7 @@ dependencies = [
[[package]]
name = "ttp-native"
version = "0.1.0"
source = "git+https://git.methanium.net/Tensamin/TTP.git#82b71c1be1fa73aeb0f228c4af364206fda8d712"
source = "git+https://git.methanium.net/Tensamin/TTP.git#2322bdced8183e970405d5017cd87ba805309a4c"
dependencies = [
"quinn",
"rustls",

View file

@ -433,7 +433,7 @@ impl OmikronConnection {
async fn handle_iota_connected(self: Arc<Self>, cv: CommunicationValue, omikron_id: i64) {
log_in!(PrintType::Omega, "IOTA connected");
if let Some(iota_id) = cv.get_data(DataTypes::iota_id).as_number() {
let iota_id = cv.get_sender();
let iota_id = iota_id as i64;
user_online_tracker::track_iota_connection(iota_id, omikron_id, true);
@ -456,14 +456,11 @@ impl OmikronConnection {
.add_data(DataTypes::user_ids, DataValue::Array(user_ids));
let _ = self.send(&response).await;
} else {
log_in!(PrintType::General, "No IOTA ID found");
}
}
async fn handle_iota_disconnected(self: Arc<Self>, cv: CommunicationValue, omikron_id: i64) {
log_in!(PrintType::Omega, "IOTA disconnected");
if let Some(iota_id) = cv.get_data(DataTypes::iota_id).as_number() {
let iota_id = cv.get_sender();
let iota_id = iota_id as i64;
let iota_offline = user_online_tracker::untrack_iota_connection(iota_id, omikron_id);
if iota_offline {
@ -473,7 +470,6 @@ impl OmikronConnection {
}
}
}
}
async fn handle_sync_status(self: Arc<Self>, cv: CommunicationValue, omikron_id: i64) {
if let DataValue::Array(user_ids) = cv.get_data(DataTypes::user_ids) {
@ -616,7 +612,7 @@ impl OmikronConnection {
async fn handle_get_iota_data(self: Arc<Self>, cv: CommunicationValue) -> OmikronResult<()> {
// Try by iota_id
if let Some(iota_id) = cv.get_data(DataTypes::iota_id).as_number() {
let iota_id = cv.get_sender();
if let Ok((iota_id, public_key)) = get_iota_by_id(iota_id as i64).await {
let response = self
.clone()
@ -624,7 +620,6 @@ impl OmikronConnection {
.await;
return self.send(&response).await;
}
}
// Try by user_id
if let Some(user_id) = cv.get_data(DataTypes::user_id).as_number() {
@ -780,19 +775,16 @@ impl OmikronConnection {
.get_data(DataTypes::public_key)
.as_str()
.map(|s| s.to_string());
let iota_id = cv
.get_data(DataTypes::iota_id)
.as_number()
.map(|n| n as i64);
let iota_id = cv.get_sender();
let reset_token = cv
.get_data(DataTypes::reset_token)
.as_str()
.map(|s| s.to_string());
if let (Some(uid), Some(uname), Some(pk), Some(iid), Some(rt)) =
(user_id, username, public_key, iota_id, reset_token)
if let (Some(uid), Some(uname), Some(pk), Some(rt)) =
(user_id, username, public_key, reset_token)
{
match sql::register_complete_user(uid, uname, pk, iid, rt).await {
match sql::register_complete_user(uid, uname, pk, iota_id as i64, rt).await {
Ok(_) => {
let response =
CommunicationValue::new(CommunicationType::success).with_id(cv.get_id());
@ -877,10 +869,8 @@ impl OmikronConnection {
async fn handle_change_iota_data(self: Arc<Self>, cv: CommunicationValue) -> OmikronResult<()> {
let user_id = cv.get_sender() as i64;
if let (Some(iota_id), Some(reset_token), Some(new_token)) = (
cv.get_data(DataTypes::iota_id)
.as_number()
.map(|n| n as i64),
if let (iota_id, Some(reset_token), Some(new_token)) = (
cv.get_sender(),
cv.get_data(DataTypes::reset_token).as_str(),
cv.get_data(DataTypes::new_token).as_str(),
) {
@ -891,7 +881,7 @@ impl OmikronConnection {
let mut success = true;
let mut error_message = String::new();
if let Err(e) = sql::change_iota_id(user_id, iota_id).await {
if let Err(e) = sql::change_iota_id(user_id, iota_id as i64).await {
success = false;
error_message = e.to_string();
}
@ -950,12 +940,8 @@ impl OmikronConnection {
}
async fn handle_delete_iota(self: Arc<Self>, cv: CommunicationValue) -> OmikronResult<()> {
if let Some(iota_id) = cv
.get_data(DataTypes::iota_id)
.as_number()
.map(|n| n as i64)
{
match sql::delete_iota(iota_id).await {
let iota_id = cv.get_sender();
match sql::delete_iota(iota_id as i64).await {
Ok(_) => {
let response =
CommunicationValue::new(CommunicationType::success).with_id(cv.get_id());
@ -968,10 +954,6 @@ impl OmikronConnection {
self.send(&response).await
}
}
} else {
self.send_error_response(cv.get_id(), CommunicationType::error_invalid_data)
.await
}
}
async fn handle_get_notifications(