Swap to UNIX timestamps as user ID's
This commit is contained in:
parent
bc441d44c9
commit
9d43687f8b
18 changed files with 234 additions and 276 deletions
|
|
@ -2,7 +2,6 @@ use crate::util::file_util::{get_children, get_directory, load_file, save_file};
|
|||
use json::{self, JsonValue, array, object};
|
||||
use std::fs::{self};
|
||||
use std::path::Path;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::gui::log_panel::log_message;
|
||||
|
||||
|
|
@ -27,8 +26,8 @@ impl MessageState {
|
|||
pub fn add_message(
|
||||
send_time: u128,
|
||||
storage_owner_is_sender: bool,
|
||||
storage_owner: Uuid,
|
||||
external_user: Uuid,
|
||||
storage_owner: i64,
|
||||
external_user: i64,
|
||||
message: &str,
|
||||
) {
|
||||
let user_dir = format!(
|
||||
|
|
@ -87,8 +86,8 @@ pub fn add_message(
|
|||
save_file(&user_dir, &file_name, &message_chunk.dump());
|
||||
}
|
||||
pub fn change_message_state(
|
||||
storage_owner: Uuid,
|
||||
external_user: Uuid,
|
||||
storage_owner: i64,
|
||||
external_user: i64,
|
||||
timestamp: i64,
|
||||
new_state: MessageState,
|
||||
) -> std::io::Result<()> {
|
||||
|
|
@ -132,8 +131,8 @@ pub fn change_message_state(
|
|||
}
|
||||
|
||||
pub fn get_messages(
|
||||
storage_owner: Uuid,
|
||||
external_user: Uuid,
|
||||
storage_owner: i64,
|
||||
external_user: i64,
|
||||
loaded_messages: i64,
|
||||
amount: i64,
|
||||
) -> JsonValue {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use json::{self, JsonValue, array};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::users::contact::Contact;
|
||||
use crate::util::file_util::{load_file, save_file};
|
||||
|
||||
pub fn mod_user(storage_owner: Uuid, contact: &Contact) {
|
||||
pub fn mod_user(storage_owner: i64, contact: &Contact) {
|
||||
let dir: &str = &format!("users/{}/contacts/", storage_owner);
|
||||
let s = load_file(dir, "contacts.json");
|
||||
|
||||
|
|
@ -25,7 +24,7 @@ pub fn mod_user(storage_owner: Uuid, contact: &Contact) {
|
|||
save_file(&dir, "contacts.json", &contacts.dump());
|
||||
}
|
||||
|
||||
pub fn get_user(storage_owner: Uuid, user_id: Uuid) -> Option<Contact> {
|
||||
pub fn get_user(storage_owner: i64, user_id: i64) -> Option<Contact> {
|
||||
let dir = format!("users/{}/contacts/", storage_owner);
|
||||
let s = load_file(&dir, "contacts.json");
|
||||
if s.is_empty() {
|
||||
|
|
@ -34,8 +33,8 @@ pub fn get_user(storage_owner: Uuid, user_id: Uuid) -> Option<Contact> {
|
|||
|
||||
if let Ok(contacts) = json::parse(&s) {
|
||||
for i in 0..contacts.len() {
|
||||
if let Some(uid) = contacts[i]["user_id"].as_str() {
|
||||
if Uuid::parse_str(uid).ok()? == user_id {
|
||||
if let Some(uid) = contacts[i]["user_id"].as_i64() {
|
||||
if uid == user_id {
|
||||
return Option::from(Contact::from_json(&contacts[i]));
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +43,7 @@ pub fn get_user(storage_owner: Uuid, user_id: Uuid) -> Option<Contact> {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn get_users(storage_owner: Uuid) -> JsonValue {
|
||||
pub fn get_users(storage_owner: i64) -> JsonValue {
|
||||
let dir: &str = &format!("users/{}/contacts/", storage_owner);
|
||||
let s = load_file(dir, "contacts.json");
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,8 @@ impl ConfigUtil {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_iota_id(&self) -> Uuid {
|
||||
self.config["iota_id"]
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.parse()
|
||||
.unwrap_or_default()
|
||||
pub fn get_iota_id(&self) -> i64 {
|
||||
self.config["iota_id"].as_i64().unwrap_or(0)
|
||||
}
|
||||
|
||||
pub fn get_port(&self) -> u16 {
|
||||
|
|
@ -44,8 +40,8 @@ impl ConfigUtil {
|
|||
&self.config[key]
|
||||
}
|
||||
|
||||
pub fn change(&mut self, key: &str, value: &str) {
|
||||
self.config[key] = JsonValue::String(value.to_string());
|
||||
pub fn change(&mut self, key: &str, value: JsonValue) {
|
||||
self.config[key] = value;
|
||||
self.unique = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue