Save listeners in db

This commit is contained in:
asonix 2020-03-18 13:56:13 -05:00
parent 4c373e562b
commit 4fba2f317d

View file

@ -165,12 +165,13 @@ async fn handle_follow(
return Err(MyError::WrongActor(input.object.id().to_string())); return Err(MyError::WrongActor(input.object.id().to_string()));
} }
if !is_listener && input.object.is(&my_id) { if !is_listener {
let follow = generate_follow(state, &actor.id, &my_id)?;
let inbox = actor.inbox().to_owned(); let inbox = actor.inbox().to_owned();
db.add_listener(inbox).await?; db.add_listener(inbox).await?;
// if following relay directly, not just following 'public', followback
if input.object.is(&my_id) {
let follow = generate_follow(state, &actor.id, &my_id)?;
let client2 = client.clone(); let client2 = client.clone();
let inbox = actor.inbox().clone(); let inbox = actor.inbox().clone();
let follow2 = follow.clone(); let follow2 = follow.clone();
@ -178,6 +179,7 @@ async fn handle_follow(
let _ = client2.deliver(inbox, &follow2).await; let _ = client2.deliver(inbox, &follow2).await;
}); });
} }
}
let accept = generate_accept_follow(state, &actor.id, &input.id, &my_id)?; let accept = generate_accept_follow(state, &actor.id, &input.id, &my_id)?;