mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Synthesize GitHub avatar URL and follow redirects when fetching it
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
84d4bb6186
commit
e0e0bdbc3a
3 changed files with 6 additions and 4 deletions
|
|
@ -558,8 +558,8 @@ impl Server {
|
|||
.into_iter()
|
||||
.map(|user| proto::User {
|
||||
id: user.id.to_proto(),
|
||||
avatar_url: format!("https://github.com/{}.png?size=128", user.github_login),
|
||||
github_login: user.github_login,
|
||||
avatar_url: String::new(),
|
||||
})
|
||||
.collect();
|
||||
self.peer
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ pub use anyhow::{anyhow, Result};
|
|||
use futures::future::BoxFuture;
|
||||
use std::sync::Arc;
|
||||
pub use surf::{
|
||||
http::{Method, Request, Response as ServerResponse},
|
||||
Response, Url,
|
||||
http::{Method, Response as ServerResponse},
|
||||
Request, Response, Url,
|
||||
};
|
||||
|
||||
pub trait HttpClient: Send + Sync {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,9 @@ impl User {
|
|||
|
||||
async fn fetch_avatar(http: &dyn HttpClient, url: &str) -> Result<Arc<ImageData>> {
|
||||
let url = Url::parse(url).with_context(|| format!("failed to parse avatar url {:?}", url))?;
|
||||
let request = Request::new(Method::Get, url);
|
||||
let mut request = Request::new(Method::Get, url);
|
||||
request.middleware(surf::middleware::Redirect::default());
|
||||
|
||||
let mut response = http
|
||||
.send(request)
|
||||
.await
|
||||
|
|
|
|||
Loading…
Reference in a new issue