From 89f9ecb634de7f8d8e19fabf39111a19fbc81daa Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 1 Dec 2020 18:45:46 +0100 Subject: [PATCH] Mark user as updated after fetching --- lemmy_apub/src/fetcher.rs | 8 ++++++-- lemmy_db/src/user.rs | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lemmy_apub/src/fetcher.rs b/lemmy_apub/src/fetcher.rs index 76d8b645e..0fb0cb10c 100644 --- a/lemmy_apub/src/fetcher.rs +++ b/lemmy_apub/src/fetcher.rs @@ -258,8 +258,12 @@ pub(crate) async fn get_or_fetch_and_upsert_user( recursion_counter, ) .await?; - // TODO: do we need to set this? would need a separate db call - //uf.last_refreshed_at = Some(naive_now()); + + let user_id = user.id; + blocking(context.pool(), move |conn| { + User_::mark_as_updated(conn, user_id) + }) + .await??; Ok(user) } diff --git a/lemmy_db/src/user.rs b/lemmy_db/src/user.rs index 2c4c67ea2..3f2efd2cc 100644 --- a/lemmy_db/src/user.rs +++ b/lemmy_db/src/user.rs @@ -188,6 +188,12 @@ impl User_ { .get_result::(conn) } + pub fn mark_as_updated(conn: &PgConnection, user_id: i32) -> Result { + diesel::update(user_.find(user_id)) + .set((updated.eq(naive_now()),)) + .get_result::(conn) + } + pub fn delete_account(conn: &PgConnection, user_id: i32) -> Result { diesel::update(user_.find(user_id)) .set((