Compare commits
4 changed files with 12 additions and 36 deletions
|
|
@ -1,17 +0,0 @@
|
||||||
use actix_web::{HttpResponse, Responder};
|
|
||||||
|
|
||||||
pub async fn index_handler() -> impl Responder {
|
|
||||||
let documentation = r#"
|
|
||||||
Omega API Server
|
|
||||||
|
|
||||||
Available Routes:
|
|
||||||
- /api/* : API endpoints for the Omega server.
|
|
||||||
- /direct/* : Resolution for shortened links.
|
|
||||||
|
|
||||||
All other routes will return this documentation.
|
|
||||||
"#;
|
|
||||||
|
|
||||||
HttpResponse::Ok()
|
|
||||||
.content_type("text/plain; charset=utf-8")
|
|
||||||
.body(documentation)
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
pub mod api;
|
pub mod api;
|
||||||
pub mod index;
|
|
||||||
pub mod server;
|
pub mod server;
|
||||||
pub mod short_link;
|
pub mod short_link;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
log,
|
log,
|
||||||
server::{api, index::index_handler, short_link::get_short_link},
|
server::{api, short_link::get_short_link},
|
||||||
util::file_util::load_file_buf,
|
util::file_util::load_file_buf,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,7 +37,6 @@ pub async fn start(port: u16) -> anyhow::Result<()> {
|
||||||
App::new()
|
App::new()
|
||||||
.route("/api/{path:.*}", web::to(api_handler))
|
.route("/api/{path:.*}", web::to(api_handler))
|
||||||
.route("/direct/{path:.*}", web::to(direct_handler))
|
.route("/direct/{path:.*}", web::to(direct_handler))
|
||||||
.default_service(web::to(index_handler))
|
|
||||||
})
|
})
|
||||||
.bind_rustls_0_23(addr, config)?
|
.bind_rustls_0_23(addr, config)?
|
||||||
.run()
|
.run()
|
||||||
|
|
|
||||||
|
|
@ -433,10 +433,8 @@ impl OmikronConnection {
|
||||||
|
|
||||||
async fn handle_iota_connected(self: Arc<Self>, cv: CommunicationValue, omikron_id: i64) {
|
async fn handle_iota_connected(self: Arc<Self>, cv: CommunicationValue, omikron_id: i64) {
|
||||||
log_in!(PrintType::Omega, "IOTA connected");
|
log_in!(PrintType::Omega, "IOTA connected");
|
||||||
let iota_id = match cv.get_data(DataTypes::iota_id).as_number() {
|
let iota_id = cv.get_sender();
|
||||||
Some(id) => id as i64,
|
let iota_id = iota_id as i64;
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
user_online_tracker::track_iota_connection(iota_id, omikron_id, true);
|
user_online_tracker::track_iota_connection(iota_id, omikron_id, true);
|
||||||
|
|
||||||
let mut user_ids = Vec::new();
|
let mut user_ids = Vec::new();
|
||||||
|
|
@ -462,10 +460,8 @@ impl OmikronConnection {
|
||||||
|
|
||||||
async fn handle_iota_disconnected(self: Arc<Self>, cv: CommunicationValue, omikron_id: i64) {
|
async fn handle_iota_disconnected(self: Arc<Self>, cv: CommunicationValue, omikron_id: i64) {
|
||||||
log_in!(PrintType::Omega, "IOTA disconnected");
|
log_in!(PrintType::Omega, "IOTA disconnected");
|
||||||
let iota_id = match cv.get_data(DataTypes::iota_id).as_number() {
|
let iota_id = cv.get_sender();
|
||||||
Some(id) => id as i64,
|
let iota_id = iota_id as i64;
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
let iota_offline = user_online_tracker::untrack_iota_connection(iota_id, omikron_id);
|
let iota_offline = user_online_tracker::untrack_iota_connection(iota_id, omikron_id);
|
||||||
if iota_offline {
|
if iota_offline {
|
||||||
if let Ok(users) = sql::get_users_by_iota_id(iota_id).await {
|
if let Ok(users) = sql::get_users_by_iota_id(iota_id).await {
|
||||||
|
|
@ -616,14 +612,13 @@ impl OmikronConnection {
|
||||||
|
|
||||||
async fn handle_get_iota_data(self: Arc<Self>, cv: CommunicationValue) -> OmikronResult<()> {
|
async fn handle_get_iota_data(self: Arc<Self>, cv: CommunicationValue) -> OmikronResult<()> {
|
||||||
// Try by iota_id
|
// 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 {
|
if let Ok((iota_id, public_key)) = get_iota_by_id(iota_id as i64).await {
|
||||||
let response = self
|
let response = self
|
||||||
.clone()
|
.clone()
|
||||||
.build_iota_data_response(cv.get_id(), iota_id, public_key, None, None)
|
.build_iota_data_response(cv.get_id(), iota_id, public_key, None, None)
|
||||||
.await;
|
.await;
|
||||||
return self.send(&response).await;
|
return self.send(&response).await;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try by user_id
|
// Try by user_id
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue