mirror of
https://github.com/astro/buzzrelay.git
synced 2024-11-27 22:31:01 +00:00
relay: restore more detailed log output
This commit is contained in:
parent
390f7653fb
commit
7b93419a91
1 changed files with 10 additions and 6 deletions
16
src/relay.rs
16
src/relay.rs
|
@ -62,6 +62,8 @@ struct Tag<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Job {
|
struct Job {
|
||||||
|
post_url: Arc<String>,
|
||||||
|
actor_id: Arc<String>,
|
||||||
body: Arc<Vec<u8>>,
|
body: Arc<Vec<u8>>,
|
||||||
key_id: String,
|
key_id: String,
|
||||||
private_key: Arc<PrivateKey>,
|
private_key: Arc<PrivateKey>,
|
||||||
|
@ -71,8 +73,8 @@ fn spawn_worker(client: Arc<reqwest::Client>, inbox: String) -> Sender<Job> {
|
||||||
let (tx, mut rx) = channel(1024);
|
let (tx, mut rx) = channel(1024);
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
while let Some(Job { key_id, private_key, body }) = rx.next().await {
|
while let Some(Job { post_url, actor_id, key_id, private_key, body }) = rx.next().await {
|
||||||
tracing::debug!("relay to {}", inbox);
|
tracing::debug!("relay {} from {} to {}", post_url, actor_id, inbox);
|
||||||
if let Err(e) = send::send_raw(
|
if let Err(e) = send::send_raw(
|
||||||
&client, &inbox,
|
&client, &inbox,
|
||||||
&key_id, &private_key, body
|
&key_id, &private_key, body
|
||||||
|
@ -117,7 +119,7 @@ pub fn spawn(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let post_url = match post.url {
|
let post_url = match post.url {
|
||||||
Some(url) => url,
|
Some(ref url) => Arc::new(url.to_string()),
|
||||||
// skip reposts
|
// skip reposts
|
||||||
None => {
|
None => {
|
||||||
increment_counter!("relay_posts_total", "action" => "skip");
|
increment_counter!("relay_posts_total", "action" => "skip");
|
||||||
|
@ -131,14 +133,14 @@ pub fn spawn(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let actor_id = actor.uri();
|
let actor_id = Arc::new(actor.uri());
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"type": "Announce",
|
"type": "Announce",
|
||||||
"actor": &actor_id,
|
"actor": **&actor_id,
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"object": &post.uri,
|
"object": &post.uri,
|
||||||
"id": &post_url,
|
"id": **&post_url,
|
||||||
});
|
});
|
||||||
let body = Arc::new(
|
let body = Arc::new(
|
||||||
serde_json::to_vec(&body)
|
serde_json::to_vec(&body)
|
||||||
|
@ -151,6 +153,8 @@ pub fn spawn(
|
||||||
seen_inboxes.insert(inbox.clone());
|
seen_inboxes.insert(inbox.clone());
|
||||||
|
|
||||||
let job = Job {
|
let job = Job {
|
||||||
|
post_url: post_url.clone(),
|
||||||
|
actor_id: actor_id.clone(),
|
||||||
body: body.clone(),
|
body: body.clone(),
|
||||||
key_id: actor.key_id(),
|
key_id: actor.key_id(),
|
||||||
private_key: private_key.clone(),
|
private_key: private_key.clone(),
|
||||||
|
|
Loading…
Reference in a new issue