Update actix-web
This commit is contained in:
parent
02c3088787
commit
b44c3ade55
29
Cargo.toml
29
Cargo.toml
|
@ -9,32 +9,33 @@ build = "src/build.rs"
|
|||
|
||||
[dependencies]
|
||||
activitystreams = "0.7.0-alpha.8"
|
||||
actix-session = "0.4.0"
|
||||
actix-rt = "1.1.1"
|
||||
actix-web = { version = "3.3.2", features = ["rustls", "compress"] }
|
||||
actix-webfinger = "0.3.0"
|
||||
actix-session = "0.5.0-beta.1"
|
||||
actix-rt = "2.1.0"
|
||||
actix-web = { version = "4.0.0-beta.1", features = ["rustls", "compress"] }
|
||||
actix-webfinger = "0.4.0-beta.3"
|
||||
anyhow = "1.0.35"
|
||||
background-jobs = "0.8.0"
|
||||
awc = { version = "3.0.0-beta.4", features = ["rustls", "compress"] }
|
||||
background-jobs = "0.9.0"
|
||||
base64 = "0.13.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
event-listener = "2.5.1"
|
||||
fluent = "0.14.3"
|
||||
fluent-syntax = "0.10.2"
|
||||
fluent = "0.15.0"
|
||||
fluent-syntax = "0.11.0"
|
||||
futures = "0.3.11"
|
||||
html-minifier = "3.0.8"
|
||||
http-signature-normalization-actix = { version = "0.4.0", default-features = false, features = ["sha-2"] }
|
||||
http-signature-normalization-actix = { version = "0.5.0-beta.4", default-features = false, features = ["sha-2"] }
|
||||
hyaenidae-accounts = { version = "0.1.0", path = "./accounts" }
|
||||
hyaenidae-profiles = { version = "0.1.0", path = "./profiles" }
|
||||
hyaenidae-toolkit = { version = "0.1.0", path = "./toolkit" }
|
||||
i18n-embed-fl = "0.4.0"
|
||||
i18n-embed = { version = "0.11.0", features = ["fluent-system"] }
|
||||
i18n-embed-fl = "0.5.0"
|
||||
i18n-embed = { version = "0.12.0", features = ["fluent-system"] }
|
||||
log = "0.4"
|
||||
mime = "0.3.16"
|
||||
once_cell = "1.5.2"
|
||||
rand = "0.7"
|
||||
rsa = "0.3.0"
|
||||
rsa-magic-public-key = "0.2.1"
|
||||
rsa-pem = "0.2.0"
|
||||
rand = "0.8"
|
||||
rsa = "0.4.0"
|
||||
rsa-magic-public-key = "0.3.0"
|
||||
rsa-pem = "0.3.0"
|
||||
rust-embed = "5"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
|
|
@ -7,8 +7,8 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-session = "0.4.0"
|
||||
actix-web = "3.3.2"
|
||||
actix-session = "0.5.0-beta.1"
|
||||
actix-web = "4.0.0-beta.5"
|
||||
bcrypt = "0.9.0"
|
||||
event-listener = "2.5.1"
|
||||
futures = "0.3.8"
|
||||
|
|
|
@ -23,7 +23,7 @@ pub(crate) struct CookieData {
|
|||
impl CookieData {
|
||||
pub(crate) fn set_accepted(session: &Session) -> Result<(), SessionError> {
|
||||
session
|
||||
.set("accepted", CookieData { accepted: true })
|
||||
.insert("accepted", CookieData { accepted: true })
|
||||
.map_err(|_| SessionError::Set)
|
||||
}
|
||||
|
||||
|
@ -43,12 +43,12 @@ pub(crate) struct UserData {
|
|||
impl UserData {
|
||||
pub(crate) fn set_data(id: Uuid, session: &Session) -> Result<(), SessionError> {
|
||||
session
|
||||
.set("user-data", UserData { id })
|
||||
.insert("user-data", UserData { id })
|
||||
.map_err(|_| SessionError::Set)
|
||||
}
|
||||
|
||||
pub(crate) fn remove(session: &Session) {
|
||||
session.remove("user-data")
|
||||
session.remove("user-data");
|
||||
}
|
||||
|
||||
fn data(session: &Session) -> Result<Option<UserData>, actix_web::Error> {
|
||||
|
@ -80,7 +80,7 @@ impl ResponseError for ServerError {
|
|||
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
HttpResponse::build(self.status_code())
|
||||
.header(LOCATION, self.0.clone())
|
||||
.insert_header((LOCATION, self.0.clone()))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
@ -192,12 +192,11 @@ impl Drop for DropGuard {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S> for Auth
|
||||
impl<S, B> Transform<S, ServiceRequest> for Auth
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = S::Request;
|
||||
type Response = S::Response;
|
||||
type Error = S::Error;
|
||||
type InitError = ();
|
||||
|
@ -209,21 +208,20 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<S, B> Service for AuthMiddleware<S>
|
||||
impl<S, B> Service<ServiceRequest> for AuthMiddleware<S>
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = S::Request;
|
||||
type Response = S::Response;
|
||||
type Error = S::Error;
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
|
||||
|
||||
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.0.poll_ready(cx)
|
||||
}
|
||||
|
||||
fn call(&mut self, req: Self::Request) -> Self::Future {
|
||||
fn call(&self, req: ServiceRequest) -> Self::Future {
|
||||
let session = req.get_session();
|
||||
let state = self.1.clone();
|
||||
|
||||
|
@ -237,8 +235,8 @@ where
|
|||
let res = state.user_store.user_by_id(id).await;
|
||||
|
||||
let user_opt = match res {
|
||||
Ok(user_opt) => user_opt,
|
||||
Err(_) => {
|
||||
Ok(Ok(user_opt)) => user_opt,
|
||||
Ok(Err(_)) | Err(_) => {
|
||||
log::warn!("Error fetching user data from store");
|
||||
return Err(ServerError(state.pages.internal_server_error_path()).into());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{to_home, Authenticated, Error, State};
|
||||
use actix_session::Session;
|
||||
use actix_web::{error::BlockingError, web, HttpResponse};
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
pub type DeleteUserPageArgs = (Authenticated, web::Data<State>);
|
||||
|
||||
|
@ -102,10 +102,11 @@ async fn try_delete_user(
|
|||
.await;
|
||||
|
||||
match res {
|
||||
Ok(_) => (),
|
||||
Err(BlockingError::Error(crate::store::StoreError::AuthenticationFailed)) => {
|
||||
Ok(Ok(_)) => (),
|
||||
Ok(Err(crate::store::StoreError::AuthenticationFailed)) => {
|
||||
return Ok(Err(DeleteUserError::Invalid));
|
||||
}
|
||||
Ok(Err(e)) => return Err(e.into()),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{to_cookie_page, to_home, AcceptedCookies, Authenticated, Error, State};
|
||||
use actix_session::Session;
|
||||
use actix_web::{error::BlockingError, web, HttpResponse};
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
pub type LoginPageArgs = (
|
||||
Option<AcceptedCookies>,
|
||||
|
@ -131,11 +131,10 @@ async fn try_login(
|
|||
.await;
|
||||
|
||||
let user = match res {
|
||||
Ok(user) => user,
|
||||
Err(BlockingError::Error(crate::store::StoreError::AuthenticationFailed))
|
||||
| Err(BlockingError::Error(crate::store::StoreError::NoUser)) => {
|
||||
return Ok(Err(LoginError::Invalid))
|
||||
}
|
||||
Ok(Ok(user)) => user,
|
||||
Ok(Err(crate::store::StoreError::AuthenticationFailed))
|
||||
| Ok(Err(crate::store::StoreError::NoUser)) => return Ok(Err(LoginError::Invalid)),
|
||||
Ok(Err(e)) => return Err(e.into()),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{to_cookie_page, to_home, AcceptedCookies, Authenticated, Error, State};
|
||||
use actix_session::Session;
|
||||
use actix_web::{error::BlockingError, web, HttpResponse};
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
pub type RegisterPageArgs = (
|
||||
Option<AcceptedCookies>,
|
||||
|
@ -155,10 +155,9 @@ async fn try_register(
|
|||
.await;
|
||||
|
||||
let user = match res {
|
||||
Ok(user) => user,
|
||||
Err(BlockingError::Error(crate::store::StoreError::InUse)) => {
|
||||
return Ok(Err(RegisterError::UsernameTaken))
|
||||
}
|
||||
Ok(Ok(user)) => user,
|
||||
Ok(Err(crate::store::StoreError::InUse)) => return Ok(Err(RegisterError::UsernameTaken)),
|
||||
Ok(Err(e)) => return Err(e.into()),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{to_account_page, Authenticated, Error, State};
|
||||
use actix_web::{error::BlockingError, web, HttpResponse};
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
pub type UpdatePasswordPageArgs = (Authenticated, web::Data<State>);
|
||||
|
||||
|
@ -131,13 +131,12 @@ async fn try_update_password(
|
|||
.await;
|
||||
|
||||
match res {
|
||||
Ok(_) => (),
|
||||
Err(BlockingError::Error(crate::store::StoreError::AuthenticationFailed)) => {
|
||||
return Ok(Err(UpdatePasswordError::Invalid))
|
||||
}
|
||||
Err(BlockingError::Error(crate::store::StoreError::DoubleChange)) => {
|
||||
Ok(Ok(_)) => (),
|
||||
Ok(Err(crate::store::StoreError::AuthenticationFailed))
|
||||
| Ok(Err(crate::store::StoreError::DoubleChange)) => {
|
||||
return Ok(Err(UpdatePasswordError::Invalid))
|
||||
}
|
||||
Ok(Err(e)) => return Err(e.into()),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{to_account_page, Authenticated, Error, State};
|
||||
use actix_web::{error::BlockingError, web, HttpResponse};
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
pub type UpdateUsernamePageArgs = (Authenticated, web::Data<State>);
|
||||
|
||||
|
@ -116,13 +116,14 @@ async fn try_update_username(
|
|||
.await;
|
||||
|
||||
match res {
|
||||
Ok(_) => (),
|
||||
Err(BlockingError::Error(crate::store::StoreError::AuthenticationFailed)) => {
|
||||
Ok(Ok(_)) => (),
|
||||
Ok(Err(crate::store::StoreError::AuthenticationFailed)) => {
|
||||
return Ok(Err(UpdateUsernameError::Invalid));
|
||||
}
|
||||
Err(BlockingError::Error(crate::store::StoreError::InUse)) => {
|
||||
Ok(Err(crate::store::StoreError::InUse)) => {
|
||||
return Ok(Err(UpdateUsernameError::UsernameTaken));
|
||||
}
|
||||
Ok(Err(e)) => return Err(e.into()),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
|
||||
|
|
|
@ -70,11 +70,11 @@ pub struct State {
|
|||
|
||||
impl State {
|
||||
pub async fn by_username(&self, username: String) -> Result<Option<User>, Error> {
|
||||
Ok(self.user_store.user_by_username(username).await?)
|
||||
Ok(self.user_store.user_by_username(username).await??)
|
||||
}
|
||||
|
||||
pub async fn suspend(&self, user_id: Uuid) -> Result<(), Error> {
|
||||
Ok(self.user_store.suspend(user_id).await?)
|
||||
Ok(self.user_store.suspend(user_id).await??)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,37 +125,30 @@ impl std::fmt::Debug for State {
|
|||
|
||||
fn to_cookie_page(state: &State) -> HttpResponse {
|
||||
HttpResponse::SeeOther()
|
||||
.header(LOCATION, state.pages.cookies_path())
|
||||
.insert_header((LOCATION, state.pages.cookies_path()))
|
||||
.finish()
|
||||
}
|
||||
|
||||
fn to_register(state: &State) -> HttpResponse {
|
||||
HttpResponse::SeeOther()
|
||||
.header(LOCATION, state.pages.register_path())
|
||||
.insert_header((LOCATION, state.pages.register_path()))
|
||||
.finish()
|
||||
}
|
||||
|
||||
fn to_account_page(state: &State) -> HttpResponse {
|
||||
HttpResponse::SeeOther()
|
||||
.header(LOCATION, state.pages.accounts_path())
|
||||
.insert_header((LOCATION, state.pages.accounts_path()))
|
||||
.finish()
|
||||
}
|
||||
|
||||
fn to_home(state: &State) -> HttpResponse {
|
||||
HttpResponse::SeeOther()
|
||||
.header(LOCATION, state.pages.home_path())
|
||||
.insert_header((LOCATION, state.pages.home_path()))
|
||||
.finish()
|
||||
}
|
||||
|
||||
impl<E> From<actix_web::error::BlockingError<E>> for Error
|
||||
where
|
||||
Error: From<E>,
|
||||
E: std::fmt::Debug,
|
||||
{
|
||||
fn from(e: actix_web::error::BlockingError<E>) -> Self {
|
||||
match e {
|
||||
actix_web::error::BlockingError::Error(e) => e.into(),
|
||||
_ => Error::Blocking,
|
||||
}
|
||||
impl From<actix_web::error::BlockingError> for Error {
|
||||
fn from(_: actix_web::error::BlockingError) -> Self {
|
||||
Self::Blocking
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,10 @@ impl UserStore {
|
|||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn exec<T>(&self, operation: T) -> Result<T::Output, BlockingError<StoreError>>
|
||||
pub(crate) async fn exec<T>(
|
||||
&self,
|
||||
operation: T,
|
||||
) -> Result<Result<T::Output, StoreError>, BlockingError>
|
||||
where
|
||||
T: operations::Operation + Send + 'static,
|
||||
{
|
||||
|
@ -114,7 +117,7 @@ impl UserStore {
|
|||
actix_web::web::block(move || operation.exec(&store)).await
|
||||
}
|
||||
|
||||
pub(crate) async fn suspend(&self, id: Uuid) -> Result<(), BlockingError<StoreError>> {
|
||||
pub(crate) async fn suspend(&self, id: Uuid) -> Result<Result<(), StoreError>, BlockingError> {
|
||||
let store = self.clone();
|
||||
|
||||
actix_web::web::block(move || {
|
||||
|
@ -150,7 +153,7 @@ impl UserStore {
|
|||
pub(crate) async fn user_by_username(
|
||||
&self,
|
||||
username: String,
|
||||
) -> Result<Option<User>, BlockingError<StoreError>> {
|
||||
) -> Result<Result<Option<User>, StoreError>, BlockingError> {
|
||||
let store = self.clone();
|
||||
actix_web::web::block(move || {
|
||||
let ivec_opt = store.tree.get(username_key(&username))?;
|
||||
|
@ -173,7 +176,7 @@ impl UserStore {
|
|||
pub(crate) async fn user_by_id(
|
||||
&self,
|
||||
id: Uuid,
|
||||
) -> Result<Option<User>, BlockingError<StoreError>> {
|
||||
) -> Result<Result<Option<User>, StoreError>, BlockingError> {
|
||||
let store = self.clone();
|
||||
actix_web::web::block(move || {
|
||||
let ivec_opt = store.tree.get(user_id_username_key(id))?;
|
||||
|
|
|
@ -7,18 +7,19 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.1.1"
|
||||
actix-web = "3.3.2"
|
||||
actix-rt = "2.1.0"
|
||||
actix-web = "4.0.0-beta.5"
|
||||
activitystreams = "0.7.0-alpha.9"
|
||||
activitystreams-ext = "0.1.0-alpha.2"
|
||||
awc = "3.0.0-beta.4"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
hyaenidae-content = { version = "0.1.0", path = "../content" }
|
||||
log = "0.4.11"
|
||||
mime = "0.3.16"
|
||||
rand = "0.7.0"
|
||||
rsa = "0.3.0"
|
||||
rsa-magic-public-key = "0.2.1"
|
||||
rsa-pem = "0.2.0"
|
||||
rand = "0.8.0"
|
||||
rsa = "0.4.0"
|
||||
rsa-magic-public-key = "0.3.0"
|
||||
rsa-pem = "0.3.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
sled = "0.34.6"
|
||||
|
|
|
@ -49,8 +49,7 @@ pub(crate) fn application(
|
|||
.map(|s| s.to_owned());
|
||||
let description = application
|
||||
.summary()
|
||||
.and_then(|s| s.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|s| s.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
let public_key = application.ext_one.public_key.public_key_pem.clone();
|
||||
let public_key_id = application.ext_one.public_key.id.clone();
|
||||
let published = application
|
||||
|
@ -157,8 +156,7 @@ pub(crate) fn update_application(
|
|||
.map(|s| s.to_owned());
|
||||
let description = application
|
||||
.summary()
|
||||
.and_then(|s| s.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|s| s.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
let public_key_id = application.ext_one.public_key.id.clone();
|
||||
let public_key = application.ext_one.public_key.public_key_pem.clone();
|
||||
let updated = application.updated().req("updated")?.into();
|
||||
|
|
|
@ -20,7 +20,8 @@ pub(crate) fn flag(
|
|||
require_federation(key_owner, actor, ctx)?;
|
||||
|
||||
let object = flag.object().as_single_id().req("flag object id")?;
|
||||
let report_note = flag.content().req("content")?.as_single_xsd_string();
|
||||
let content = flag.content().req("content")?;
|
||||
let report_note = content.as_single_xsd_string();
|
||||
|
||||
let actor_id = recover!(actor, ctx.apub.id_for_apub(actor)?);
|
||||
let actor_id = actor_id.server().req("flag actor id as server id")?;
|
||||
|
|
|
@ -20,11 +20,8 @@ pub(crate) fn like(
|
|||
require_federation(key_owner, actor, ctx)?;
|
||||
|
||||
let object = like.object().as_single_id().req("like object id")?;
|
||||
let react = like
|
||||
.content()
|
||||
.req("content")?
|
||||
.as_single_xsd_string()
|
||||
.req("content string")?;
|
||||
let content = like.content().req("content")?;
|
||||
let react = content.as_single_xsd_string().req("content string")?;
|
||||
let published = like.published().req("published")?;
|
||||
|
||||
let actor_id = recover!(actor, ctx.apub.id_for_apub(actor)?);
|
||||
|
|
|
@ -79,11 +79,8 @@ pub(super) fn note(
|
|||
let in_reply_to = in_reply_to.as_single_id().req("in reply to id")?;
|
||||
let in_reply_to = recover!(in_reply_to, ctx.apub.id_for_apub(in_reply_to)?);
|
||||
|
||||
let body = note
|
||||
.content()
|
||||
.req("content")?
|
||||
.as_single_xsd_string()
|
||||
.req("content string")?;
|
||||
let content = note.content().req("content")?;
|
||||
let body = content.as_single_xsd_string().req("content string")?;
|
||||
|
||||
if let Some(submission_id) = in_reply_to.submission() {
|
||||
return Ok(Ok(Box::new(CreateComment {
|
||||
|
@ -125,12 +122,10 @@ pub(super) fn note(
|
|||
|
||||
let title = note
|
||||
.summary()
|
||||
.and_then(|s| s.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|s| s.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
let description = note
|
||||
.content()
|
||||
.and_then(|c| c.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|c| c.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
|
||||
let mut missing_files = vec![];
|
||||
let mut existing_files = vec![];
|
||||
|
@ -347,8 +342,7 @@ pub(super) fn update_note(
|
|||
|
||||
let body = note
|
||||
.content()
|
||||
.and_then(|c| c.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|c| c.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
|
||||
return Ok(Ok(Box::new(UpdateComment {
|
||||
update_apub_id: Some(update_id.to_owned()),
|
||||
|
@ -372,12 +366,10 @@ pub(super) fn update_note(
|
|||
|
||||
let title = note
|
||||
.summary()
|
||||
.and_then(|s| s.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|s| s.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
let description = note
|
||||
.content()
|
||||
.and_then(|c| c.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|c| c.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
let published = note.published().req("published")?;
|
||||
|
||||
let mut missing_files = vec![];
|
||||
|
|
|
@ -92,8 +92,7 @@ pub(crate) fn person(
|
|||
.map(|s| s.to_owned());
|
||||
let description = person
|
||||
.summary()
|
||||
.and_then(|s| s.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|s| s.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
let public_key = person.ext_one.public_key.public_key_pem.clone();
|
||||
let public_key_id = person.ext_one.public_key.id.clone();
|
||||
let published = person.published().req("published")?.into();
|
||||
|
@ -219,8 +218,7 @@ pub(crate) fn update_person(
|
|||
.map(|s| s.to_owned());
|
||||
let description = person
|
||||
.summary()
|
||||
.and_then(|s| s.as_single_xsd_string())
|
||||
.map(|s| s.to_owned());
|
||||
.and_then(|s| s.as_single_xsd_string().map(|s| s.to_owned()));
|
||||
let public_key_id = person.ext_one.public_key.id.clone();
|
||||
let public_key = person.ext_one.public_key.public_key_pem.clone();
|
||||
let updated = person.updated().map(|u| u.into()).req("updated")?;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use activitystreams::base::AnyBase;
|
||||
use actix_rt::Arbiter;
|
||||
use actix_web::{client::Client, dev::Payload, HttpRequest};
|
||||
use actix_rt::ArbiterHandle;
|
||||
use actix_web::{dev::Payload, HttpRequest};
|
||||
use awc::Client;
|
||||
use hyaenidae_content::NodeView;
|
||||
use sled::Db;
|
||||
use std::{borrow::Cow, fmt, sync::Arc};
|
||||
|
@ -164,7 +165,7 @@ pub struct State {
|
|||
pub spawner: Arc<dyn Spawner + Send + Sync>,
|
||||
pub url_for: Arc<dyn UrlFor + Send + Sync>,
|
||||
pub content_config: ContentConfig,
|
||||
pub arbiter: Arbiter,
|
||||
pub arbiter: ArbiterHandle,
|
||||
_db: Db,
|
||||
}
|
||||
|
||||
|
@ -176,7 +177,7 @@ impl State {
|
|||
spawner: impl Spawner + Send + Sync + 'static,
|
||||
url_for: impl UrlFor + Send + Sync + 'static,
|
||||
content_config: ContentConfig,
|
||||
arbiter: Arbiter,
|
||||
arbiter: ArbiterHandle,
|
||||
db: Db,
|
||||
) -> Result<Arc<Self>, sled::Error> {
|
||||
Ok(Arc::new(State {
|
||||
|
@ -284,9 +285,9 @@ impl State {
|
|||
None => panic!("Failed to generate server actor"),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(()) as Result<(), Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -304,9 +305,9 @@ impl State {
|
|||
ctx.spawn_blocking(move || context_clone.deliver(&*outbound));
|
||||
Ok(id)
|
||||
}
|
||||
None => Ok(None),
|
||||
None => Ok(None) as Result<_, Error>,
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(opt)
|
||||
}
|
||||
|
@ -333,7 +334,7 @@ impl State {
|
|||
|
||||
Err(Error::Invalid)
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -386,11 +387,11 @@ impl State {
|
|||
if object.is_none() {}
|
||||
Ok(object)
|
||||
} else {
|
||||
Ok(None)
|
||||
Ok(None) as Result<_, Error>
|
||||
}
|
||||
}
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(opt)
|
||||
}
|
||||
|
@ -433,9 +434,9 @@ impl State {
|
|||
let apub_image = apub_image.into_any_base()?;
|
||||
ctx.apub.store_object(&apub_image)?;
|
||||
|
||||
Ok(file.id())
|
||||
Ok(file.id()) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(file_id)
|
||||
}
|
||||
|
@ -462,9 +463,9 @@ impl State {
|
|||
let file = ctx.store.files.create(&file_source)?;
|
||||
files.push(file.id());
|
||||
}
|
||||
Ok(files)
|
||||
Ok(files) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(files)
|
||||
}
|
||||
|
@ -478,7 +479,7 @@ impl State {
|
|||
let file = actix_web::web::block(move || {
|
||||
ctx.store.files.by_id(file_id)?.req("File in delete_file")
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
let store::FileSource::PictRs(image) = file.source();
|
||||
|
||||
|
@ -487,7 +488,11 @@ impl State {
|
|||
.await?;
|
||||
|
||||
let ctx = self.clone();
|
||||
actix_web::web::block(move || Ok(ctx.store.files.delete(file_id)?)).await?;
|
||||
actix_web::web::block(move || {
|
||||
let undo_file = ctx.store.files.delete(file_id)?;
|
||||
Ok(undo_file) as Result<Option<_>, Error>
|
||||
})
|
||||
.await??;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -609,13 +614,13 @@ impl State {
|
|||
where
|
||||
F: FnOnce() + Send + 'static,
|
||||
{
|
||||
self.arbiter.send(Box::pin(async move {
|
||||
self.arbiter.spawn(async move {
|
||||
let _ = actix_web::web::block(move || {
|
||||
(f)();
|
||||
Ok(()) as Result<(), ()>
|
||||
})
|
||||
.await;
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -636,11 +641,8 @@ impl From<activitystreams::error::DomainError> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<actix_web::error::BlockingError<Error>> for Error {
|
||||
fn from(e: actix_web::error::BlockingError<Error>) -> Self {
|
||||
match e {
|
||||
actix_web::error::BlockingError::Error(e) => e,
|
||||
_ => Error::Panic,
|
||||
}
|
||||
impl From<actix_web::error::BlockingError> for Error {
|
||||
fn from(_: actix_web::error::BlockingError) -> Self {
|
||||
Self::Panic
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use actix_web::{body::BodyStream, client::Client, dev::Payload, HttpRequest, HttpResponse};
|
||||
use actix_web::{body::BodyStream, dev::Payload, HttpRequest, HttpResponse};
|
||||
use awc::Client;
|
||||
use std::{fmt, sync::Arc, time::Duration};
|
||||
use url::Url;
|
||||
|
||||
|
@ -196,7 +197,7 @@ impl State {
|
|||
.request_from(url.as_str(), req.head())
|
||||
.timeout(Duration::from_secs(30));
|
||||
let client_req = if let Some(addr) = req.head().peer_addr {
|
||||
client_req.header("X-Forwarded-For", addr.to_string())
|
||||
client_req.insert_header(("X-Forwarded-For", addr.to_string()))
|
||||
} else {
|
||||
client_req
|
||||
};
|
||||
|
@ -206,7 +207,7 @@ impl State {
|
|||
let mut client_res = HttpResponse::build(res.status());
|
||||
|
||||
for (name, value) in res.headers().iter().filter(|(h, _)| *h != "connection") {
|
||||
client_res.header(name.clone(), value.clone());
|
||||
client_res.insert_header((name.clone(), value.clone()));
|
||||
}
|
||||
|
||||
Ok(client_res.body(BodyStream::new(res)))
|
||||
|
@ -245,7 +246,7 @@ impl State {
|
|||
.timeout(Duration::from_secs(30));
|
||||
|
||||
let client_req = if let Some(addr) = req.head().peer_addr {
|
||||
client_req.header("X-Forwarded-For", addr.to_string())
|
||||
client_req.insert_header(("X-Forwarded-For", addr.to_string()))
|
||||
} else {
|
||||
client_req
|
||||
};
|
||||
|
|
|
@ -203,7 +203,7 @@ async fn account_page(
|
|||
|
||||
async fn to_account() -> HttpResponse {
|
||||
HttpResponse::SeeOther()
|
||||
.header(LOCATION, Pages.accounts_path())
|
||||
.insert_header((LOCATION, Pages.accounts_path()))
|
||||
.finish()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@ use crate::{
|
|||
views::{OwnedProfileView, OwnedSubmissionView},
|
||||
ActixLoader, State,
|
||||
};
|
||||
use actix_web::{client::Client, dev::Payload, web, FromRequest, HttpRequest, HttpResponse, Scope};
|
||||
use actix_web::{dev::Payload, web, FromRequest, HttpRequest, HttpResponse, Scope};
|
||||
use actix_webfinger::Webfinger;
|
||||
use awc::Client;
|
||||
use chrono::{DateTime, Utc};
|
||||
use futures::future::LocalBoxFuture;
|
||||
use hyaenidae_accounts::{State as AccountState, User};
|
||||
|
@ -160,7 +161,7 @@ async fn block_server(
|
|||
|
||||
let fallible = || async move {
|
||||
let servers = state.profiles.store.servers.clone();
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await?;
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await??;
|
||||
|
||||
state
|
||||
.profiles
|
||||
|
@ -188,10 +189,11 @@ async fn unblock_server(
|
|||
|
||||
let fallible = || async move {
|
||||
let servers = state.profiles.store.servers.clone();
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await?;
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await??;
|
||||
|
||||
let blocks = state.profiles.store.view.server_blocks.clone();
|
||||
let block_id = web::block(move || blocks.by_forward(server_id, self_server)?.req()).await?;
|
||||
let block_id =
|
||||
web::block(move || blocks.by_forward(server_id, self_server)?.req()).await??;
|
||||
|
||||
state
|
||||
.profiles
|
||||
|
@ -219,7 +221,7 @@ async fn follow_server(
|
|||
|
||||
let fallible = || async move {
|
||||
let servers = state.profiles.store.servers.clone();
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await?;
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await??;
|
||||
|
||||
state
|
||||
.profiles
|
||||
|
@ -250,7 +252,7 @@ async fn accept_follow(
|
|||
|
||||
let fallible = || async move {
|
||||
let servers = state.profiles.store.servers.clone();
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await?;
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await??;
|
||||
|
||||
let federation_requests = state.profiles.store.view.server_follow_requests.clone();
|
||||
let freq_id = web::block(move || {
|
||||
|
@ -258,7 +260,7 @@ async fn accept_follow(
|
|||
.by_forward(self_server, server_id)?
|
||||
.req()
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
state
|
||||
.profiles
|
||||
|
@ -286,7 +288,7 @@ async fn reject_follow(
|
|||
|
||||
let fallible = || async move {
|
||||
let servers = state.profiles.store.servers.clone();
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await?;
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await??;
|
||||
|
||||
let federation_requests = state.profiles.store.view.server_follow_requests.clone();
|
||||
let freq_id = web::block(move || {
|
||||
|
@ -294,7 +296,7 @@ async fn reject_follow(
|
|||
.by_forward(self_server, server_id)?
|
||||
.req()
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
state
|
||||
.profiles
|
||||
|
@ -322,7 +324,7 @@ async fn cancel_request(
|
|||
|
||||
let fallible = || async move {
|
||||
let servers = state.profiles.store.servers.clone();
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await?;
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await??;
|
||||
|
||||
let federation_requests = state.profiles.store.view.server_follow_requests.clone();
|
||||
let freq_id = web::block(move || {
|
||||
|
@ -330,7 +332,7 @@ async fn cancel_request(
|
|||
.by_forward(server_id, self_server)?
|
||||
.req()
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
state
|
||||
.profiles
|
||||
|
@ -358,15 +360,15 @@ async fn defederate(
|
|||
|
||||
let fallible = || async move {
|
||||
let servers = state.profiles.store.servers.clone();
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await?;
|
||||
let self_server = web::block(move || servers.get_self()?.req()).await??;
|
||||
|
||||
let federations = state.profiles.store.view.server_follows.clone();
|
||||
let outbound_follow_id =
|
||||
web::block(move || Ok(federations.by_forward(server_id, self_server)?)).await?;
|
||||
web::block(move || federations.by_forward(server_id, self_server)).await??;
|
||||
|
||||
let federations = state.profiles.store.view.server_follows.clone();
|
||||
let inbound_follow_id =
|
||||
web::block(move || Ok(federations.by_forward(self_server, server_id)?)).await?;
|
||||
web::block(move || federations.by_forward(self_server, server_id)).await??;
|
||||
|
||||
if let Some(follow_id) = outbound_follow_id {
|
||||
state
|
||||
|
@ -872,9 +874,9 @@ impl FederationView {
|
|||
discover_value: None,
|
||||
discover_error: None,
|
||||
query,
|
||||
})
|
||||
}) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(view)
|
||||
}
|
||||
|
@ -936,7 +938,7 @@ async fn view_report(
|
|||
) -> Result<HttpResponse, Error> {
|
||||
let report_id = report.into_inner();
|
||||
let report_store = state.profiles.store.reports.clone();
|
||||
let report = web::block(move || report_store.by_id(report_id)?.req()).await?;
|
||||
let report = web::block(move || report_store.by_id(report_id)?.req()).await??;
|
||||
|
||||
let report_view = ReportView::new(report, state).await?;
|
||||
|
||||
|
@ -979,7 +981,7 @@ async fn close_report(
|
|||
) -> Result<HttpResponse, Error> {
|
||||
let report_id = report.into_inner();
|
||||
let report_store = state.profiles.store.reports.clone();
|
||||
let report = web::block(move || report_store.by_id(report_id)?.req()).await?;
|
||||
let report = web::block(move || report_store.by_id(report_id)?.req()).await??;
|
||||
|
||||
let form = form.into_inner();
|
||||
|
||||
|
@ -1032,16 +1034,16 @@ async fn handle_report(
|
|||
ReportKind::Submission => {
|
||||
let submission_id = report.item();
|
||||
let submission_store = state.profiles.store.submissions.clone();
|
||||
let submission = web::block(move || Ok(submission_store.by_id(submission_id)?))
|
||||
.await?
|
||||
let submission = web::block(move || submission_store.by_id(submission_id))
|
||||
.await??
|
||||
.req()?;
|
||||
submission.profile_id()
|
||||
}
|
||||
ReportKind::Comment => {
|
||||
let comment_id = report.item();
|
||||
let comment_store = state.profiles.store.comments.clone();
|
||||
let comment = web::block(move || Ok(comment_store.by_id(comment_id)?))
|
||||
.await?
|
||||
let comment = web::block(move || comment_store.by_id(comment_id))
|
||||
.await??
|
||||
.req()?;
|
||||
comment.profile_id()
|
||||
}
|
||||
|
@ -1049,8 +1051,8 @@ async fn handle_report(
|
|||
};
|
||||
|
||||
let profile_store = state.profiles.store.profiles.clone();
|
||||
let profile = web::block(move || Ok(profile_store.by_id(profile_id)?))
|
||||
.await?
|
||||
let profile = web::block(move || profile_store.by_id(profile_id))
|
||||
.await??
|
||||
.req()?;
|
||||
|
||||
use hyaenidae_profiles::apub::actions::SuspendProfile;
|
||||
|
@ -1061,7 +1063,7 @@ async fn handle_report(
|
|||
let profiles = web::block(move || {
|
||||
let profiles: Vec<_> = profile_store.for_local(user_id).collect();
|
||||
|
||||
Ok(profiles) as Result<Vec<_>, Error>
|
||||
profiles
|
||||
})
|
||||
.await?;
|
||||
for profile in profiles {
|
||||
|
@ -1257,7 +1259,7 @@ impl ReportView {
|
|||
|
||||
let author = if let Some(author_id) = report.reporter_profile() {
|
||||
let store = state.profiles.clone();
|
||||
let author = web::block(move || store.store.profiles.by_id(author_id)?.req()).await?;
|
||||
let author = web::block(move || store.store.profiles.by_id(author_id)?.req()).await??;
|
||||
|
||||
let mut file_ids = vec![];
|
||||
file_ids.extend(author.icon());
|
||||
|
@ -1274,7 +1276,7 @@ impl ReportView {
|
|||
|
||||
Ok(files) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Some(author)
|
||||
} else {
|
||||
|
@ -1286,7 +1288,7 @@ impl ReportView {
|
|||
let profile_id = report.item();
|
||||
let store = state.profiles.clone();
|
||||
let profile =
|
||||
web::block(move || store.store.profiles.by_id(profile_id)?.req()).await?;
|
||||
web::block(move || store.store.profiles.by_id(profile_id)?.req()).await??;
|
||||
|
||||
let store = state.profiles.clone();
|
||||
let mut file_ids = vec![];
|
||||
|
@ -1303,7 +1305,7 @@ impl ReportView {
|
|||
|
||||
Ok(files) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
ReportedItem::Profile(profile)
|
||||
}
|
||||
|
@ -1311,12 +1313,13 @@ impl ReportView {
|
|||
let submission_id = report.item();
|
||||
let store = state.profiles.clone();
|
||||
let submission =
|
||||
web::block(move || store.store.submissions.by_id(submission_id)?.req()).await?;
|
||||
web::block(move || store.store.submissions.by_id(submission_id)?.req())
|
||||
.await??;
|
||||
|
||||
let profile_id = submission.profile_id();
|
||||
let store = state.profiles.clone();
|
||||
let author =
|
||||
web::block(move || store.store.profiles.by_id(profile_id)?.req()).await?;
|
||||
web::block(move || store.store.profiles.by_id(profile_id)?.req()).await??;
|
||||
|
||||
let store = state.profiles.clone();
|
||||
let mut file_ids: Vec<Uuid> = submission.files().iter().copied().collect();
|
||||
|
@ -1333,7 +1336,7 @@ impl ReportView {
|
|||
|
||||
Ok(files) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
ReportedItem::Submission { submission, author }
|
||||
}
|
||||
|
@ -1341,12 +1344,12 @@ impl ReportView {
|
|||
let comment_id = report.item();
|
||||
let store = state.profiles.clone();
|
||||
let comment =
|
||||
web::block(move || store.store.comments.by_id(comment_id)?.req()).await?;
|
||||
web::block(move || store.store.comments.by_id(comment_id)?.req()).await??;
|
||||
|
||||
let profile_id = comment.profile_id();
|
||||
let store = state.profiles.clone();
|
||||
let author =
|
||||
web::block(move || store.store.profiles.by_id(profile_id)?.req()).await?;
|
||||
web::block(move || store.store.profiles.by_id(profile_id)?.req()).await??;
|
||||
|
||||
let store = state.profiles.clone();
|
||||
let mut file_ids = vec![];
|
||||
|
@ -1363,7 +1366,7 @@ impl ReportView {
|
|||
|
||||
Ok(files) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
ReportedItem::Comment { comment, author }
|
||||
}
|
||||
|
@ -1422,7 +1425,7 @@ impl ServerView {
|
|||
let id = servers.get_self()?.req()?;
|
||||
servers.by_id(id)?.req()
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(ServerView {
|
||||
server: self_server,
|
||||
|
@ -1694,7 +1697,7 @@ impl ReportsView {
|
|||
page_source(&query, "closed"),
|
||||
);
|
||||
|
||||
Ok(ReportsView {
|
||||
ReportsView {
|
||||
query,
|
||||
open_reports,
|
||||
closed_reports,
|
||||
|
@ -1703,7 +1706,7 @@ impl ReportsView {
|
|||
submissions,
|
||||
comments,
|
||||
files,
|
||||
}) as Result<_, Error>
|
||||
}
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
@ -1734,7 +1737,7 @@ impl FromRequest for Admin {
|
|||
|
||||
let admin = state.admin.clone();
|
||||
let user_id = user.id();
|
||||
if web::block(move || admin.is_admin(user_id)).await? {
|
||||
if web::block(move || admin.is_admin(user_id)).await?? {
|
||||
return Ok(Admin(user));
|
||||
}
|
||||
|
||||
|
@ -1844,7 +1847,7 @@ async fn resolve_report(
|
|||
.await?;
|
||||
|
||||
let admin = state.admin.clone();
|
||||
actix_web::web::block(move || admin.resolve_report(admin_id, report_id)).await?;
|
||||
actix_web::web::block(move || admin.resolve_report(admin_id, report_id)).await??;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
22
src/apub.rs
22
src/apub.rs
|
@ -80,7 +80,7 @@ impl SignatureVerify for RsaVerifier {
|
|||
return Err(VerifyError);
|
||||
}
|
||||
|
||||
web::block(move || {
|
||||
let res = web::block(move || {
|
||||
let public_key = if let Some(key) = apub.public_key_for_id(&key_id)? {
|
||||
key
|
||||
} else {
|
||||
|
@ -103,11 +103,19 @@ impl SignatureVerify for RsaVerifier {
|
|||
|
||||
Ok(true) as Result<bool, anyhow::Error>
|
||||
})
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to verify signature: {}", e);
|
||||
VerifyError
|
||||
})
|
||||
.await;
|
||||
|
||||
match res {
|
||||
Ok(Ok(item)) => Ok(item),
|
||||
Ok(Err(e)) => {
|
||||
log::error!("Failed to verify signature: {}", e);
|
||||
Err(VerifyError)
|
||||
}
|
||||
Err(_) => {
|
||||
log::error!("Panic while verifying signature");
|
||||
Err(VerifyError)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +153,7 @@ async fn serve_object(
|
|||
let object_id = path.into_inner();
|
||||
|
||||
let apub = state.apub.clone();
|
||||
let url = match web::block(move || apub.id_for_uuid(object_id)).await? {
|
||||
let url = match web::block(move || apub.id_for_uuid(object_id)).await?? {
|
||||
Some(url) => url,
|
||||
None => return Ok(crate::to_404()),
|
||||
};
|
||||
|
|
|
@ -75,7 +75,7 @@ impl ViewBrowseState {
|
|||
|
||||
let page = browse_page(viewer, can_view_sensitive, &store, &mut cache, source);
|
||||
|
||||
Ok(ViewBrowseState {
|
||||
ViewBrowseState {
|
||||
cache,
|
||||
submissions: page.items,
|
||||
next_id: page.next,
|
||||
|
@ -83,7 +83,7 @@ impl ViewBrowseState {
|
|||
reset: page.reset,
|
||||
logged_in: viewer.is_some(),
|
||||
path,
|
||||
})
|
||||
}
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ async fn prepare_view(
|
|||
|
||||
Ok((cache, author)) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
let submission = comment.submission_id();
|
||||
|
||||
|
@ -628,7 +628,7 @@ impl ReportView {
|
|||
input_error: None,
|
||||
}) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(view)
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ impl CommentNode {
|
|||
|
||||
Ok((node, cache)) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(tup)
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ impl CommentNode {
|
|||
Self::do_from_root(comment, author, self_profile, &mut cache, &store).req()?;
|
||||
Ok((node, cache)) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(tup)
|
||||
}
|
||||
|
|
|
@ -69,11 +69,8 @@ impl From<hyaenidae_profiles::apub::StoreError> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<actix_web::error::BlockingError<Error>> for Error {
|
||||
fn from(e: actix_web::error::BlockingError<Error>) -> Self {
|
||||
match e {
|
||||
actix_web::error::BlockingError::Error(e) => e,
|
||||
_ => Error::Panic,
|
||||
}
|
||||
impl From<actix_web::error::BlockingError> for Error {
|
||||
fn from(_: actix_web::error::BlockingError) -> Self {
|
||||
Self::Panic
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ impl ViewFeedState {
|
|||
|
||||
Ok(state) as Result<Self, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(state)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::State;
|
||||
use actix_web::{
|
||||
client::Client, http::StatusCode, web, HttpRequest, HttpResponse, ResponseError, Scope,
|
||||
};
|
||||
use actix_web::{http::StatusCode, web, HttpRequest, HttpResponse, ResponseError, Scope};
|
||||
use awc::Client;
|
||||
use hyaenidae_profiles::pictrs::ImageInfo;
|
||||
use hyaenidae_toolkit::Image;
|
||||
use url::Url;
|
||||
|
|
12
src/jobs.rs
12
src/jobs.rs
|
@ -1,7 +1,7 @@
|
|||
use crate::{Error, OptionExt, State};
|
||||
use activitystreams::base::AnyBase;
|
||||
use actix_rt::Arbiter;
|
||||
use actix_web::client::Client;
|
||||
use awc::Client;
|
||||
use background_jobs::{
|
||||
create_server, memory_storage::Storage, ActixJob, Backoff, MaxRetries, QueueHandle,
|
||||
WorkerConfig,
|
||||
|
@ -209,7 +209,7 @@ impl ActixJob for Deliver {
|
|||
let res = state
|
||||
.client
|
||||
.post(self.url.as_str())
|
||||
.header("Accept", "application/activity+json")
|
||||
.insert_header(("Accept", "application/activity+json"))
|
||||
.content_type("application/activity+json")
|
||||
.signature_with_digest(
|
||||
signature_config(),
|
||||
|
@ -263,7 +263,7 @@ impl ActixJob for DeliverMany {
|
|||
let private_key = apub_store.private_key_for_id(&key_id)?.req()?;
|
||||
Ok((private_key, key_id)) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
for url in self.inboxes {
|
||||
let res = state.state.spawn.0.queue(Deliver {
|
||||
|
@ -340,7 +340,7 @@ impl ActixJob for DownloadApubAnonymous {
|
|||
let mut res = state
|
||||
.client
|
||||
.get(self.url.as_str())
|
||||
.header("Accept", "application/activity+json")
|
||||
.insert_header(("Accept", "application/activity+json"))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("Request: {}", e))?;
|
||||
|
@ -387,14 +387,14 @@ impl ActixJob for DownloadApub {
|
|||
let private_key = apub_store.private_key_for_id(&key_id)?.req()?;
|
||||
Ok((private_key, key_id)) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
let signer = Signer::new(&private_key)?;
|
||||
|
||||
let mut res = state
|
||||
.client
|
||||
.get(self.url.as_str())
|
||||
.header("Accept", "application/activity+json")
|
||||
.insert_header(("Accept", "application/activity+json"))
|
||||
.signature(
|
||||
signature_config(),
|
||||
key_id.to_string(),
|
||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -1,11 +1,11 @@
|
|||
use actix_rt::Arbiter;
|
||||
use actix_rt::ArbiterHandle;
|
||||
use actix_web::{
|
||||
client::Client,
|
||||
dev::HttpResponseBuilder,
|
||||
http::header::{CacheControl, CacheDirective, ContentType, LastModified},
|
||||
middleware::{Compress, Logger},
|
||||
web, App, HttpResponse, HttpServer,
|
||||
};
|
||||
use awc::Client;
|
||||
use hyaenidae_accounts::Auth;
|
||||
use sled::Db;
|
||||
use std::{fmt, sync::Arc, time::SystemTime};
|
||||
|
@ -329,7 +329,7 @@ impl State {
|
|||
base_url: url::Url,
|
||||
pict_rs_upstream: url::Url,
|
||||
content_config: hyaenidae_profiles::ContentConfig,
|
||||
arbiter: Arbiter,
|
||||
arbiter: ArbiterHandle,
|
||||
db: &Db,
|
||||
) -> Result<Self, Error> {
|
||||
let images = images::Images::new(base_url.clone());
|
||||
|
@ -405,13 +405,13 @@ async fn toolkit(
|
|||
|
||||
if let Some(file) = hyaenidae_toolkit::templates::statics::StaticFile::get(&path) {
|
||||
return HttpResponse::Ok()
|
||||
.set(LastModified(SystemTime::clone(&startup).into()))
|
||||
.set(CacheControl(vec![
|
||||
.insert_header(LastModified(SystemTime::clone(&startup).into()))
|
||||
.insert_header(CacheControl(vec![
|
||||
CacheDirective::Public,
|
||||
CacheDirective::MaxAge(365 * DAYS),
|
||||
CacheDirective::Extension("immutable".to_owned(), None),
|
||||
]))
|
||||
.set(ContentType(file.mime.clone()))
|
||||
.insert_header(ContentType(file.mime.clone()))
|
||||
.body(file.content);
|
||||
}
|
||||
|
||||
|
@ -421,13 +421,13 @@ async fn toolkit(
|
|||
async fn statics(path: web::Path<String>, startup: web::Data<SystemTime>) -> HttpResponse {
|
||||
if let Some(file) = templates::statics::StaticFile::get(&path) {
|
||||
return HttpResponse::Ok()
|
||||
.set(LastModified(SystemTime::clone(&startup).into()))
|
||||
.set(CacheControl(vec![
|
||||
.insert_header(LastModified(SystemTime::clone(&startup).into()))
|
||||
.insert_header(CacheControl(vec![
|
||||
CacheDirective::Public,
|
||||
CacheDirective::MaxAge(365 * DAYS),
|
||||
CacheDirective::Extension("immutable".to_owned(), None),
|
||||
]))
|
||||
.set(ContentType(file.mime.clone()))
|
||||
.insert_header(ContentType(file.mime.clone()))
|
||||
.body(file.content);
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,9 @@ fn to_home() -> HttpResponse {
|
|||
}
|
||||
|
||||
fn redirect(path: &str) -> HttpResponse {
|
||||
HttpResponse::SeeOther().header("Location", path).finish()
|
||||
HttpResponse::SeeOther()
|
||||
.insert_header(("Location", path))
|
||||
.finish()
|
||||
}
|
||||
|
||||
async fn not_found(loader: ActixLoader, nav_state: NavState) -> Result<HttpResponse, Error> {
|
||||
|
|
|
@ -62,7 +62,7 @@ impl FromRequest for CurrentSubmission {
|
|||
|
||||
let submission =
|
||||
actix_web::web::block(move || store.store.submissions.by_id(submission_id)?.req())
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(CurrentSubmission(submission))
|
||||
})
|
||||
|
@ -139,7 +139,7 @@ pub(super) struct ProfileData {
|
|||
impl ProfileData {
|
||||
pub(super) fn set_data(id: Uuid, session: &Session) -> Result<(), SessionError> {
|
||||
session
|
||||
.set("profile-data", ProfileData { id })
|
||||
.insert("profile-data", ProfileData { id })
|
||||
.map_err(|_| SessionError::Set)
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ impl ResponseError for ServerError {
|
|||
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
HttpResponse::SeeOther()
|
||||
.header("Location", self.0.clone())
|
||||
.insert_header(("Location", self.0.clone()))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
@ -195,12 +195,11 @@ impl Drop for ProfileDropGuard {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S> for CurrentProfile
|
||||
impl<S, B> Transform<S, ServiceRequest> for CurrentProfile
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = S::Request;
|
||||
type Response = S::Response;
|
||||
type Error = S::Error;
|
||||
type InitError = ();
|
||||
|
@ -212,24 +211,23 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<S, B> Service for ProfileMiddleware<S>
|
||||
impl<S, B> Service<ServiceRequest> for ProfileMiddleware<S>
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = S::Request;
|
||||
type Response = S::Response;
|
||||
type Error = S::Error;
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
|
||||
|
||||
fn poll_ready(
|
||||
&mut self,
|
||||
&self,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Result<(), Self::Error>> {
|
||||
self.1.poll_ready(cx)
|
||||
}
|
||||
|
||||
fn call(&mut self, req: S::Request) -> Self::Future {
|
||||
fn call(&self, req: ServiceRequest) -> Self::Future {
|
||||
let session = req.get_session();
|
||||
|
||||
let (extractor, drop_guard) = profile_extractor();
|
||||
|
@ -239,9 +237,7 @@ where
|
|||
|
||||
let user_fut = Authenticated::extract(&req);
|
||||
|
||||
let req = ServiceRequest::from_parts(req, pl)
|
||||
.map_err(|_| ())
|
||||
.expect("Request has been cloned");
|
||||
let req = ServiceRequest::from_parts(req, pl);
|
||||
let fut = self.1.call(req);
|
||||
|
||||
let state = self.0.clone();
|
||||
|
@ -261,7 +257,7 @@ where
|
|||
})
|
||||
.await
|
||||
{
|
||||
Ok(Some(profile)) => {
|
||||
Ok(Ok(Some(profile))) => {
|
||||
if profile
|
||||
.local_owner()
|
||||
.map(|id| id == user_id)
|
||||
|
@ -270,12 +266,15 @@ where
|
|||
*extractor.0.borrow_mut() = Some(profile);
|
||||
}
|
||||
}
|
||||
Ok(None) => {
|
||||
Ok(Ok(None)) => {
|
||||
log::warn!("No profile found for {}", profile_id);
|
||||
}
|
||||
Err(e) => {
|
||||
Ok(Err(e)) => {
|
||||
log::warn!("Error fetching profile {}: {}", profile_id, e);
|
||||
}
|
||||
Err(_) => {
|
||||
log::warn!("Panic while fetching profile {}", profile_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ impl FromRequest for NavState {
|
|||
banner: None,
|
||||
}) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Some(profile)
|
||||
} else {
|
||||
|
|
|
@ -80,9 +80,9 @@ async fn clear_notifications(
|
|||
reacts.clear(profile_id, None)?;
|
||||
comments.clear(profile_id, None)?;
|
||||
|
||||
Ok(())
|
||||
Ok(()) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(to_notifications_page())
|
||||
}
|
||||
|
@ -96,9 +96,9 @@ async fn clear_comments(
|
|||
let comments = state.profiles.store.view.comments.clone();
|
||||
web::block(move || {
|
||||
comments.clear(profile_id, None)?;
|
||||
Ok(())
|
||||
Ok(()) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(to_notifications_page())
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ async fn accept_all(profile: UserProfile, state: web::Data<State>) -> Result<Htt
|
|||
let profile_id = profile.id();
|
||||
let follow_requests = state.profiles.store.view.follow_request_notifs.clone();
|
||||
let requests: Vec<_> =
|
||||
web::block(move || Ok(follow_requests.for_profile(profile_id).collect())).await?;
|
||||
web::block(move || follow_requests.for_profile(profile_id).collect()).await?;
|
||||
|
||||
let mut unorderd = FuturesUnordered::new();
|
||||
|
||||
|
@ -132,7 +132,7 @@ async fn reject_all(profile: UserProfile, state: web::Data<State>) -> Result<Htt
|
|||
let profile_id = profile.id();
|
||||
let follow_requests = state.profiles.store.view.follow_request_notifs.clone();
|
||||
let requests: Vec<_> =
|
||||
web::block(move || Ok(follow_requests.for_profile(profile_id).collect())).await?;
|
||||
web::block(move || follow_requests.for_profile(profile_id).collect()).await?;
|
||||
|
||||
let mut unorderd = FuturesUnordered::new();
|
||||
|
||||
|
@ -162,9 +162,9 @@ async fn accept_follow_request(
|
|||
Ok(follow_requests
|
||||
.left(freq_id)?
|
||||
.map(|left_id| left_id == profile_id)
|
||||
.unwrap_or(false))
|
||||
.unwrap_or(false)) as Result<bool, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
if !freq_is_valid {
|
||||
return Ok(crate::to_404());
|
||||
|
@ -193,9 +193,9 @@ async fn reject_follow_request(
|
|||
Ok(follow_requests
|
||||
.left(freq_id)?
|
||||
.map(|left_id| left_id == profile_id)
|
||||
.unwrap_or(false))
|
||||
.unwrap_or(false)) as Result<bool, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
if !freq_is_valid {
|
||||
return Ok(crate::to_404());
|
||||
|
@ -219,7 +219,10 @@ async fn remove_comment_notification(
|
|||
let comment_id = comment_id.into_inner();
|
||||
|
||||
let comment_notifs = state.profiles.store.view.comments.clone();
|
||||
web::block(move || Ok(comment_notifs.clear(profile_id, Some(vec![comment_id]))?)).await?;
|
||||
web::block(move || {
|
||||
Ok(comment_notifs.clear(profile_id, Some(vec![comment_id]))?) as Result<_, Error>
|
||||
})
|
||||
.await??;
|
||||
|
||||
Ok(to_notifications_page())
|
||||
}
|
||||
|
@ -497,9 +500,9 @@ impl NotificationsView {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(view)
|
||||
Ok(view) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(view)
|
||||
}
|
||||
|
@ -514,9 +517,9 @@ pub(crate) async fn total_for_profile(profile_id: Uuid, state: &State) -> Result
|
|||
let count = follow_requests.count(profile_id)?
|
||||
+ comments.count(profile_id)?
|
||||
+ reacts.count(profile_id)?;
|
||||
Ok(count)
|
||||
Ok(count) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(count)
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ impl ProfileListState {
|
|||
|
||||
Ok(state) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(state)
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ impl ProfileListState {
|
|||
|
||||
Ok(state) as Result<Self, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(state)
|
||||
}
|
||||
|
|
|
@ -98,8 +98,10 @@ async fn follow(
|
|||
let profile_id = profile.id();
|
||||
|
||||
let blocks = state.profiles.store.view.blocks.clone();
|
||||
let is_blocked =
|
||||
web::block(move || Ok(blocks.by_forward(self_id, profile_id)?.is_some())).await?;
|
||||
let is_blocked = web::block(move || {
|
||||
Ok(blocks.by_forward(self_id, profile_id)?.is_some()) as Result<bool, Error>
|
||||
})
|
||||
.await??;
|
||||
if is_blocked {
|
||||
return Ok(crate::to_404());
|
||||
}
|
||||
|
@ -111,9 +113,9 @@ async fn follow(
|
|||
let exists = follow_requests.by_forward(profile_id, self_id)?.is_some()
|
||||
|| follows.by_forward(profile_id, self_id)?.is_some();
|
||||
|
||||
Ok(exists)
|
||||
Ok(exists) as Result<bool, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
if follow_exists {
|
||||
return Ok(to_profile_page(&handle, &domain));
|
||||
|
@ -150,8 +152,10 @@ async fn unfollow(
|
|||
let profile_id = profile.id();
|
||||
|
||||
let blocks = state.profiles.store.view.blocks.clone();
|
||||
let is_blocked =
|
||||
web::block(move || Ok(blocks.by_forward(self_id, profile_id)?.is_some())).await?;
|
||||
let is_blocked = web::block(move || {
|
||||
Ok(blocks.by_forward(self_id, profile_id)?.is_some()) as Result<bool, Error>
|
||||
})
|
||||
.await??;
|
||||
if is_blocked {
|
||||
return Ok(crate::to_404());
|
||||
}
|
||||
|
@ -163,9 +167,9 @@ async fn unfollow(
|
|||
let follow_request = follow_requests.by_forward(profile_id, self_id)?;
|
||||
let follow = follows.by_forward(profile_id, self_id)?;
|
||||
|
||||
Ok((follow_request, follow))
|
||||
Ok((follow_request, follow)) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
if let Some(follow_request) = follow_request {
|
||||
state
|
||||
|
@ -199,15 +203,19 @@ async fn block(
|
|||
let profile_id = profile.id();
|
||||
|
||||
let blocks = state.profiles.store.view.blocks.clone();
|
||||
let is_blocked =
|
||||
web::block(move || Ok(blocks.by_forward(self_id, profile_id)?.is_some())).await?;
|
||||
let is_blocked = web::block(move || {
|
||||
Ok(blocks.by_forward(self_id, profile_id)?.is_some()) as Result<bool, Error>
|
||||
})
|
||||
.await??;
|
||||
if is_blocked {
|
||||
return Ok(crate::to_404());
|
||||
}
|
||||
|
||||
let blocks = state.profiles.store.view.blocks.clone();
|
||||
let block_exists =
|
||||
web::block(move || Ok(blocks.by_forward(profile_id, self_id)?.is_some())).await?;
|
||||
let block_exists = web::block(move || {
|
||||
Ok(blocks.by_forward(profile_id, self_id)?.is_some()) as Result<bool, Error>
|
||||
})
|
||||
.await??;
|
||||
if block_exists {
|
||||
return Ok(to_profile_page(&handle, &domain));
|
||||
}
|
||||
|
@ -235,7 +243,7 @@ async fn unblock(
|
|||
let profile_id = profile.id();
|
||||
|
||||
let blocks = state.profiles.store.view.blocks.clone();
|
||||
let block = web::block(move || Ok(blocks.by_forward(profile_id, self_id)?)).await?;
|
||||
let block = web::block(move || blocks.by_forward(profile_id, self_id)).await??;
|
||||
if let Some(block) = block {
|
||||
state.profiles.run(DeleteBlock::from_id(block)).await?;
|
||||
}
|
||||
|
@ -304,7 +312,7 @@ impl ReportView {
|
|||
async fn profile_from_id(id: Uuid, state: &State) -> Result<Profile, Error> {
|
||||
let store = state.profiles.clone();
|
||||
|
||||
let profile = web::block(move || store.store.profiles.by_id(id)?.req()).await?;
|
||||
let profile = web::block(move || store.store.profiles.by_id(id)?.req()).await??;
|
||||
|
||||
Ok(profile)
|
||||
}
|
||||
|
@ -319,9 +327,9 @@ async fn profile_from_handle(
|
|||
let profile = web::block(move || {
|
||||
let id = store.store.profiles.by_handle(&handle, &domain)?.req()?;
|
||||
let profile = store.store.profiles.by_id(id)?.req()?;
|
||||
Ok(profile)
|
||||
Ok(profile) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(profile)
|
||||
}
|
||||
|
@ -346,7 +354,7 @@ async fn get_files_for_profile(
|
|||
|
||||
Ok(files) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(files)
|
||||
}
|
||||
|
@ -365,8 +373,10 @@ async fn report_page(
|
|||
let blocks = state.profiles.store.view.blocks.clone();
|
||||
let self_id = self_profile.id();
|
||||
let profile_id = profile.id();
|
||||
let is_blocked =
|
||||
web::block(move || Ok(blocks.by_forward(self_id, profile_id)?.is_some())).await?;
|
||||
let is_blocked = web::block(move || {
|
||||
Ok(blocks.by_forward(self_id, profile_id)?.is_some()) as Result<bool, Error>
|
||||
})
|
||||
.await??;
|
||||
|
||||
if is_blocked {
|
||||
return Ok(crate::to_404());
|
||||
|
@ -449,8 +459,10 @@ async fn report_success_page(
|
|||
let blocks = state.profiles.store.view.blocks.clone();
|
||||
let self_id = self_profile.id();
|
||||
let profile_id = profile.id();
|
||||
let is_blocked =
|
||||
web::block(move || Ok(blocks.by_forward(self_id, profile_id)?.is_some())).await?;
|
||||
let is_blocked = web::block(move || {
|
||||
Ok(blocks.by_forward(self_id, profile_id)?.is_some()) as Result<bool, Error>
|
||||
})
|
||||
.await??;
|
||||
|
||||
if is_blocked {
|
||||
return Ok(crate::to_404());
|
||||
|
@ -478,7 +490,9 @@ pub(super) fn to_change_profile_page() -> HttpResponse {
|
|||
}
|
||||
|
||||
fn redirect(path: &str) -> HttpResponse {
|
||||
HttpResponse::SeeOther().header("Location", path).finish()
|
||||
HttpResponse::SeeOther()
|
||||
.insert_header(("Location", path))
|
||||
.finish()
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Deserialize)]
|
||||
|
@ -583,9 +597,9 @@ async fn do_public_view(
|
|||
.view
|
||||
.blocks
|
||||
.by_forward(self_id, profile_id)?
|
||||
.is_some())
|
||||
.is_some()) as Result<bool, Error>
|
||||
})
|
||||
.await?
|
||||
.await??
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
@ -691,7 +705,7 @@ async fn change_profile_page(
|
|||
|
||||
Ok(profiles) as Result<Vec<_>, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
if profiles.len() == 0 {
|
||||
return Ok(update::to_create());
|
||||
|
|
|
@ -28,8 +28,9 @@ impl SettingStore {
|
|||
.tree
|
||||
.get(profile_id.as_bytes())?
|
||||
.and_then(|ivec| serde_json::from_slice(&ivec).ok()))
|
||||
as Result<Option<_>, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(opt.unwrap_or(Settings {
|
||||
dark: true,
|
||||
|
@ -45,7 +46,7 @@ impl SettingStore {
|
|||
this.tree.insert(profile_id.as_bytes(), vec)?;
|
||||
Ok(()) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ impl ViewProfileState {
|
|||
viewer_exists: viewer.is_some(),
|
||||
}) as Result<ViewProfileState, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(state)
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ impl EditProfileState {
|
|||
|
||||
Ok((icon, banner)) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(Self::new(profile, icon, banner, settings))
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ use crate::{
|
|||
ActixLoader, State,
|
||||
};
|
||||
use actix_session::Session;
|
||||
use actix_web::{client::Client, web, HttpRequest, HttpResponse, Scope};
|
||||
use actix_web::{web, HttpRequest, HttpResponse, Scope};
|
||||
use awc::Client;
|
||||
use hyaenidae_accounts::User;
|
||||
use hyaenidae_profiles::store::Profile;
|
||||
use hyaenidae_toolkit::TextInput;
|
||||
|
|
|
@ -9,7 +9,8 @@ use crate::{
|
|||
views::{OwnedProfileView, OwnedSubmissionView},
|
||||
ActixLoader, State,
|
||||
};
|
||||
use actix_web::{client::Client, web, HttpRequest, HttpResponse, Scope};
|
||||
use actix_web::{web, HttpRequest, HttpResponse, Scope};
|
||||
use awc::Client;
|
||||
use hyaenidae_profiles::{
|
||||
apub::actions::{
|
||||
CreateComment, CreateReport, CreateSubmission, DeleteSubmission, UpdateSubmission,
|
||||
|
@ -120,9 +121,9 @@ impl ReportView {
|
|||
author,
|
||||
error: None,
|
||||
value: None,
|
||||
})
|
||||
}) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(view)
|
||||
}
|
||||
|
@ -345,7 +346,7 @@ impl SubmissionState {
|
|||
|
||||
Ok(files) as Result<HashMap<Uuid, File>, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(SubmissionState {
|
||||
files,
|
||||
|
@ -663,7 +664,7 @@ async fn can_view(
|
|||
can_view_sensitive,
|
||||
)) as Result<Option<()>, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
if opt.is_none() {
|
||||
return Ok(Some(crate::to_404()));
|
||||
|
@ -690,7 +691,7 @@ async fn files_for_submission(
|
|||
|
||||
Ok(cache) as Result<Cache, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(cache)
|
||||
}
|
||||
|
@ -716,9 +717,9 @@ async fn files_for_profile(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(cache)
|
||||
Ok(cache) as Result<_, Error>
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(cache)
|
||||
}
|
||||
|
@ -849,7 +850,7 @@ async fn adjacent_submissions(
|
|||
Ok((next, prev)) as Result<_, Error>
|
||||
}
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok((next, prev))
|
||||
}
|
||||
|
@ -872,7 +873,9 @@ async fn submission_page(
|
|||
|
||||
let poster_id = submission.profile_id();
|
||||
let store = state.profiles.clone();
|
||||
let poster = web::block(move || store.store.profiles.by_id(poster_id)?.req()).await?;
|
||||
let poster =
|
||||
web::block(move || store.store.profiles.by_id(poster_id)?.req() as Result<_, Error>)
|
||||
.await??;
|
||||
|
||||
let cache = Cache::new();
|
||||
let cache = files_for_submission(&submission, cache, &state).await?;
|
||||
|
@ -989,7 +992,9 @@ async fn create_comment(
|
|||
|
||||
let store = state.profiles.clone();
|
||||
let poster_id = submission.profile_id();
|
||||
let poster = web::block(move || store.store.profiles.by_id(poster_id)?.req()).await?;
|
||||
let poster =
|
||||
web::block(move || store.store.profiles.by_id(poster_id)?.req() as Result<_, Error>)
|
||||
.await??;
|
||||
|
||||
let can_view_sensitive = state.settings.for_profile(profile.id()).await?.sensitive;
|
||||
|
||||
|
|
|
@ -48,6 +48,10 @@ impl Resolver for HyaenidaeResolver {
|
|||
Ok(wf) as Result<_, anyhow::Error>
|
||||
})
|
||||
.await
|
||||
.map_err(|_| {
|
||||
log::error!("Panic while finding server actor");
|
||||
ResolveError
|
||||
})?
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to find server actor: {}", e);
|
||||
ResolveError
|
||||
|
@ -73,6 +77,10 @@ impl Resolver for HyaenidaeResolver {
|
|||
Ok(wf) as Result<_, anyhow::Error>
|
||||
})
|
||||
.await
|
||||
.map_err(|_| {
|
||||
log::error!("Panic while finding profile actor");
|
||||
ResolveError
|
||||
})?
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to find profile actor: {}", e);
|
||||
ResolveError
|
||||
|
|
|
@ -8,7 +8,7 @@ build = "src/build.rs"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3.3.2"
|
||||
actix-web = "4.0.0-beta.5"
|
||||
anyhow = "1.0.35"
|
||||
env_logger = "0.8.2"
|
||||
hyaenidae-toolkit = { version = "0.1.0", path = "../toolkit" }
|
||||
|
|
Loading…
Reference in a new issue