From 7bdb1abbe6009a6f55a8add4333bb4e62e942915 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 18 Sep 2020 07:04:12 -0400 Subject: [PATCH] Published user time (#1141) * Adding published time to UserForm. - Federates user creation time. Fixes #1140 * Check the user published time. --- api_tests/src/user.spec.ts | 3 ++- lemmy_db/src/activity.rs | 1 + lemmy_db/src/comment.rs | 1 + lemmy_db/src/comment_view.rs | 1 + lemmy_db/src/community.rs | 1 + lemmy_db/src/moderator.rs | 2 ++ lemmy_db/src/password_reset_request.rs | 1 + lemmy_db/src/post.rs | 1 + lemmy_db/src/post_view.rs | 1 + lemmy_db/src/private_message.rs | 2 ++ lemmy_db/src/user.rs | 2 ++ lemmy_db/src/user_mention.rs | 2 ++ src/api/user.rs | 2 ++ src/apub/user.rs | 1 + src/code_migrations.rs | 1 + 15 files changed, 21 insertions(+), 1 deletion(-) diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index a1f8c119a..bfd56fcbd 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -25,6 +25,7 @@ function assertUserFederation( expect(userOne.actor_id).toBe(userTwo.actor_id); expect(userOne.avatar).toBe(userTwo.avatar); expect(userOne.banner).toBe(userTwo.banner); + expect(userOne.published).toBe(userTwo.published); } test('Create user', async () => { @@ -74,4 +75,4 @@ test('Set avatar and banner, check that they are federated', async () => { let searchBeta = await searchForUser(beta, apShortname); let userOnBeta = searchBeta.users[0]; assertUserFederation(userOnAlpha, userOnBeta); -}); \ No newline at end of file +}); diff --git a/lemmy_db/src/activity.rs b/lemmy_db/src/activity.rs index 79b185fb7..c3f0ab679 100644 --- a/lemmy_db/src/activity.rs +++ b/lemmy_db/src/activity.rs @@ -105,6 +105,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/comment.rs b/lemmy_db/src/comment.rs index bc2a574ec..398ea78bf 100644 --- a/lemmy_db/src/comment.rs +++ b/lemmy_db/src/comment.rs @@ -281,6 +281,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/comment_view.rs b/lemmy_db/src/comment_view.rs index a5eb8e6d4..a3358ac43 100644 --- a/lemmy_db/src/comment_view.rs +++ b/lemmy_db/src/comment_view.rs @@ -520,6 +520,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/community.rs b/lemmy_db/src/community.rs index 918d44f15..25cb272a7 100644 --- a/lemmy_db/src/community.rs +++ b/lemmy_db/src/community.rs @@ -321,6 +321,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/moderator.rs b/lemmy_db/src/moderator.rs index aaed1314d..3edd4350f 100644 --- a/lemmy_db/src/moderator.rs +++ b/lemmy_db/src/moderator.rs @@ -417,6 +417,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), @@ -445,6 +446,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/password_reset_request.rs b/lemmy_db/src/password_reset_request.rs index fde47c98e..8a831a8db 100644 --- a/lemmy_db/src/password_reset_request.rs +++ b/lemmy_db/src/password_reset_request.rs @@ -101,6 +101,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/post.rs b/lemmy_db/src/post.rs index 7d13eb806..724c342c6 100644 --- a/lemmy_db/src/post.rs +++ b/lemmy_db/src/post.rs @@ -350,6 +350,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/post_view.rs b/lemmy_db/src/post_view.rs index e88a80e30..8f606b226 100644 --- a/lemmy_db/src/post_view.rs +++ b/lemmy_db/src/post_view.rs @@ -413,6 +413,7 @@ mod tests { matrix_user_id: None, avatar: None, banner: None, + published: None, updated: None, admin: false, banned: false, diff --git a/lemmy_db/src/private_message.rs b/lemmy_db/src/private_message.rs index 2484ebeab..988d97d3b 100644 --- a/lemmy_db/src/private_message.rs +++ b/lemmy_db/src/private_message.rs @@ -158,6 +158,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), @@ -186,6 +187,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/user.rs b/lemmy_db/src/user.rs index 986701c43..f2c20e947 100644 --- a/lemmy_db/src/user.rs +++ b/lemmy_db/src/user.rs @@ -48,6 +48,7 @@ pub struct UserForm { pub banned: bool, pub email: Option>, pub avatar: Option>, + pub published: Option, pub updated: Option, pub show_nsfw: bool, pub theme: String, @@ -181,6 +182,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/lemmy_db/src/user_mention.rs b/lemmy_db/src/user_mention.rs index bcb3a1437..f35722cf9 100644 --- a/lemmy_db/src/user_mention.rs +++ b/lemmy_db/src/user_mention.rs @@ -97,6 +97,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), @@ -125,6 +126,7 @@ mod tests { banner: None, admin: false, banned: false, + published: None, updated: None, show_nsfw: false, theme: "darkly".into(), diff --git a/src/api/user.rs b/src/api/user.rs index 630f816de..977250d34 100644 --- a/src/api/user.rs +++ b/src/api/user.rs @@ -170,6 +170,7 @@ impl Perform for Register { banner: None, password_encrypted: data.password.to_owned(), preferred_username: None, + published: None, updated: None, admin: data.admin, banned: false, @@ -404,6 +405,7 @@ impl Perform for SaveUserSettings { banner, password_encrypted, preferred_username, + published: Some(read_user.published), updated: Some(naive_now()), admin: read_user.admin, banned: read_user.banned, diff --git a/src/apub/user.rs b/src/apub/user.rs index fb650632e..47b6a58a7 100644 --- a/src/apub/user.rs +++ b/src/apub/user.rs @@ -262,6 +262,7 @@ impl FromApub for UserForm { email: None, avatar, banner, + published: person.inner.published().map(|u| u.to_owned().naive_local()), updated: person.updated().map(|u| u.to_owned().naive_local()), show_nsfw: false, theme: "".to_string(), diff --git a/src/code_migrations.rs b/src/code_migrations.rs index 47d046696..6a69035da 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -54,6 +54,7 @@ fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> { banner: Some(cuser.banner.to_owned()), password_encrypted: cuser.password_encrypted.to_owned(), preferred_username: cuser.preferred_username.to_owned(), + published: Some(cuser.published), updated: None, admin: cuser.admin, banned: cuser.banned,