From 3358ae0461ef3312037cf694a8201269afd6b53f Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 13 Nov 2022 13:57:52 -0600 Subject: [PATCH] Simplify debug info for jobs --- src/jobs/apub/announce.rs | 2 +- src/jobs/apub/follow.rs | 11 ++++++++++- src/jobs/apub/forward.rs | 11 ++++++++++- src/jobs/apub/reject.rs | 8 +++++++- src/jobs/apub/undo.rs | 12 +++++++++++- src/jobs/deliver.rs | 3 ++- src/jobs/deliver_many.rs | 3 ++- src/requests.rs | 2 +- 8 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/jobs/apub/announce.rs b/src/jobs/apub/announce.rs index d03f48e..26048c1 100644 --- a/src/jobs/apub/announce.rs +++ b/src/jobs/apub/announce.rs @@ -21,7 +21,7 @@ impl std::fmt::Debug for Announce { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Announce") .field("object_id", &self.object_id.to_string()) - .field("actor", &self.actor) + .field("actor_id", &self.actor.id) .finish() } } diff --git a/src/jobs/apub/follow.rs b/src/jobs/apub/follow.rs index e76f0ca..d78b544 100644 --- a/src/jobs/apub/follow.rs +++ b/src/jobs/apub/follow.rs @@ -13,12 +13,21 @@ use activitystreams::{ use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] +#[derive(Clone, serde::Deserialize, serde::Serialize)] pub(crate) struct Follow { input: AcceptedActivities, actor: Actor, } +impl std::fmt::Debug for Follow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Follow") + .field("input", &self.input.id_unchecked()) + .field("actor", &self.actor.id) + .finish() + } +} + impl Follow { pub fn new(input: AcceptedActivities, actor: Actor) -> Self { Follow { input, actor } diff --git a/src/jobs/apub/forward.rs b/src/jobs/apub/forward.rs index e790826..1f72a32 100644 --- a/src/jobs/apub/forward.rs +++ b/src/jobs/apub/forward.rs @@ -8,12 +8,21 @@ use activitystreams::prelude::*; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] +#[derive(Clone, serde::Deserialize, serde::Serialize)] pub(crate) struct Forward { input: AcceptedActivities, actor: Actor, } +impl std::fmt::Debug for Forward { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Forward") + .field("input", &self.input.id_unchecked()) + .field("actor", &self.actor.id) + .finish() + } +} + impl Forward { pub fn new(input: AcceptedActivities, actor: Actor) -> Self { Forward { input, actor } diff --git a/src/jobs/apub/reject.rs b/src/jobs/apub/reject.rs index 43a8553..f6ee0e7 100644 --- a/src/jobs/apub/reject.rs +++ b/src/jobs/apub/reject.rs @@ -7,9 +7,15 @@ use crate::{ use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] +#[derive(Clone, serde::Deserialize, serde::Serialize)] pub(crate) struct Reject(pub(crate) Actor); +impl std::fmt::Debug for Reject { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Reject").field("actor", &self.0.id).finish() + } +} + impl Reject { #[tracing::instrument(name = "Reject", skip(state))] async fn perform(self, state: JobState) -> Result<(), Error> { diff --git a/src/jobs/apub/undo.rs b/src/jobs/apub/undo.rs index e6fd1d1..0359bf2 100644 --- a/src/jobs/apub/undo.rs +++ b/src/jobs/apub/undo.rs @@ -5,15 +5,25 @@ use crate::{ error::Error, jobs::{apub::generate_undo_follow, Deliver, JobState}, }; +use activitystreams::prelude::BaseExt; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] +#[derive(Clone, serde::Deserialize, serde::Serialize)] pub(crate) struct Undo { input: AcceptedActivities, actor: Actor, } +impl std::fmt::Debug for Undo { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Undo") + .field("input", &self.input.id_unchecked()) + .field("actor", &self.actor.id) + .finish() + } +} + impl Undo { pub(crate) fn new(input: AcceptedActivities, actor: Actor) -> Self { Undo { input, actor } diff --git a/src/jobs/deliver.rs b/src/jobs/deliver.rs index eb86ab8..f53d412 100644 --- a/src/jobs/deliver.rs +++ b/src/jobs/deliver.rs @@ -13,7 +13,8 @@ impl std::fmt::Debug for Deliver { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Deliver") .field("to", &self.to.to_string()) - .field("data", &self.data) + .field("activity", &self.data["type"]) + .field("object", &self.data["object"]["type"]) .finish() } } diff --git a/src/jobs/deliver_many.rs b/src/jobs/deliver_many.rs index e37a12d..95a2f7e 100644 --- a/src/jobs/deliver_many.rs +++ b/src/jobs/deliver_many.rs @@ -24,7 +24,8 @@ impl std::fmt::Debug for DeliverMany { ); f.debug_struct("DeliverMany") .field("to", &to) - .field("data", &self.data) + .field("activity", &self.data["type"]) + .field("object", &self.data["object"]["type"]) .finish() } } diff --git a/src/requests.rs b/src/requests.rs index b55da16..98e3a2d 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -354,7 +354,7 @@ impl Requests { #[tracing::instrument( "Deliver to Inbox", skip_all, - fields(inbox = inbox.to_string().as_str(), item) + fields(inbox = inbox.to_string().as_str()) )] pub(crate) async fn deliver(&self, inbox: IriString, item: &T) -> Result<(), Error> where