+3
-1
crates/jacquard-common/src/session.rs
+3
-1
crates/jacquard-common/src/session.rs
···
94
/// Create a new file token store at the given path.
95
pub fn new(path: impl AsRef<Path>) -> Self {
96
std::fs::create_dir_all(path.as_ref().parent().unwrap()).unwrap();
97
+
if !path.as_ref().exists() {
98
+
std::fs::write(path.as_ref(), b"{}").unwrap();
99
+
}
100
101
Self {
102
path: path.as_ref().to_path_buf(),
+4
-8
crates/jacquard/src/richtext.rs
+4
-8
crates/jacquard/src/richtext.rs
···
1080
1081
/// Fetch OpenGraph metadata from a URL using the webpage crate
1082
#[cfg(feature = "api_bluesky")]
1083
-
async fn fetch_opengraph_metadata<C>(
1084
client: &C,
1085
url: &str,
1086
) -> Result<Option<ExternalMetadata<'static>>, Box<dyn std::error::Error + Send + Sync>>
···
1091
let request = http::Request::builder()
1092
.method("GET")
1093
.uri(url)
1094
-
.header("User-Agent", "jacquard/0.6")
1095
-
.body(Vec::new())
1096
-
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)?;
1097
1098
// Fetch the page
1099
-
let response = client
1100
-
.send_http(request)
1101
-
.await
1102
-
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)?;
1103
1104
// Parse HTML body
1105
let html = String::from_utf8_lossy(response.body());
···
1080
1081
/// Fetch OpenGraph metadata from a URL using the webpage crate
1082
#[cfg(feature = "api_bluesky")]
1083
+
pub async fn fetch_opengraph_metadata<C>(
1084
client: &C,
1085
url: &str,
1086
) -> Result<Option<ExternalMetadata<'static>>, Box<dyn std::error::Error + Send + Sync>>
···
1091
let request = http::Request::builder()
1092
.method("GET")
1093
.uri(url)
1094
+
.header("User-Agent", "jacquard/0.8")
1095
+
.body(Vec::new())?;
1096
1097
// Fetch the page
1098
+
let response = client.send_http(request).await?;
1099
1100
// Parse HTML body
1101
let html = String::from_utf8_lossy(response.body());