Better tracing of API endpoints
This commit is contained in:
parent
cbf6c7fe43
commit
236502ad05
|
@ -11,6 +11,7 @@ use crate::service::MagnetarService;
|
|||
use crate::web::auth::MaybeUser;
|
||||
use crate::web::{ApiError, ObjectNotFound};
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_note(
|
||||
Path(id): Path<String>,
|
||||
Query(NoteByIdReq {
|
||||
|
|
|
@ -20,6 +20,7 @@ use std::collections::HashMap;
|
|||
use std::sync::Arc;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_user_info_self(
|
||||
Query(req): Query<Req<GetUserSelf>>,
|
||||
State(service): State<Arc<MagnetarService>>,
|
||||
|
@ -41,6 +42,7 @@ pub async fn handle_user_info_self(
|
|||
Ok(Json(user))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_user_info(
|
||||
Path(id): Path<String>,
|
||||
Query(req): Query<Req<GetUserById>>,
|
||||
|
@ -69,6 +71,7 @@ pub async fn handle_user_info(
|
|||
Ok(Json(user))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_user_info_by_acct(
|
||||
Path(tag_str): Path<String>,
|
||||
Query(req): Query<Req<GetUserByAcct>>,
|
||||
|
@ -102,6 +105,7 @@ pub async fn handle_user_info_by_acct(
|
|||
Ok(Json(user))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_user_by_id_many(
|
||||
Query(ManyUsersByIdReq { id }): Query<Req<GetManyUsersById>>,
|
||||
State(service): State<Arc<MagnetarService>>,
|
||||
|
@ -145,6 +149,7 @@ pub async fn handle_user_by_id_many(
|
|||
Ok(Json(users_ordered))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_notifications(
|
||||
Query(NotificationsReq {
|
||||
ref exclude_types,
|
||||
|
@ -179,6 +184,7 @@ pub async fn handle_notifications(
|
|||
Ok((pagination, Json(notifications)))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_following_self(
|
||||
Query(_): Query<Req<GetFollowingSelf>>,
|
||||
State(service): State<Arc<MagnetarService>>,
|
||||
|
@ -194,6 +200,7 @@ pub async fn handle_following_self(
|
|||
Ok((pagination, Json(users)))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_followers_self(
|
||||
Query(_): Query<Req<GetFollowersSelf>>,
|
||||
State(service): State<Arc<MagnetarService>>,
|
||||
|
@ -209,6 +216,7 @@ pub async fn handle_followers_self(
|
|||
Ok((pagination, Json(users)))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_following(
|
||||
Query(_): Query<Req<GetFollowingById>>,
|
||||
Path(id): Path<String>,
|
||||
|
@ -223,6 +231,7 @@ pub async fn handle_following(
|
|||
Ok((pagination, Json(users)))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_followers(
|
||||
Query(_): Query<Req<GetFollowersById>>,
|
||||
Path(id): Path<String>,
|
||||
|
@ -237,6 +246,7 @@ pub async fn handle_followers(
|
|||
Ok((pagination, Json(users)))
|
||||
}
|
||||
|
||||
#[tracing::instrument(err, skip_all)]
|
||||
pub async fn handle_follow_requests_self(
|
||||
Query(_): Query<Req<GetFollowRequestsSelf>>,
|
||||
State(service): State<Arc<MagnetarService>>,
|
||||
|
|
|
@ -26,7 +26,7 @@ use magnetar_sdk::types::{Id, MmXml};
|
|||
use magnetar_sdk::{mmm, Optional, Packed, Required};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::{join, try_join};
|
||||
use tracing::warn;
|
||||
use tracing::{instrument, warn};
|
||||
use url::Url;
|
||||
|
||||
pub trait UserShapedData<'a>: Send + Sync {
|
||||
|
@ -566,7 +566,10 @@ impl UserModel {
|
|||
ctx: &PackingContext,
|
||||
id: &str,
|
||||
) -> Result<(), ApiError> {
|
||||
if !ctx.is_id_self(id) {
|
||||
if ctx.is_id_self(id) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let profile = self.get_profile_by_id(ctx, id).await?;
|
||||
|
||||
match (&ctx.self_user, &profile.ff_visibility) {
|
||||
|
@ -585,7 +588,6 @@ impl UserModel {
|
|||
))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ impl<T: ?Sized> IntoErrorCode for T {
|
|||
where
|
||||
&'a Self: Into<&'b str>,
|
||||
{
|
||||
ErrorCode(self.into().to_string())
|
||||
ErrorCode(<&Self as Into<&'b str>>::into(self).to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue