License & tensamin.net

This commit is contained in:
Alex Emmet 2025-11-03 20:26:50 +00:00
commit af1088e9fb
6 changed files with 90 additions and 43 deletions

16
LICENSE Normal file
View 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.

View file

@ -28,7 +28,7 @@ fn client() -> Client {
}
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 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> {
let url = format!(
"https://auth.tensamin.methanium.net/api/get/uuid/{}",
username
);
let url = format!("https://auth.tensamin.net/api/get/uuid/{}", username);
let client = client();
let res = client.get(&url).send().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> {
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 res = client.get(&url).send().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> {
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 res = client.get(&url).send().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 {
let url = "https://auth.tensamin.methanium.net/api/register/complete";
let url = "https://auth.tensamin.net/api/register/complete";
let client = client();
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 {
let url = format!(
"https://auth.tensamin.methanium.net/api/change/iota-id/{}",
"https://auth.tensamin.net/api/change/iota-id/{}",
user_profile.user_id
);
let client = client();

View file

@ -4,8 +4,8 @@ use crate::{
};
use axum::Json;
use json::JsonValue;
use std::any::Any;
use std::sync::Arc;
use std::{any::Any, pin::Pin};
pub type InteractableFactory = fn() -> Box<dyn Interactable>;

View file

@ -1,5 +1,8 @@
use crate::{
communities::{community::Community, interactables::interactable::Interactable},
communities::{
community::Community, community_connection::CommunityConnection,
interactables::interactable::Interactable,
},
data::communication::{CommunicationType, CommunicationValue, DataTypes},
gui::log_panel::log_message,
util::file_util::{get_children, load_file, save_file},
@ -7,9 +10,13 @@ use crate::{
use aes_gcm::aead::Payload;
use axum::Json;
use json::{JsonValue, array, object};
use std::any::Any;
use std::fs::{self, File};
use rustls::ClientConnection;
use std::sync::Arc;
use std::{any::Any, collections::HashMap};
use std::{
fs::{self, File},
pin::Pin,
};
use uuid::Uuid;
pub struct TextChat {
name: String,
@ -183,11 +190,12 @@ impl Interactable for TextChat {
JsonValue::new_object()
}
fn run_function(&self, cv: CommunicationValue) -> CommunicationValue {
let ret: Pin<Box<dyn Future<Output = CommunicationValue> + Send>> = Box::pin(async move {
let payload = cv.get_data(DataTypes::payload).unwrap();
if cv.get_data(DataTypes::function).unwrap().as_str().unwrap() == "get_messages" {
let amount = payload["amount"].as_i64().unwrap();
let loaded_messages = payload["loaded_messages"].as_i64().unwrap();
let messages = self.get_messages(loaded_messages, amount);
let messages = self.get_messages(loaded_messages, amount).clone();
let mut payload = JsonValue::new_object();
payload["messages"] = messages;
return CommunicationValue::new(CommunicationType::function)
@ -204,6 +212,29 @@ impl Interactable for TextChat {
.unwrap()
.as_millis();
self.add_message(milliseconds_timestamp, cv.get_sender().unwrap(), message);
let mut distribution_payload = JsonValue::new_object();
distribution_payload["message"] = JsonValue::String(message.to_string());
distribution_payload["sender_id"] =
JsonValue::String(cv.get_sender().unwrap().to_string());
distribution_payload["send_time"] =
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())
@ -212,6 +243,8 @@ impl Interactable for TextChat {
.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 {
let mut v = JsonValue::new_object();

View file

@ -59,6 +59,7 @@ async fn main() {
}
if !sb.is_empty() {
{}
sb.remove(0);
sb = sb + ",";
}

View file

@ -54,7 +54,7 @@ impl OmikronConnection {
/// Connect loop with retry
pub async fn connect(&self) {
loop {
match connect_async("wss://tensamin.methanium.net/ws/iota/").await {
match connect_async("wss://app.tensamin.net/ws/iota/").await {
Ok((ws_stream, _)) => {
let (write_half, read_half) = ws_stream.split();
*self.writer.lock().await = Some(write_half);