Try to be a bit more clear about what object is being delivered

This commit is contained in:
asonix 2022-11-14 19:18:09 -06:00
parent 373072c482
commit 881654fed9
3 changed files with 21 additions and 4 deletions

View file

@ -1,4 +1,7 @@
use crate::{error::Error, jobs::JobState};
use crate::{
error::Error,
jobs::{debug_object, JobState},
};
use activitystreams::iri_string::types::IriString;
use background_jobs::{ActixJob, Backoff};
use std::{future::Future, pin::Pin};
@ -14,7 +17,7 @@ impl std::fmt::Debug for Deliver {
f.debug_struct("Deliver")
.field("to", &self.to.to_string())
.field("activity", &self.data["type"])
.field("object", &self.data["object"]["type"])
.field("object", debug_object(&self.data))
.finish()
}
}

View file

@ -1,6 +1,6 @@
use crate::{
error::Error,
jobs::{Deliver, JobState},
jobs::{debug_object, Deliver, JobState},
};
use activitystreams::iri_string::types::IriString;
use background_jobs::ActixJob;
@ -16,7 +16,7 @@ impl std::fmt::Debug for DeliverMany {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("DeliverMany")
.field("activity", &self.data["type"])
.field("object", &self.data["object"]["type"])
.field("object", debug_object(&self.data))
.finish()
}
}

View file

@ -25,6 +25,20 @@ use background_jobs::{
};
use std::time::Duration;
fn debug_object(activity: &serde_json::Value) -> &serde_json::Value {
let mut object = &activity["object"]["type"];
if object.is_null() {
object = &activity["object"]["id"];
}
if object.is_null() {
object = &activity["object"];
}
object
}
pub(crate) fn create_workers(
state: State,
actors: ActorCache,