A photo manager for VRChat.

update to new backend

Changed files
+13 -18
src
src-tauri
+2 -2
src-tauri/src/main.rs
··· 53 54 #[tauri::command] 55 fn start_user_auth() { 56 - open::that("https://id.phazed.xyz?oauth=79959294626406").unwrap(); 57 } 58 59 #[tauri::command] ··· 266 267 let mut cmd = Command::new(&container_folder.join("./updater.exe")); 268 cmd.current_dir(container_folder); 269 - cmd.spawn().expect("Cannot run VRChat Photo Manager"); 270 271 process::exit(0); 272 }
··· 53 54 #[tauri::command] 55 fn start_user_auth() { 56 + open::that("https://photos.phazed.xyz/api/v1/auth").unwrap(); 57 } 58 59 #[tauri::command] ··· 266 267 let mut cmd = Command::new(&container_folder.join("./updater.exe")); 268 cmd.current_dir(container_folder); 269 + cmd.spawn().expect("Cannot run updater"); 270 271 process::exit(0); 272 }
+4 -4
src-tauri/src/photosync.rs
··· 41 let re1 = Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}.png").unwrap(); 42 let re2 = Regex::new( 43 r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap(); 44 - 45 if 46 re1.is_match(p.file_name().to_str().unwrap()) || 47 re2.is_match(p.file_name().to_str().unwrap()) ··· 55 } 56 } 57 58 - let body = reqwest::blocking::get(format!("https://photos.phazed.xyz/api/v1/photos/exists?token={}", &token)).unwrap() 59 .text().unwrap(); 60 61 let body: Value = serde_json::from_str(&body).unwrap(); ··· 97 98 match file{ 99 Ok(file) => { 100 - let res = client.put(format!("https://photos.phazed.xyz/api/v1/photos?token={}", &token)) 101 .header("Content-Type", "image/png") 102 .header("filename", photo) 103 .body(file) ··· 164 165 let full_path = format!("{}\\{}\\{}", path.to_str().unwrap(), folder_name, photo); 166 167 - let res = client.get(format!("https://photos.phazed.xyz/api/v1/photos?token={}&photo={}", &token, &photo)) 168 .timeout(Duration::from_secs(120)) 169 .send().unwrap().bytes(); 170
··· 41 let re1 = Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}.png").unwrap(); 42 let re2 = Regex::new( 43 r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap(); 44 + 45 if 46 re1.is_match(p.file_name().to_str().unwrap()) || 47 re2.is_match(p.file_name().to_str().unwrap()) ··· 55 } 56 } 57 58 + let body = reqwest::blocking::get(format!("https://photos-cdn.phazed.xyz/api/v1/photos/exists?token={}", &token)).unwrap() 59 .text().unwrap(); 60 61 let body: Value = serde_json::from_str(&body).unwrap(); ··· 97 98 match file{ 99 Ok(file) => { 100 + let res = client.put(format!("https://photos-cdn.phazed.xyz/api/v1/photos?token={}", &token)) 101 .header("Content-Type", "image/png") 102 .header("filename", photo) 103 .body(file) ··· 164 165 let full_path = format!("{}\\{}\\{}", path.to_str().unwrap(), folder_name, photo); 166 167 + let res = client.get(format!("https://photos-cdn.phazed.xyz/api/v1/photos?token={}&photo={}", &token, &photo)) 168 .timeout(Duration::from_secs(120)) 169 .send().unwrap().bytes(); 170
+1 -1
src-tauri/tauri.conf.json
··· 23 "http": { 24 "all": true, 25 "request": true, 26 - "scope": [ "https://photos.phazed.xyz/*" ] 27 }, 28 "window": { 29 "close": true,
··· 23 "http": { 24 "all": true, 25 "request": true, 26 + "scope": [ "https://photos.phazed.xyz/*", "https://photos-cdn.phazed.xyz/*" ] 27 }, 28 "window": { 29 "close": true,
+2 -4
src/Components/App.tsx
··· 36 } 37 38 if(localStorage.getItem('token')){ 39 - fetch<any>('https://photos.phazed.xyz/api/v1/account', { 40 method: 'GET', 41 - headers: { auth: localStorage.getItem('token' )}, 42 responseType: ResponseType.JSON 43 }) 44 .then(data => { ··· 116 listen('auth-callback', ( event: any ) => { 117 let token = event.payload; 118 119 - fetch<any>('https://photos.phazed.xyz/api/v1/account', { 120 method: 'GET', 121 - headers: { auth: token }, 122 responseType: ResponseType.JSON 123 }) 124 .then(data => {
··· 36 } 37 38 if(localStorage.getItem('token')){ 39 + fetch<any>('https://photos.phazed.xyz/api/v1/account?token='+localStorage.getItem('token'), { 40 method: 'GET', 41 responseType: ResponseType.JSON 42 }) 43 .then(data => { ··· 115 listen('auth-callback', ( event: any ) => { 116 let token = event.payload; 117 118 + fetch<any>('https://photos.phazed.xyz/api/v1/account?token='+token, { 119 method: 'GET', 120 responseType: ResponseType.JSON 121 }) 122 .then(data => {
+2 -4
src/Components/NavBar.tsx
··· 148 duration: 250 149 }) 150 151 - fetch<any>('https://photos.phazed.xyz/api/v1/account', { 152 method: 'GET', 153 - headers: { auth: localStorage.getItem('token')! }, 154 responseType: ResponseType.JSON 155 }) 156 .then(data => { ··· 171 172 <Show when={props.loggedIn().loggedIn == false} fallback={ 173 <div class="dropdown-button" onClick={() => { 174 - fetch<any>('https://photos.phazed.xyz/api/v1/deauth', { 175 method: 'DELETE', 176 - headers: { auth: localStorage.getItem('token')! }, 177 responseType: ResponseType.JSON 178 }) 179 .then(data => {
··· 148 duration: 250 149 }) 150 151 + fetch<any>('https://photos.phazed.xyz/api/v1/account?token='+localStorage.getItem('token')!, { 152 method: 'GET', 153 responseType: ResponseType.JSON 154 }) 155 .then(data => { ··· 170 171 <Show when={props.loggedIn().loggedIn == false} fallback={ 172 <div class="dropdown-button" onClick={() => { 173 + fetch<any>('https://photos.phazed.xyz/api/v1/deauth?token='+localStorage.getItem('token')!, { 174 method: 'DELETE', 175 responseType: ResponseType.JSON 176 }) 177 .then(data => {
+2 -3
src/Components/SettingsMenu.tsx
··· 172 }) 173 174 let refreshAccount = () => { 175 - fetch<any>('https://photos.phazed.xyz/api/v1/account', { 176 method: 'GET', 177 - headers: { auth: localStorage.getItem('token')! }, 178 responseType: ResponseType.JSON 179 }) 180 .then(data => { ··· 363 props.setStorageInfo({ used: 0, storage: 0, sync: false }); 364 setDeletingPhotos(true); 365 366 - fetch<any>('https://photos.phazed.xyz/api/v1/allphotos', { 367 method: 'DELETE', 368 headers: { auth: localStorage.getItem("token")! }, 369 responseType: ResponseType.JSON
··· 172 }) 173 174 let refreshAccount = () => { 175 + fetch<any>('https://photos.phazed.xyz/api/v1/account?token='+localStorage.getItem('token')!, { 176 method: 'GET', 177 responseType: ResponseType.JSON 178 }) 179 .then(data => { ··· 362 props.setStorageInfo({ used: 0, storage: 0, sync: false }); 363 setDeletingPhotos(true); 364 365 + fetch<any>('https://photos-cdn.phazed.xyz/api/v1/allphotos', { 366 method: 'DELETE', 367 headers: { auth: localStorage.getItem("token")! }, 368 responseType: ResponseType.JSON