License & tensamin.net
This commit is contained in:
parent
1c08956387
commit
af1088e9fb
6 changed files with 90 additions and 43 deletions
16
LICENSE
Normal file
16
LICENSE
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
Copyright (c) [2025] [Methanium]
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
This software is protected by copyright. Copying, editing,
|
||||||
|
distributing, publicly performing, or any other use of this software
|
||||||
|
or its components, in source or binary form, is strictly prohibited without the express
|
||||||
|
written permission of the copyright holder.
|
||||||
|
|
||||||
|
FUTURE LICENSE ACCEPTANCE:
|
||||||
|
It is the copyright holder's intention to release this software in the future
|
||||||
|
under a license yet to be defined, which will, among other things,
|
||||||
|
allow private, non-commercial use. This statement does not constitute
|
||||||
|
a current license grant and does not alter the above
|
||||||
|
prohibition on use, copying, or modification. Until the formal
|
||||||
|
publication of such a future license, all rights remain
|
||||||
|
reserved.
|
||||||
|
|
@ -28,7 +28,7 @@ fn client() -> Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unregister_user(user_id: Uuid, reset_token: &str) -> Option<bool> {
|
pub async fn unregister_user(user_id: Uuid, reset_token: &str) -> Option<bool> {
|
||||||
let url = format!("https:/auth.tensamin.methanium.net/api/delete/{}", user_id);
|
let url = format!("https:/auth.tensamin.net/api/delete/{}", user_id);
|
||||||
let client = client();
|
let client = client();
|
||||||
|
|
||||||
let mut payload = JsonValue::new_object();
|
let mut payload = JsonValue::new_object();
|
||||||
|
|
@ -47,10 +47,7 @@ pub async fn unregister_user(user_id: Uuid, reset_token: &str) -> Option<bool> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_uuid(username: &str) -> Option<Uuid> {
|
pub async fn get_uuid(username: &str) -> Option<Uuid> {
|
||||||
let url = format!(
|
let url = format!("https://auth.tensamin.net/api/get/uuid/{}", username);
|
||||||
"https://auth.tensamin.methanium.net/api/get/uuid/{}",
|
|
||||||
username
|
|
||||||
);
|
|
||||||
let client = client();
|
let client = client();
|
||||||
let res = client.get(&url).send().await.ok()?;
|
let res = client.get(&url).send().await.ok()?;
|
||||||
let json = res.text().await.ok()?;
|
let json = res.text().await.ok()?;
|
||||||
|
|
@ -62,7 +59,7 @@ pub async fn get_uuid(username: &str) -> Option<Uuid> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user(user_id: Uuid) -> Option<AuthUser> {
|
pub async fn get_user(user_id: Uuid) -> Option<AuthUser> {
|
||||||
let url = format!("https://auth.tensamin.methanium.net/api/get/{}", user_id);
|
let url = format!("https://auth.tensamin.net/api/get/{}", user_id);
|
||||||
let client = client();
|
let client = client();
|
||||||
let res = client.get(&url).send().await.ok()?;
|
let res = client.get(&url).send().await.ok()?;
|
||||||
let json = res.text().await.ok()?;
|
let json = res.text().await.ok()?;
|
||||||
|
|
@ -101,7 +98,7 @@ pub async fn get_user(user_id: Uuid) -> Option<AuthUser> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_register() -> Option<Uuid> {
|
pub async fn get_register() -> Option<Uuid> {
|
||||||
let url = "https://auth.tensamin.methanium.net/api/register/init".to_string();
|
let url = "https://auth.tensamin.net/api/register/init".to_string();
|
||||||
let client = client();
|
let client = client();
|
||||||
let res = client.get(&url).send().await.ok()?;
|
let res = client.get(&url).send().await.ok()?;
|
||||||
let json = res.text().await.ok()?;
|
let json = res.text().await.ok()?;
|
||||||
|
|
@ -111,7 +108,7 @@ pub async fn get_register() -> Option<Uuid> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn complete_register(user_profile: &UserProfile, iota_id: &str) -> bool {
|
pub async fn complete_register(user_profile: &UserProfile, iota_id: &str) -> bool {
|
||||||
let url = "https://auth.tensamin.methanium.net/api/register/complete";
|
let url = "https://auth.tensamin.net/api/register/complete";
|
||||||
let client = client();
|
let client = client();
|
||||||
|
|
||||||
let mut payload = JsonValue::new_object();
|
let mut payload = JsonValue::new_object();
|
||||||
|
|
@ -139,7 +136,7 @@ pub async fn complete_register(user_profile: &UserProfile, iota_id: &str) -> boo
|
||||||
|
|
||||||
pub async fn migrate_user(user_profile: &mut UserProfile) -> bool {
|
pub async fn migrate_user(user_profile: &mut UserProfile) -> bool {
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://auth.tensamin.methanium.net/api/change/iota-id/{}",
|
"https://auth.tensamin.net/api/change/iota-id/{}",
|
||||||
user_profile.user_id
|
user_profile.user_id
|
||||||
);
|
);
|
||||||
let client = client();
|
let client = client();
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ use crate::{
|
||||||
};
|
};
|
||||||
use axum::Json;
|
use axum::Json;
|
||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use std::any::Any;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{any::Any, pin::Pin};
|
||||||
|
|
||||||
pub type InteractableFactory = fn() -> Box<dyn Interactable>;
|
pub type InteractableFactory = fn() -> Box<dyn Interactable>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
communities::{community::Community, interactables::interactable::Interactable},
|
communities::{
|
||||||
|
community::Community, community_connection::CommunityConnection,
|
||||||
|
interactables::interactable::Interactable,
|
||||||
|
},
|
||||||
data::communication::{CommunicationType, CommunicationValue, DataTypes},
|
data::communication::{CommunicationType, CommunicationValue, DataTypes},
|
||||||
gui::log_panel::log_message,
|
gui::log_panel::log_message,
|
||||||
util::file_util::{get_children, load_file, save_file},
|
util::file_util::{get_children, load_file, save_file},
|
||||||
|
|
@ -7,9 +10,13 @@ use crate::{
|
||||||
use aes_gcm::aead::Payload;
|
use aes_gcm::aead::Payload;
|
||||||
use axum::Json;
|
use axum::Json;
|
||||||
use json::{JsonValue, array, object};
|
use json::{JsonValue, array, object};
|
||||||
use std::any::Any;
|
use rustls::ClientConnection;
|
||||||
use std::fs::{self, File};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{any::Any, collections::HashMap};
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
pin::Pin,
|
||||||
|
};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
pub struct TextChat {
|
pub struct TextChat {
|
||||||
name: String,
|
name: String,
|
||||||
|
|
@ -183,35 +190,61 @@ impl Interactable for TextChat {
|
||||||
JsonValue::new_object()
|
JsonValue::new_object()
|
||||||
}
|
}
|
||||||
fn run_function(&self, cv: CommunicationValue) -> CommunicationValue {
|
fn run_function(&self, cv: CommunicationValue) -> CommunicationValue {
|
||||||
let payload = cv.get_data(DataTypes::payload).unwrap();
|
let ret: Pin<Box<dyn Future<Output = CommunicationValue> + Send>> = Box::pin(async move {
|
||||||
if cv.get_data(DataTypes::function).unwrap().as_str().unwrap() == "get_messages" {
|
let payload = cv.get_data(DataTypes::payload).unwrap();
|
||||||
let amount = payload["amount"].as_i64().unwrap();
|
if cv.get_data(DataTypes::function).unwrap().as_str().unwrap() == "get_messages" {
|
||||||
let loaded_messages = payload["loaded_messages"].as_i64().unwrap();
|
let amount = payload["amount"].as_i64().unwrap();
|
||||||
let messages = self.get_messages(loaded_messages, amount);
|
let loaded_messages = payload["loaded_messages"].as_i64().unwrap();
|
||||||
let mut payload = JsonValue::new_object();
|
let messages = self.get_messages(loaded_messages, amount).clone();
|
||||||
payload["messages"] = messages;
|
let mut payload = JsonValue::new_object();
|
||||||
return CommunicationValue::new(CommunicationType::function)
|
payload["messages"] = messages;
|
||||||
.with_id(cv.get_id())
|
return CommunicationValue::new(CommunicationType::function)
|
||||||
.add_data_str(DataTypes::name, self.name.clone())
|
.with_id(cv.get_id())
|
||||||
.add_data_str(DataTypes::path, self.path.clone())
|
.add_data_str(DataTypes::name, self.name.clone())
|
||||||
.add_data_str(DataTypes::result, "message_chunk".to_string())
|
.add_data_str(DataTypes::path, self.path.clone())
|
||||||
.add_data(DataTypes::payload, payload);
|
.add_data_str(DataTypes::result, "message_chunk".to_string())
|
||||||
}
|
.add_data(DataTypes::payload, payload);
|
||||||
if cv.get_data(DataTypes::function).unwrap().as_str().unwrap() == "send_message" {
|
}
|
||||||
let message = payload["message"].as_str().unwrap();
|
if cv.get_data(DataTypes::function).unwrap().as_str().unwrap() == "send_message" {
|
||||||
let milliseconds_timestamp: u128 = std::time::SystemTime::now()
|
let message = payload["message"].as_str().unwrap();
|
||||||
.duration_since(std::time::UNIX_EPOCH)
|
let milliseconds_timestamp: u128 = std::time::SystemTime::now()
|
||||||
.unwrap()
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
.as_millis();
|
.unwrap()
|
||||||
self.add_message(milliseconds_timestamp, cv.get_sender().unwrap(), message);
|
.as_millis();
|
||||||
return CommunicationValue::new(CommunicationType::function)
|
self.add_message(milliseconds_timestamp, cv.get_sender().unwrap(), message);
|
||||||
.with_id(cv.get_id())
|
|
||||||
.add_data_str(DataTypes::name, self.name.clone())
|
let mut distribution_payload = JsonValue::new_object();
|
||||||
.add_data_str(DataTypes::path, self.path.clone())
|
distribution_payload["message"] = JsonValue::String(message.to_string());
|
||||||
.add_data_str(DataTypes::result, "message_received".to_string())
|
distribution_payload["sender_id"] =
|
||||||
.add_data(DataTypes::payload, JsonValue::new_object());
|
JsonValue::String(cv.get_sender().unwrap().to_string());
|
||||||
}
|
distribution_payload["send_time"] =
|
||||||
CommunicationValue::new(CommunicationType::error).with_id(cv.get_id())
|
JsonValue::String(milliseconds_timestamp.to_string());
|
||||||
|
let distribution = CommunicationValue::new(CommunicationType::update)
|
||||||
|
.with_id(cv.get_id())
|
||||||
|
.add_data_str(DataTypes::name, self.name.clone())
|
||||||
|
.add_data_str(DataTypes::path, self.path.clone())
|
||||||
|
.add_data_str(DataTypes::result, "message_live".to_string())
|
||||||
|
.add_data(DataTypes::payload, distribution_payload);
|
||||||
|
|
||||||
|
let connections: HashMap<Uuid, Vec<Arc<CommunityConnection>>> =
|
||||||
|
self.get_community().get_connections().await.clone();
|
||||||
|
|
||||||
|
for con in connections.values() {
|
||||||
|
for c in con {
|
||||||
|
let cd: &Arc<CommunityConnection> = c;
|
||||||
|
cd.send_message(&distribution).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommunicationValue::new(CommunicationType::function)
|
||||||
|
.with_id(cv.get_id())
|
||||||
|
.add_data_str(DataTypes::name, self.name.clone())
|
||||||
|
.add_data_str(DataTypes::path, self.path.clone())
|
||||||
|
.add_data_str(DataTypes::result, "message_received".to_string())
|
||||||
|
.add_data(DataTypes::payload, JsonValue::new_object());
|
||||||
|
}
|
||||||
|
CommunicationValue::new(CommunicationType::error).with_id(cv.get_id())
|
||||||
|
});
|
||||||
|
CommunicationValue::new(CommunicationType::error)
|
||||||
}
|
}
|
||||||
fn to_json(&self) -> JsonValue {
|
fn to_json(&self) -> JsonValue {
|
||||||
let mut v = JsonValue::new_object();
|
let mut v = JsonValue::new_object();
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !sb.is_empty() {
|
if !sb.is_empty() {
|
||||||
|
{}
|
||||||
sb.remove(0);
|
sb.remove(0);
|
||||||
sb = sb + ",";
|
sb = sb + ",";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ impl OmikronConnection {
|
||||||
/// Connect loop with retry
|
/// Connect loop with retry
|
||||||
pub async fn connect(&self) {
|
pub async fn connect(&self) {
|
||||||
loop {
|
loop {
|
||||||
match connect_async("wss://tensamin.methanium.net/ws/iota/").await {
|
match connect_async("wss://app.tensamin.net/ws/iota/").await {
|
||||||
Ok((ws_stream, _)) => {
|
Ok((ws_stream, _)) => {
|
||||||
let (write_half, read_half) = ws_stream.split();
|
let (write_half, read_half) = ws_stream.split();
|
||||||
*self.writer.lock().await = Some(write_half);
|
*self.writer.lock().await = Some(write_half);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue