fix(client): fixing tokens to not be encoded wholesale
Query tokens weren't working because they were being encoded entirely. Switched to encoding the key and value separately
This commit is contained in:
parent
59ec2de7e7
commit
a139d3efe3
2 changed files with 10 additions and 5 deletions
|
|
@ -1153,12 +1153,17 @@ impl<'a> SzurubooruRequest<'a> {
|
||||||
pub async fn delete_comment(&self, comment_id: u32, version: u32) -> SzurubooruResult<()> {
|
pub async fn delete_comment(&self, comment_id: u32, version: u32) -> SzurubooruResult<()> {
|
||||||
let path = format!("/comment/{comment_id}");
|
let path = format!("/comment/{comment_id}");
|
||||||
let version_obj = ResourceVersion { version };
|
let version_obj = ResourceVersion { version };
|
||||||
self.do_request(Method::DELETE, &path, None, Some(&version_obj))
|
self.do_request::<Value, _, _>(Method::DELETE, &path, None, Some(&version_obj))
|
||||||
.await
|
.await
|
||||||
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates score of authenticated user for given comment. Valid scores are -1, 0 and 1.
|
/// Updates score of authenticated user for given comment. Valid scores are -1, 0 and 1.
|
||||||
pub async fn rate_comment(&self, comment_id: u32, score: i8) -> SzurubooruResult<()> {
|
pub async fn rate_comment(
|
||||||
|
&self,
|
||||||
|
comment_id: u32,
|
||||||
|
score: i8,
|
||||||
|
) -> SzurubooruResult<CommentResource> {
|
||||||
let path = format!("/comment/{comment_id}/score");
|
let path = format!("/comment/{comment_id}/score");
|
||||||
let rating = RateResource { score };
|
let rating = RateResource { score };
|
||||||
self.do_request(Method::PUT, &path, None, Some(&rating))
|
self.do_request(Method::PUT, &path, None, Some(&rating))
|
||||||
|
|
|
||||||
|
|
@ -143,18 +143,18 @@ impl QueryToken {
|
||||||
impl Display for QueryToken {
|
impl Display for QueryToken {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let suffix = if !self.value.is_empty() {
|
let suffix = if !self.value.is_empty() {
|
||||||
format!(":{}", self.value)
|
format!(":{}", encode(&self.value))
|
||||||
} else {
|
} else {
|
||||||
"".to_string()
|
"".to_string()
|
||||||
};
|
};
|
||||||
write!(f, "{}{}", self.key, suffix)
|
write!(f, "{}{}", encode(&self.key), suffix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToQueryString for Vec<QueryToken> {
|
impl ToQueryString for Vec<QueryToken> {
|
||||||
fn to_query_string(&self) -> String {
|
fn to_query_string(&self) -> String {
|
||||||
let query_vec: Vec<String> = self.iter().map(|qv| qv.to_string()).collect();
|
let query_vec: Vec<String> = self.iter().map(|qv| qv.to_string()).collect();
|
||||||
encode(&query_vec.join(" ")).to_string()
|
query_vec.join(" ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue