Skip to content

Commit

Permalink
💄
Browse files Browse the repository at this point in the history
  • Loading branch information
rgbkrk committed Apr 26, 2024
1 parent cb6d0f2 commit f7a5acb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions crates/collab/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use rpc::proto;
pub fn get_supermaven_api_key(
_request: proto::GetSupermavenApiKey,
) -> Result<supermaven_api::GetExternalUserRequest> {
#[allow(unreachable_code)]
Ok(supermaven_api::GetExternalUserRequest {
user_id: todo!("Get the user id from collab server."),
})
Err(anyhow!("User is not authorized to access Supermaven API."))
// Ok(supermaven_api::GetExternalUserRequest {
// user_id: todo!("Get the user id from collab server."),
// })
}
16 changes: 8 additions & 8 deletions crates/supermaven_api/src/supermaven_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl SupermavenAdminApi {
.http_client
.send(request.body(AsyncBody::default())?)
.await
.with_context(|| format!("Unable to get Supermaven API Key"))?;
.with_context(|| "Unable to get Supermaven API Key".to_string())?;

let mut body = Vec::new();
response.body_mut().read_to_end(&mut body).await?;
Expand All @@ -113,7 +113,7 @@ impl SupermavenAdminApi {

let body_str = std::str::from_utf8(&body)?;
serde_json::from_str::<SupermavenUser>(body_str)
.with_context(|| format!("Unable to parse Supermaven API Key response"))
.with_context(|| "Unable to parse Supermaven API Key response".to_string())
}

pub async fn try_create_user(
Expand All @@ -130,14 +130,14 @@ impl SupermavenAdminApi {
.http_client
.send(request)
.await
.with_context(|| format!("Unable to create Supermaven API Key"))?;
.with_context(|| "Unable to create Supermaven API Key".to_string())?;

let mut body = Vec::new();
response.body_mut().read_to_end(&mut body).await?;

let body_str = std::str::from_utf8(&body)?;
serde_json::from_str::<CreateExternalUserResponse>(body_str)
.with_context(|| format!("Unable to parse Supermaven API Key response"))
.with_context(|| "Unable to parse Supermaven API Key response".to_string())
}

pub async fn try_delete_user(&self, request: DeleteExternalUserRequest) -> Result<()> {
Expand All @@ -149,7 +149,7 @@ impl SupermavenAdminApi {
.http_client
.send(request.body(AsyncBody::default())?)
.await
.with_context(|| format!("Unable to delete Supermaven User"))?;
.with_context(|| "Unable to delete Supermaven User".to_string())?;

let mut body = Vec::new();
response.body_mut().read_to_end(&mut body).await?;
Expand Down Expand Up @@ -186,7 +186,7 @@ pub async fn latest_release(
let mut response = client
.send(request.body(AsyncBody::default())?)
.await
.with_context(|| format!("Unable to acquire Supermaven Agent"))?;
.with_context(|| "Unable to acquire Supermaven Agent".to_string())?;

let mut body = Vec::new();
response.body_mut().read_to_end(&mut body).await?;
Expand All @@ -198,7 +198,7 @@ pub async fn latest_release(
}

serde_json::from_slice::<SupermavenDownloadResponse>(&body)
.with_context(|| format!("Unable to parse Supermaven Agent response"))
.with_context(|| "Unable to parse Supermaven Agent response".to_string())
}

pub fn download_latest(client: Arc<dyn HttpClient>) -> impl Future<Output = Result<PathBuf>> {
Expand All @@ -222,7 +222,7 @@ pub fn download_latest(client: Arc<dyn HttpClient>) -> impl Future<Output = Resu
let mut response = client
.send(request.body(AsyncBody::default())?)
.await
.with_context(|| format!("Unable to download Supermaven Agent"))?;
.with_context(|| "Unable to download Supermaven Agent".to_string())?;

let version_dir = SUPERMAVEN_DIR.join(format!("sm-agent-{}", download_info.version));
fs::create_dir_all(&version_dir)
Expand Down

0 comments on commit f7a5acb

Please sign in to comment.