Don't panic in loop
This commit is contained in:
parent
c82c38fe52
commit
5ba823990a
@ -66,40 +66,60 @@ impl ActorFactoryArgs<DbPool> for RemoteFetchActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_and_cache_articles(user: &Arc<User>, conn: &DbConn) {
|
fn fetch_and_cache_articles(user: &Arc<User>, conn: &DbConn) {
|
||||||
for create_act in user
|
let create_acts = user.fetch_outbox::<Create>();
|
||||||
.fetch_outbox::<Create>()
|
match create_acts {
|
||||||
.expect("Remote user: outbox couldn't be fetched")
|
Ok(create_acts) => {
|
||||||
{
|
for create_act in create_acts {
|
||||||
match create_act.create_props.object_object::<LicensedArticle>() {
|
match create_act.create_props.object_object::<LicensedArticle>() {
|
||||||
Ok(article) => {
|
Ok(article) => {
|
||||||
Post::from_activity(conn, article)
|
Post::from_activity(conn, article)
|
||||||
.expect("Article from remote user couldn't be saved");
|
.expect("Article from remote user couldn't be saved");
|
||||||
info!("Fetched article from remote user");
|
info!("Fetched article from remote user");
|
||||||
|
}
|
||||||
|
Err(e) => warn!("Error while fetching articles in background: {:?}", e),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(e) => warn!("Error while fetching articles in background: {:?}", e),
|
}
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to fetch outboxes: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_and_cache_followers(user: &Arc<User>, conn: &DbConn) {
|
fn fetch_and_cache_followers(user: &Arc<User>, conn: &DbConn) {
|
||||||
for user_id in user
|
let follower_ids = user.fetch_followers_ids();
|
||||||
.fetch_followers_ids()
|
match follower_ids {
|
||||||
.expect("Remote user: fetching followers error")
|
Ok(user_ids) => {
|
||||||
{
|
for user_id in user_ids {
|
||||||
let follower = User::from_id(conn, &user_id, None, CONFIG.proxy())
|
let follower = User::from_id(conn, &user_id, None, CONFIG.proxy());
|
||||||
.expect("user::details: Couldn't fetch follower");
|
match follower {
|
||||||
follows::Follow::insert(
|
Ok(follower) => {
|
||||||
conn,
|
let inserted = follows::Follow::insert(
|
||||||
follows::NewFollow {
|
conn,
|
||||||
follower_id: follower.id,
|
follows::NewFollow {
|
||||||
following_id: user.id,
|
follower_id: follower.id,
|
||||||
ap_url: String::new(),
|
following_id: user.id,
|
||||||
},
|
ap_url: String::new(),
|
||||||
)
|
},
|
||||||
.expect("Couldn't save follower for remote user");
|
);
|
||||||
|
if inserted.is_err() {
|
||||||
|
error!("Couldn't save follower for remote user: {:?}", user_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
error!("Couldn't fetch follower: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to fetch follower: {:?}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_and_cache_user(user: &Arc<User>, conn: &DbConn) {
|
fn fetch_and_cache_user(user: &Arc<User>, conn: &DbConn) {
|
||||||
user.refetch(conn).expect("Couldn't update user info");
|
if user.refetch(conn).is_err() {
|
||||||
|
error!("Couldn't update user info: {:?}", user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user