From 2e35441483ebd632a1bba82c812d3f07a89867d6 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Thu, 5 May 2022 01:21:25 +0900 Subject: [PATCH] Follow reqwest change --- plume-common/src/activity_pub/inbox.rs | 2 +- plume-common/src/activity_pub/mod.rs | 2 +- plume-common/src/activity_pub/request.rs | 7 ++++--- plume-models/src/users.rs | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plume-common/src/activity_pub/inbox.rs b/plume-common/src/activity_pub/inbox.rs index 48ba6c5f..a0c3b75c 100644 --- a/plume-common/src/activity_pub/inbox.rs +++ b/plume-common/src/activity_pub/inbox.rs @@ -366,7 +366,7 @@ pub trait FromId: Sized { ) -> Result, Self::Error)> { request::get(id, Self::get_sender(), proxy) .map_err(|_| (None, InboxError::DerefError)) - .and_then(|mut r| { + .and_then(|r| { let json: serde_json::Value = r .json() .map_err(|_| (None, InboxError::InvalidObject(None)))?; diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index ebc5536f..9b85a4c0 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -1,6 +1,6 @@ use activitypub::{Activity, Link, Object}; use array_tool::vec::Uniq; -use reqwest::{header::HeaderValue, ClientBuilder, Url}; +use reqwest::{blocking::ClientBuilder, header::HeaderValue, Url}; use rocket::{ http::Status, request::{FromRequest, Request}, diff --git a/plume-common/src/activity_pub/request.rs b/plume-common/src/activity_pub/request.rs index 4258bd7b..3d60b820 100644 --- a/plume-common/src/activity_pub/request.rs +++ b/plume-common/src/activity_pub/request.rs @@ -1,10 +1,11 @@ use chrono::{offset::Utc, DateTime}; use openssl::hash::{Hasher, MessageDigest}; use reqwest::{ + blocking::{ClientBuilder, Response}, header::{ HeaderMap, HeaderValue, InvalidHeaderValue, ACCEPT, CONTENT_TYPE, DATE, HOST, USER_AGENT, }, - ClientBuilder, Proxy, Response, Url, UrlError, + Proxy, Url, }; use std::ops::Deref; use std::time::SystemTime; @@ -18,8 +19,8 @@ const PLUME_USER_AGENT: &str = concat!("Plume/", env!("CARGO_PKG_VERSION")); #[derive(Debug)] pub struct Error(); -impl From for Error { - fn from(_err: UrlError) -> Self { +impl From for Error { + fn from(_err: url::ParseError) -> Self { Error() } } diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 1e27fb19..85aaf941 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -243,7 +243,7 @@ impl User { } fn fetch(url: &str) -> Result { - let mut res = get(url, Self::get_sender(), CONFIG.proxy().cloned())?; + let res = get(url, Self::get_sender(), CONFIG.proxy().cloned())?; let text = &res.text()?; // without this workaround, publicKey is not correctly deserialized let ap_sign = serde_json::from_str::(text)?; @@ -482,7 +482,7 @@ impl User { Ok(coll) } fn fetch_outbox_page(&self, url: &str) -> Result<(Vec, Option)> { - let mut res = get(url, Self::get_sender(), CONFIG.proxy().cloned())?; + let res = get(url, Self::get_sender(), CONFIG.proxy().cloned())?; let text = &res.text()?; let json: serde_json::Value = serde_json::from_str(text)?; let items = json["items"] @@ -496,7 +496,7 @@ impl User { Ok((items, next)) } pub fn fetch_outbox(&self) -> Result> { - let mut res = get( + let res = get( &self.outbox_url[..], Self::get_sender(), CONFIG.proxy().cloned(), @@ -532,7 +532,7 @@ impl User { } pub fn fetch_followers_ids(&self) -> Result> { - let mut res = get( + let res = get( &self.followers_endpoint[..], Self::get_sender(), CONFIG.proxy().cloned(),