From: Dessalines Date: Fri, 18 Sep 2020 11:04:12 +0000 (-0400) Subject: Published user time (#1141) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7BelementUrl%7D?a=commitdiff_plain;h=7bdb1abbe6009a6f55a8add4333bb4e62e942915;p=lemmy.git Published user time (#1141) * Adding published time to UserForm. - Federates user creation time. Fixes #1140 * Check the user published time. --- diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index a1f8c119..bfd56fcb 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 79b185fb..c3f0ab67 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 bc2a574e..398ea78b 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 a5eb8e6d..a3358ac4 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 918d44f1..25cb272a 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 aaed1314..3edd4350 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 fde47c98..8a831a8d 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 7d13eb80..724c342c 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 e88a80e3..8f606b22 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 2484ebea..988d97d3 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 986701c4..f2c20e94 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 bcb3a143..f35722cf 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 630f816d..977250d3 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 fb650632..47b6a58a 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 47d04669..6a69035d 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,