format, use logging properly, restrict runtime.log to 5mb, bump versions, update framework
This commit is contained in:
parent
add21253c7
commit
ba25e5d485
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fanslysync-desktop",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
@ -17,7 +17,7 @@
|
||||
"@sveltejs/adapter-static": "^3.0.5",
|
||||
"@sveltejs/kit": "^2.6.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"@tauri-apps/cli": "^2.1.0",
|
||||
"@tauri-apps/cli": "^2.4.1",
|
||||
"@types/eslint": "^9.6.1",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.12.0",
|
||||
|
2383
src-tauri/Cargo.lock
generated
2383
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -17,18 +17,19 @@ tauri-build = { version = "2.0.0", features = [] }
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "2.0.0-rc.2", features = [] }
|
||||
tauri = { version = "2.4.1", features = [] }
|
||||
dirs = "5.0.1"
|
||||
reqwest = { version = "0.11.18", features = ["json"] }
|
||||
reqwest = { version = "0.11.18", features = ["json", "multipart"] }
|
||||
lazy_static = "1.5.0"
|
||||
tokio = { version = "1.29.1", features = ["full"] }
|
||||
tokio-macros = "2.3.0"
|
||||
tauri-plugin-os = { version = "2.0.0" }
|
||||
tauri-plugin-dialog = { version = "2.0.0" }
|
||||
tauri-plugin-clipboard-manager = { version = "2.0.0" }
|
||||
tauri-plugin-notification = { version = "2.0.0" }
|
||||
tauri-plugin-updater = { version = "2.0.0" }
|
||||
tauri-plugin-log = { version = "2.0.0" }
|
||||
tauri-plugin-os = { version = "2.2.1" }
|
||||
tauri-plugin-dialog = { version = "2.2.1" }
|
||||
tauri-plugin-clipboard-manager = { version = "2.2.1" }
|
||||
tauri-plugin-notification = { version = "2.2.1" }
|
||||
tauri-plugin-updater = { version = "2.2.1" }
|
||||
tauri-plugin-log = { version = "2.2.1" }
|
||||
log = "0.4.27"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
|
||||
@ -37,4 +38,4 @@ tauri-plugin-log = { version = "2.0.0" }
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-autostart = "2.0.0"
|
||||
tauri-plugin-autostart = "2.3.0"
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,16 +2,16 @@ use crate::handlers::config::{get_config_path, Config};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn init_config() -> Result<(), String> {
|
||||
println!("[commands::config::init_config] Initializing config...");
|
||||
log::info!("[commands::config::init_config] Initializing config...");
|
||||
let config_path = get_config_path().map_err(|e| e.to_string())?;
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"[commands::config::init_config] Config path: {}",
|
||||
config_path.display()
|
||||
);
|
||||
|
||||
Config::load_or_create(&config_path).map_err(|e| e.to_string())?;
|
||||
println!("[commands::config::init_config] Config initialized successfully");
|
||||
log::info!("[commands::config::init_config] Config initialized successfully");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ pub fn get_config() -> Result<Config, String> {
|
||||
let config_path = get_config_path().map_err(|e| e.to_string())?;
|
||||
let config = Config::load_or_create(&config_path).map_err(|e| e.to_string())?;
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"[commands::config::get_config] Config loaded successfully: {:?} from path: {}",
|
||||
config,
|
||||
config_path.display()
|
||||
@ -32,7 +32,7 @@ pub fn get_config() -> Result<Config, String> {
|
||||
#[tauri::command]
|
||||
pub fn save_config(config: Config) -> Result<(), String> {
|
||||
let config_path = get_config_path().map_err(|e| e.to_string())?;
|
||||
println!(
|
||||
log::info!(
|
||||
"[commands::config::save_config] Saving config: {:?} to path: {}",
|
||||
config,
|
||||
config_path.display()
|
||||
|
@ -55,15 +55,15 @@ impl Config {
|
||||
let config_raw = std::fs::read_to_string(path)?;
|
||||
let config_json: serde_json::Value = serde_json::from_str(&config_raw)?;
|
||||
|
||||
println!("[config::migrate] Migrating config file to latest version...");
|
||||
println!(
|
||||
log::info!("[config::migrate] Migrating config file to latest version...");
|
||||
log::debug!(
|
||||
"[config::migrate] [DEBUG] config is_object: {}",
|
||||
config_json.is_object()
|
||||
);
|
||||
|
||||
// Check if the JSON object is valid, if not, return an error
|
||||
if !config_json.is_object() {
|
||||
println!(
|
||||
log::error!(
|
||||
"[config::migrate] [ERROR] Found invalid JSON object in config file"
|
||||
);
|
||||
return Err(io::Error::new(
|
||||
@ -77,7 +77,7 @@ impl Config {
|
||||
|
||||
// Check if the version field is a valid integer, if not, return an error
|
||||
if version == 0 {
|
||||
println!(
|
||||
log::error!(
|
||||
"[config::migrate] [ERROR] Found invalid version field in config JSON"
|
||||
);
|
||||
return Err(io::Error::new(
|
||||
@ -86,7 +86,7 @@ impl Config {
|
||||
));
|
||||
}
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"[config::migrate] Found version field in config JSON: {}",
|
||||
version
|
||||
);
|
||||
@ -110,7 +110,7 @@ impl Config {
|
||||
config = config.migrate()?;
|
||||
config.save(path)?;
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"[config::migrate] Successfully migrated config file to latest version"
|
||||
);
|
||||
// Recursively call load_or_create to load the migrated config
|
||||
|
@ -154,15 +154,16 @@ impl Fansly {
|
||||
let response = self.client.get(url).headers(headers).send().await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
eprintln!("[fanslySyncExt] No successful response from API. Setting error state.");
|
||||
log::error!("[sync::process::fetch_subscribers] No successful response from API. Setting error state.");
|
||||
let error = response.error_for_status().unwrap_err();
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
let subscriptions: FanslyBaseResponse<FanslySubscriptionsResponse> =
|
||||
response.json().await?;
|
||||
println!(
|
||||
"[fanslySyncExt] Got {} subscriptions from API.",
|
||||
|
||||
log::info!(
|
||||
"[sync::process::fetch_subscribers] Got {} subscribers from API.",
|
||||
subscriptions.response.subscriptions.len()
|
||||
);
|
||||
|
||||
@ -170,32 +171,37 @@ impl Fansly {
|
||||
}
|
||||
|
||||
async fn upload_sync_data(&self, data: SyncDataResponse) -> Result<String, reqwest::Error> {
|
||||
let url = "https://paste.hep.gg/documents";
|
||||
let url = "https://paste.fanslycreatorbot.com";
|
||||
|
||||
// Set our content type to application/json
|
||||
let mut headers = reqwest::header::HeaderMap::new();
|
||||
headers.insert(
|
||||
reqwest::header::CONTENT_TYPE,
|
||||
"application/json".parse().unwrap(),
|
||||
// Convert passed data to bytes
|
||||
let json_string = serde_json::to_string(&data).unwrap();
|
||||
let data_as_bytes = json_string.as_bytes();
|
||||
|
||||
let form = reqwest::multipart::Form::new()
|
||||
.part(
|
||||
"file",
|
||||
reqwest::multipart::Part::bytes(data_as_bytes.to_vec())
|
||||
.file_name("sync_data.json")
|
||||
.mime_str("application/json")?,
|
||||
);
|
||||
|
||||
// Create a new client and POST
|
||||
let response = self
|
||||
.client
|
||||
.post(url)
|
||||
.headers(headers)
|
||||
.json(&data)
|
||||
.multipart(form)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
eprintln!("[sync::process::upload_sync_data] Failed to upload sync data.");
|
||||
log::error!("Failed to upload sync data...");
|
||||
log::info!("Response: {:?}", response);
|
||||
return Err(response.error_for_status().unwrap_err());
|
||||
}
|
||||
|
||||
let json: serde_json::Value = response.json().await?;
|
||||
let key = json["key"].as_str().unwrap();
|
||||
|
||||
Ok(format!("https://paste.hep.gg/{}", key))
|
||||
let reply = response.text().await?;
|
||||
log::info!("Uploaded sync data successfully. Response: {}", reply);
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
pub async fn upload_auto_sync_data(
|
||||
@ -224,10 +230,12 @@ impl Fansly {
|
||||
.await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
eprintln!("[sync::process::upload_auto_sync_data] Failed to upload sync data.");
|
||||
log::error!("Failed to upload sync data...");
|
||||
log::info!("Response: {:?}", response);
|
||||
return Err(response.error_for_status().unwrap_err());
|
||||
}
|
||||
|
||||
log::info!("Uploaded sync data successfully.");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -253,7 +261,8 @@ impl Fansly {
|
||||
match response {
|
||||
Ok(response) => {
|
||||
if !response.status().is_success() {
|
||||
eprintln!("[sync::process::check_sync_token] Failed to check sync token.");
|
||||
log::error!("Failed to check sync token...");
|
||||
log::info!("Response: {:?}", response);
|
||||
return Err(response.error_for_status().unwrap_err());
|
||||
}
|
||||
|
||||
@ -266,34 +275,32 @@ impl Fansly {
|
||||
|
||||
pub async fn sync(&self, auto: bool) -> Result<SyncDataResponse, String> {
|
||||
// Fetch profile
|
||||
println!("[sync::process] Fetching profile...");
|
||||
log::info!("[sync::process] Fetching profile...");
|
||||
let profile = self.get_profile().await.map_err(|e| e.to_string())?;
|
||||
|
||||
if !profile.success {
|
||||
return Err("Failed to fetch profile".to_string());
|
||||
}
|
||||
|
||||
println!("[sync::process] Profile retrieved successfully.");
|
||||
log::info!("[sync::process] Syncing profile...");
|
||||
|
||||
let account = profile.response.account;
|
||||
let total_followers = account.follow_count;
|
||||
let total_subscribers = account.subscriber_count;
|
||||
|
||||
println!(
|
||||
"[sync::process] Account {} has {} followers and {} subscribers. Starting sync...",
|
||||
account.id, total_followers, total_subscribers
|
||||
);
|
||||
log::info!("[sync::process] Account ID: {}, Followers: {}, Subscribers: {}",
|
||||
account.id, total_followers, total_subscribers);
|
||||
|
||||
let mut followers: Vec<FanslyFollowersResponse> = Vec::new();
|
||||
let mut subscribers: Vec<Subscription> = Vec::new();
|
||||
|
||||
println!("[sync::process] Fetching followers and subscribers...");
|
||||
log::info!("[sync::process] Fetching followers...");
|
||||
|
||||
// Fetch followers until we have all of them
|
||||
let mut offset = 0;
|
||||
let mut total_requests = 0;
|
||||
while followers.len() < total_followers as usize {
|
||||
println!(
|
||||
log::info!(
|
||||
"[sync::process] Fetching followers for account {} with offset {} (total: {})",
|
||||
account.id, offset, total_followers
|
||||
);
|
||||
@ -302,7 +309,7 @@ impl Fansly {
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"[sync::process] Got {} followers from API.",
|
||||
response.response.len()
|
||||
);
|
||||
@ -319,7 +326,7 @@ impl Fansly {
|
||||
// Fetch subscribers until we have all of them
|
||||
offset = 0;
|
||||
while subscribers.len() < total_subscribers as usize {
|
||||
println!(
|
||||
log::info!(
|
||||
"[sync::process] Fetching subscribers with offset {} for account {} (total: {})",
|
||||
offset, account.id, total_subscribers
|
||||
);
|
||||
@ -339,14 +346,14 @@ impl Fansly {
|
||||
}
|
||||
}
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"[sync::process] Got {} followers and {} subscribers from API.",
|
||||
followers.len(),
|
||||
subscribers.len()
|
||||
);
|
||||
|
||||
println!("[sync::process] Sync complete.");
|
||||
println!("[sync::process] Uploading sync data to paste.hep.gg for processing...");
|
||||
log::info!("[sync::process] Sync complete.");
|
||||
log::info!("[sync::process] Uploading sync data to paste.hep.gg for processing...");
|
||||
|
||||
// Upload sync data to paste.hep.gg
|
||||
if !auto {
|
||||
|
@ -39,7 +39,6 @@ async fn main() {
|
||||
MacosLauncher::LaunchAgent,
|
||||
None,
|
||||
))
|
||||
.plugin(tauri_plugin_log::Builder::new().build())
|
||||
.plugin(tauri_plugin_notification::init())
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
@ -54,6 +53,8 @@ async fn main() {
|
||||
}),
|
||||
Target::new(TargetKind::Webview),
|
||||
])
|
||||
.rotation_strategy(tauri_plugin_log::RotationStrategy::KeepOne)
|
||||
.max_file_size(1024 * 1024 * 5)
|
||||
.build(),
|
||||
)
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
|
@ -107,7 +107,6 @@ pub struct Account {
|
||||
pub post_likes: i64,
|
||||
pub streaming: Streaming,
|
||||
pub account_media_likes: i64,
|
||||
pub earnings_wallet: EarningsWallet,
|
||||
pub subscription_tiers: Vec<SubscriptionTier>,
|
||||
pub profile_access: bool,
|
||||
}
|
||||
@ -156,18 +155,6 @@ pub struct Streaming {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EarningsWallet {
|
||||
pub id: String,
|
||||
pub account_id: String,
|
||||
pub balance: i64,
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: i64,
|
||||
pub wallet_version: i64,
|
||||
pub flags: i64,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SubscriptionTier {
|
||||
|
@ -42,7 +42,7 @@
|
||||
"createUpdaterArtifacts": true
|
||||
},
|
||||
"productName": "FanslySync",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"identifier": "com.fanslycreatorbot.fanslysync",
|
||||
"plugins": {
|
||||
"updater": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user