lemmy/crates/routes/src/lib.rs
Nutomic a8843335a6
Simplify handling of NotFound SQL errors (fixes #4633) (#5031)
* Simplify handling of NotFound SQL errors (fixes #4633)

* fmt

* wip

* compiling

* clippy

* api tests

* fix
2024-09-23 11:26:50 -04:00

17 lines
593 B
Rust

use lemmy_api_common::{claims::Claims, context::LemmyContext, utils::check_user_valid};
use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::error::LemmyResult;
pub mod feeds;
pub mod images;
pub mod nodeinfo;
pub mod webfinger;
#[tracing::instrument(skip_all)]
async fn local_user_view_from_jwt(jwt: &str, context: &LemmyContext) -> LemmyResult<LocalUserView> {
let local_user_id = Claims::validate(jwt, context).await?;
let local_user_view = LocalUserView::read(&mut context.pool(), local_user_id).await?;
check_user_valid(&local_user_view.person)?;
Ok(local_user_view)
}