mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 18:41:10 +00:00
Pass secret token when uploading crashes
This commit is contained in:
parent
54a45095cd
commit
da3870ea31
3 changed files with 11 additions and 7 deletions
|
@ -1,6 +1,5 @@
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use client::http::HttpClient;
|
use client::{http::HttpClient, ZED_SECRET_CLIENT_TOKEN};
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
elements::{Empty, MouseEventHandler, Text},
|
elements::{Empty, MouseEventHandler, Text},
|
||||||
|
@ -16,7 +15,6 @@ use std::{env, ffi::OsString, path::PathBuf, sync::Arc, time::Duration};
|
||||||
use workspace::{ItemHandle, StatusItemView};
|
use workspace::{ItemHandle, StatusItemView};
|
||||||
|
|
||||||
const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
|
const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
|
||||||
const ACCESS_TOKEN: &'static str = "618033988749894";
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref ZED_APP_VERSION: Option<AppVersion> = env::var("ZED_APP_VERSION")
|
pub static ref ZED_APP_VERSION: Option<AppVersion> = env::var("ZED_APP_VERSION")
|
||||||
|
@ -135,7 +133,7 @@ impl AutoUpdater {
|
||||||
});
|
});
|
||||||
let mut response = client
|
let mut response = client
|
||||||
.get(
|
.get(
|
||||||
&format!("{server_url}/api/releases/latest?token={ACCESS_TOKEN}&asset=Zed.dmg"),
|
&format!("{server_url}/api/releases/latest?token={ZED_SECRET_CLIENT_TOKEN}&asset=Zed.dmg"),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
|
|
|
@ -50,6 +50,8 @@ lazy_static! {
|
||||||
.and_then(|s| if s.is_empty() { None } else { Some(s) });
|
.and_then(|s| if s.is_empty() { None } else { Some(s) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const ZED_SECRET_CLIENT_TOKEN: &'static str = "618033988749894";
|
||||||
|
|
||||||
actions!(client, [Authenticate]);
|
actions!(client, [Authenticate]);
|
||||||
|
|
||||||
pub fn init(rpc: Arc<Client>, cx: &mut MutableAppContext) {
|
pub fn init(rpc: Arc<Client>, cx: &mut MutableAppContext) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use cli::{
|
||||||
use client::{
|
use client::{
|
||||||
self,
|
self,
|
||||||
http::{self, HttpClient},
|
http::{self, HttpClient},
|
||||||
ChannelList, UserStore,
|
ChannelList, UserStore, ZED_SECRET_CLIENT_TOKEN,
|
||||||
};
|
};
|
||||||
use fs::OpenOptions;
|
use fs::OpenOptions;
|
||||||
use futures::{
|
use futures::{
|
||||||
|
@ -296,7 +296,8 @@ fn init_crash_handler(
|
||||||
.context("error reading crash file")?;
|
.context("error reading crash file")?;
|
||||||
let body = serde_json::to_string(&json!({
|
let body = serde_json::to_string(&json!({
|
||||||
"text": text,
|
"text": text,
|
||||||
"version": version
|
"version": version,
|
||||||
|
"token": ZED_SECRET_CLIENT_TOKEN,
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let request = Request::builder()
|
let request = Request::builder()
|
||||||
|
@ -311,7 +312,10 @@ fn init_crash_handler(
|
||||||
.context("error removing crash after sending it successfully")
|
.context("error removing crash after sending it successfully")
|
||||||
.log_err();
|
.log_err();
|
||||||
} else {
|
} else {
|
||||||
log::error!("{:?}", response);
|
return Err(anyhow!(
|
||||||
|
"error uploading crash to server: {}",
|
||||||
|
response.status()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok::<_, anyhow::Error>(())
|
Ok::<_, anyhow::Error>(())
|
||||||
|
|
Loading…
Reference in a new issue