fmt
This commit is contained in:
@@ -11,9 +11,9 @@ use axum::{
|
|||||||
extract::FromRequestParts,
|
extract::FromRequestParts,
|
||||||
http::{request::Parts, StatusCode},
|
http::{request::Parts, StatusCode},
|
||||||
};
|
};
|
||||||
use diesel::{pg::PgConnection, prelude::*};
|
|
||||||
use axum_extra::headers::{authorization::Bearer, Authorization};
|
use axum_extra::headers::{authorization::Bearer, Authorization};
|
||||||
use axum_extra::TypedHeader;
|
use axum_extra::TypedHeader;
|
||||||
|
use diesel::{pg::PgConnection, prelude::*};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
@@ -138,7 +138,8 @@ impl FromRequestParts<AppState> for TenantScopedConn {
|
|||||||
async move {
|
async move {
|
||||||
let user = AuthenticatedUser::from_request_parts(parts, &state).await?;
|
let user = AuthenticatedUser::from_request_parts(parts, &state).await?;
|
||||||
let tenant_id = user.tenant_id;
|
let tenant_id = user.tenant_id;
|
||||||
let mut conn = if let Some(holder) = parts.extensions.remove::<TenantConnectionHolder>() {
|
let mut conn = if let Some(holder) = parts.extensions.remove::<TenantConnectionHolder>()
|
||||||
|
{
|
||||||
holder
|
holder
|
||||||
.into_conn()
|
.into_conn()
|
||||||
.ok_or_else(|| AppError::internal("tenant connection unavailable"))?
|
.ok_or_else(|| AppError::internal("tenant connection unavailable"))?
|
||||||
|
|||||||
@@ -1427,14 +1427,9 @@ impl<'a> DocumentsService<'a> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(deleted_at) = document.deleted_at {
|
if let Some(deleted_at) = document.deleted_at {
|
||||||
message.push_str(
|
message.push_str(". Note: the existing document is currently in the trash.");
|
||||||
". Note: the existing document is currently in the trash.",
|
|
||||||
);
|
|
||||||
if let Some(obj) = details.as_object_mut() {
|
if let Some(obj) = details.as_object_mut() {
|
||||||
obj.insert(
|
obj.insert("conflict_document_in_trash".to_string(), Value::Bool(true));
|
||||||
"conflict_document_in_trash".to_string(),
|
|
||||||
Value::Bool(true),
|
|
||||||
);
|
|
||||||
obj.insert(
|
obj.insert(
|
||||||
"conflict_document_deleted_at".to_string(),
|
"conflict_document_deleted_at".to_string(),
|
||||||
Value::String(to_iso(deleted_at)),
|
Value::String(to_iso(deleted_at)),
|
||||||
@@ -1442,11 +1437,9 @@ impl<'a> DocumentsService<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(
|
return Err(AppError::conflict(message)
|
||||||
AppError::conflict(message)
|
|
||||||
.with_code("duplicate_document")
|
.with_code("duplicate_document")
|
||||||
.with_details(details),
|
.with_details(details));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(issued_at) = issued_at_override {
|
if let Some(issued_at) = issued_at_override {
|
||||||
|
|||||||
@@ -98,11 +98,8 @@ impl Worker {
|
|||||||
None => {
|
None => {
|
||||||
warn!(job_id = %job.id, job_type = %job.job_type, "job detached from tenant; marking failed");
|
warn!(job_id = %job.id, job_type = %job.job_type, "job detached from tenant; marking failed");
|
||||||
if let Ok(mut conn) = self.state.db_unscoped() {
|
if let Ok(mut conn) = self.state.db_unscoped() {
|
||||||
let _ = mark_job_failed(
|
let _ =
|
||||||
&mut conn,
|
mark_job_failed(&mut conn, job.id, "job detached from tenant context");
|
||||||
job.id,
|
|
||||||
"job detached from tenant context",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user