Link shorting (no #)

This commit is contained in:
Alex-Emmet 2026-01-20 20:25:34 +01:00
commit 30caec0921
3 changed files with 31 additions and 21 deletions

View file

@ -68,7 +68,7 @@ impl OmikronConnection {
message_text
);
}
sender.send(message_text).await.unwrap();
let _ = sender.send(message_text).await;
}
pub async fn get_omikron_id(&self) -> i64 {
*self.omikron_id.read().await
@ -208,6 +208,20 @@ impl OmikronConnection {
}
let omikron_id = self.get_omikron_id().await;
if cv.is_type(CommunicationType::shorten_link) {
if let Some(link) = cv.get_data(DataTypes::link) {
if let Some(link) = link.as_str() {
if let Ok(short_link) = add_short_link(link).await {
let response = CommunicationValue::new(CommunicationType::shorten_link)
.with_id(cv.get_id())
.add_data(DataTypes::link, JsonValue::String(short_link));
self.send_message(&response).await;
return;
}
}
}
}
// ONLINE STATUS TRACKING
if cv.is_type(CommunicationType::user_connected) {
if let Some(user_id) = cv.get_data(DataTypes::user_id).and_then(|v| v.as_i64()) {
@ -474,20 +488,6 @@ impl OmikronConnection {
}
}
if cv.is_type(CommunicationType::shorten_link) {
if let Some(link) = cv.get_data(DataTypes::link) {
if let Some(link) = link.as_str() {
if let Ok(short_link) = add_short_link(link).await {
let response = CommunicationValue::new(CommunicationType::shorten_link)
.with_id(cv.get_id())
.add_data(DataTypes::link, JsonValue::String(short_link));
self.send_message(&response).await;
return;
}
}
}
}
let response =
CommunicationValue::new(CommunicationType::error_not_found).with_id(cv.get_id());
self.send_message(&response).await;