chore: instrument inbox/outbox

this is where side effects happen, so better keep them under control

also trying out tracing, i should redo how i trace stuff in upub...
This commit is contained in:
əlemi 2024-05-31 14:43:48 +02:00
parent 5b592874cb
commit 876cf19327
3 changed files with 5 additions and 2 deletions

View file

@ -10,6 +10,7 @@ use super::{fetcher::Fetcher, httpsign::HttpSignature};
pub enum Identity {
Anonymous,
Remote {
user: String,
domain: String,
internal: i64,
},
@ -124,11 +125,11 @@ where
.verify(&user.public_key)
{
Ok(true) => {
// TODO can we avoid this extra db rountrip made on each server fetch?
let user = user.id;
let domain = Context::server(&user_id);
// TODO this will fail because we never fetch and insert into instance oops
let internal = model::instance::Entity::domain_to_internal(&domain, ctx.db()).await?;
identity = Identity::Remote { domain, internal };
identity = Identity::Remote { user, domain, internal };
},
Ok(false) => tracing::warn!("invalid signature: {http_signature:?}"),
Err(e) => tracing::error!("error verifying signature: {e}"),

View file

@ -38,6 +38,7 @@ macro_rules! pretty_json {
}
#[tracing::instrument(level = "info", skip(ctx), fields(activity = %activity))]
pub async fn post(
State(ctx): State<Context>,
AuthIdentity(auth): AuthIdentity,

View file

@ -37,6 +37,7 @@ pub async fn page(
.await
}
#[tracing::instrument(level = "info", skip(ctx), fields(activity = %activity))]
pub async fn post(
State(ctx): State<Context>,
Path(id): Path<String>,