Skip to content

Commit 7cd3617

Browse files
committed
nostr: log NIP11 json response before deserialization
1 parent eb5c889 commit 7cd3617

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

crates/nostr/src/nips/nip11.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ impl RelayInformationDocument {
9393
.get(url.to_string())
9494
.header("Accept", "application/nostr+json");
9595
match req.send().await {
96-
Ok(response) => match response.json().await {
97-
Ok(json) => Ok(json),
98-
Err(_) => Err(Error::InvalidInformationDocument),
99-
},
96+
Ok(response) => {
97+
let json: String = response.text().await?;
98+
tracing::debug!("Response: {json}");
99+
match serde_json::from_slice(json.as_bytes()) {
100+
Ok(json) => Ok(json),
101+
Err(_) => Err(Error::InvalidInformationDocument),
102+
}
103+
}
100104
Err(_) => Err(Error::InaccessibleInformationDocument),
101105
}
102106
}
@@ -118,10 +122,14 @@ impl RelayInformationDocument {
118122
.get(url.to_string())
119123
.header("Accept", "application/nostr+json");
120124
match req.send() {
121-
Ok(response) => match response.json() {
122-
Ok(json) => Ok(json),
123-
Err(_) => Err(Error::InvalidInformationDocument),
124-
},
125+
Ok(response) => {
126+
let json: String = response.text()?;
127+
tracing::debug!("Response: {json}");
128+
match serde_json::from_slice(json.as_bytes()) {
129+
Ok(json) => Ok(json),
130+
Err(_) => Err(Error::InvalidInformationDocument),
131+
}
132+
}
125133
Err(_) => Err(Error::InaccessibleInformationDocument),
126134
}
127135
}
@@ -137,10 +145,14 @@ impl RelayInformationDocument {
137145
.get(url.to_string())
138146
.header("Accept", "application/nostr+json");
139147
match req.send().await {
140-
Ok(response) => match response.json().await {
141-
Ok(json) => Ok(json),
142-
Err(_) => Err(Error::InvalidInformationDocument),
143-
},
148+
Ok(response) => {
149+
let json: String = response.text().await?;
150+
tracing::debug!("Response: {json}");
151+
match serde_json::from_slice(json.as_bytes()) {
152+
Ok(json) => Ok(json),
153+
Err(_) => Err(Error::InvalidInformationDocument),
154+
}
155+
}
144156
Err(_) => Err(Error::InaccessibleInformationDocument),
145157
}
146158
}

0 commit comments

Comments
 (0)