From 398c9ec96792c4c95aa39073b409ce542c4fa067 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 11 Jun 2025 03:38:24 -0400 Subject: [PATCH] Rename timestamp fields to `_at` (#5761) * Adding migration for renaming timestamps to at * Running format. * Updating code to _at * Fix replaceable schema * Fixing scheduled tasks. * Fixing and cleaning up api tests. * Fixing cargo shear. --- Cargo.lock | 3 - api_tests/package.json | 2 +- api_tests/pnpm-lock.yaml | 10 +- api_tests/src/comment.spec.ts | 63 +++--- api_tests/src/community.spec.ts | 55 +++-- api_tests/src/follow.spec.ts | 27 +-- api_tests/src/image.spec.ts | 12 +- api_tests/src/post.spec.ts | 110 +++++---- api_tests/src/private_community.spec.ts | 47 ++-- api_tests/src/private_message.spec.ts | 4 +- api_tests/src/shared.ts | 52 +++-- api_tests/src/user.spec.ts | 13 +- crates/api/api/src/community/ban.rs | 6 +- crates/api/api/src/community/tag.rs | 4 +- crates/api/api/src/local_user/ban_person.rs | 12 +- .../src/local_user/donation_dialog_shown.rs | 2 +- .../api/api/src/site/admin_allow_instance.rs | 2 +- .../api/api/src/site/admin_block_instance.rs | 4 +- crates/api/api/src/site/purge/person.rs | 2 +- crates/api/api_common/src/federation.rs | 2 +- crates/api/api_crud/src/comment/update.rs | 2 +- crates/api/api_crud/src/community/update.rs | 2 +- .../api/api_crud/src/oauth_provider/update.rs | 2 +- crates/api/api_crud/src/post/create.rs | 8 +- crates/api/api_crud/src/post/update.rs | 20 +- .../api_crud/src/private_message/update.rs | 2 +- crates/api/api_crud/src/site/create.rs | 2 +- crates/api/api_crud/src/site/update.rs | 4 +- crates/api/api_crud/src/tagline/update.rs | 2 +- crates/api/api_utils/src/send_activity.rs | 2 +- .../apub/src/activities/block/block_user.rs | 10 +- crates/apub/src/activities/block/mod.rs | 4 +- .../src/activities/block/undo_block_user.rs | 8 +- crates/apub/src/activities/mod.rs | 4 +- crates/apub_objects/src/objects/comment.rs | 8 +- crates/apub_objects/src/objects/community.rs | 8 +- crates/apub_objects/src/objects/instance.rs | 6 +- crates/apub_objects/src/objects/person.rs | 8 +- crates/apub_objects/src/objects/post.rs | 8 +- .../src/objects/private_message.rs | 8 +- crates/db_perf/src/main.rs | 6 +- crates/db_schema/src/impls/comment.rs | 18 +- crates/db_schema/src/impls/comment_report.rs | 8 +- crates/db_schema/src/impls/community.rs | 46 ++-- .../db_schema/src/impls/community_report.rs | 8 +- .../db_schema/src/impls/email_verification.rs | 36 ++- .../src/impls/federation_allowlist.rs | 2 +- .../src/impls/federation_queue_state.rs | 4 +- crates/db_schema/src/impls/instance.rs | 18 +- .../src/impls/local_site_rate_limit.rs | 2 +- .../src/impls/local_site_url_blocklist.rs | 5 +- crates/db_schema/src/impls/local_user.rs | 18 +- .../db_schema/src/impls/mod_log/moderator.rs | 26 +-- .../src/impls/password_reset_request.rs | 6 +- crates/db_schema/src/impls/person.rs | 22 +- crates/db_schema/src/impls/post.rs | 52 ++--- crates/db_schema/src/impls/post_report.rs | 8 +- crates/db_schema/src/impls/private_message.rs | 10 +- .../src/impls/private_message_report.rs | 25 +- crates/db_schema/src/impls/tagline.rs | 2 +- crates/db_schema/src/lib.rs | 30 +-- crates/db_schema/src/source/activity.rs | 4 +- crates/db_schema/src/source/captcha_answer.rs | 2 +- crates/db_schema/src/source/combined/inbox.rs | 2 +- .../db_schema/src/source/combined/modlog.rs | 2 +- .../src/source/combined/person_content.rs | 2 +- .../src/source/combined/person_liked.rs | 2 +- .../src/source/combined/person_saved.rs | 2 +- .../db_schema/src/source/combined/report.rs | 2 +- .../db_schema/src/source/combined/search.rs | 2 +- crates/db_schema/src/source/comment.rs | 18 +- crates/db_schema/src/source/comment_reply.rs | 2 +- crates/db_schema/src/source/comment_report.rs | 4 +- crates/db_schema/src/source/community.rs | 32 +-- .../db_schema/src/source/community_report.rs | 4 +- crates/db_schema/src/source/custom_emoji.rs | 4 +- .../src/source/email_verification.rs | 2 +- .../src/source/federation_allowlist.rs | 6 +- .../src/source/federation_blocklist.rs | 10 +- .../src/source/federation_queue_state.rs | 4 +- crates/db_schema/src/source/images.rs | 4 +- crates/db_schema/src/source/instance.rs | 18 +- crates/db_schema/src/source/local_site.rs | 6 +- .../src/source/local_site_rate_limit.rs | 6 +- .../src/source/local_site_url_blocklist.rs | 6 +- crates/db_schema/src/source/local_user.rs | 6 +- crates/db_schema/src/source/login_token.rs | 2 +- crates/db_schema/src/source/mod_log/admin.rs | 14 +- .../db_schema/src/source/mod_log/moderator.rs | 30 +-- crates/db_schema/src/source/oauth_account.rs | 4 +- crates/db_schema/src/source/oauth_provider.rs | 6 +- .../src/source/password_reset_request.rs | 2 +- crates/db_schema/src/source/person.rs | 18 +- .../src/source/person_comment_mention.rs | 2 +- .../src/source/person_post_mention.rs | 2 +- crates/db_schema/src/source/post.rs | 42 ++-- crates/db_schema/src/source/post_report.rs | 4 +- crates/db_schema/src/source/post_tag.rs | 2 +- .../db_schema/src/source/private_message.rs | 12 +- .../src/source/private_message_report.rs | 4 +- .../src/source/registration_application.rs | 2 +- crates/db_schema/src/source/site.rs | 8 +- crates/db_schema/src/source/tag.rs | 8 +- crates/db_schema/src/source/tagline.rs | 6 +- crates/db_schema/src/utils/queries.rs | 24 +- crates/db_schema_file/diesel_ltree.patch | 2 +- .../replaceable_schema/triggers.sql | 74 +++--- .../replaceable_schema/utils.sql | 30 +-- crates/db_schema_file/src/schema.rs | 214 +++++++++--------- crates/db_views/api_misc/Cargo.toml | 6 - crates/db_views/api_misc/src/lib.rs | 20 -- crates/db_views/comment/src/impls.rs | 18 +- crates/db_views/community/src/api.rs | 2 +- crates/db_views/community/src/impls.rs | 18 +- .../db_views/community_follower/src/impls.rs | 8 +- .../db_views/community_moderator/src/impls.rs | 6 +- .../community_person_ban/src/impls.rs | 2 +- crates/db_views/inbox_combined/src/impls.rs | 14 +- crates/db_views/local_user/src/impls.rs | 19 +- crates/db_views/modlog_combined/src/impls.rs | 10 +- crates/db_views/person/src/api.rs | 2 +- crates/db_views/person/src/impls.rs | 2 +- .../person_content_combined/src/impls.rs | 2 +- .../person_liked_combined/src/impls.rs | 2 +- .../person_saved_combined/src/impls.rs | 2 +- crates/db_views/post/src/api.rs | 4 +- crates/db_views/post/src/impls.rs | 56 ++--- .../readable_federation_state/src/impls.rs | 2 +- .../registration_applications/src/impls.rs | 14 +- crates/db_views/report_combined/src/impls.rs | 10 +- crates/db_views/search_combined/src/impls.rs | 9 +- crates/db_views/site/src/api.rs | 7 +- crates/db_views/vote/src/impls.rs | 8 +- crates/email/src/notifications.rs | 2 +- crates/federate/src/inboxes.rs | 24 +- crates/federate/src/lib.rs | 8 +- crates/federate/src/send.rs | 4 +- crates/federate/src/worker.rs | 23 +- crates/routes/src/feeds.rs | 44 ++-- crates/routes/src/utils/scheduled_tasks.rs | 81 +++---- .../down.sql | 214 ++++++++++++++++++ .../up.sql | 214 ++++++++++++++++++ 142 files changed, 1436 insertions(+), 987 deletions(-) create mode 100644 migrations/2025-06-08-084651_rename_timestamp_add_at/down.sql create mode 100644 migrations/2025-06-08-084651_rename_timestamp_add_at/up.sql diff --git a/Cargo.lock b/Cargo.lock index f65d5a439..29ec6764d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3415,12 +3415,9 @@ dependencies = [ "extism-convert", "lemmy_db_schema", "lemmy_db_schema_file", - "lemmy_db_views_comment", - "lemmy_db_views_community", "lemmy_db_views_community_follower", "lemmy_db_views_community_moderator", "lemmy_db_views_local_user", - "lemmy_db_views_person", "lemmy_db_views_post", "serde", "serde_with", diff --git a/api_tests/package.json b/api_tests/package.json index 41c8b077a..47bbb833b 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -31,7 +31,7 @@ "eslint-plugin-prettier": "^5.4.0", "jest": "^29.5.0", "joi": "^17.13.3", - "lemmy-js-client": "1.0.0-search-and-resolve.1", + "lemmy-js-client": "1.0.0-rename-timestamp-to-at.4", "prettier": "^3.5.3", "ts-jest": "^29.3.2", "tsoa": "^6.6.0", diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index 1867cf68e..97a7195c9 100644 --- a/api_tests/pnpm-lock.yaml +++ b/api_tests/pnpm-lock.yaml @@ -36,8 +36,8 @@ importers: specifier: ^17.13.3 version: 17.13.3 lemmy-js-client: - specifier: 1.0.0-search-and-resolve.1 - version: 1.0.0-search-and-resolve.1 + specifier: 1.0.0-rename-timestamp-to-at.4 + version: 1.0.0-rename-timestamp-to-at.4 prettier: specifier: ^3.5.3 version: 3.5.3 @@ -1594,8 +1594,8 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} - lemmy-js-client@1.0.0-search-and-resolve.1: - resolution: {integrity: sha512-HRbti+FmZEMdSu1gbpcmT/GwsH2MeLq60dXcAXaYa5j0QOlFuUy2TejO01vqqJva7EZ4YIJPZS+pbQ4Y/Y/V2A==} + lemmy-js-client@1.0.0-rename-timestamp-to-at.4: + resolution: {integrity: sha512-tEp92LODxqLIyru7qaMFVuXEmsusSDzG2V7QYctBYGfbJzsoUEogtuI9Gla5MlL6lT9l/hOLSv/ujqxdS0FLAg==} leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} @@ -4404,7 +4404,7 @@ snapshots: kleur@3.0.3: {} - lemmy-js-client@1.0.0-search-and-resolve.1: + lemmy-js-client@1.0.0-rename-timestamp-to-at.4: dependencies: '@tsoa/runtime': 6.6.0 transitivePeerDependencies: diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index dcb5a905b..0e77cd1c9 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -44,6 +44,7 @@ import { CommentView, CommunityView, DistinguishComment, + LemmyError, PersonCommentMentionView, ReportCombinedView, SaveUserSettings, @@ -71,8 +72,10 @@ function assertCommentFederation( expect(commentOne?.comment.content).toBe(commentTwo?.comment.content); expect(commentOne?.creator.name).toBe(commentTwo?.creator.name); expect(commentOne?.community.ap_id).toBe(commentTwo?.community.ap_id); - expect(commentOne?.comment.published).toBe(commentTwo?.comment.published); - expect(commentOne?.comment.updated).toBe(commentOne?.comment.updated); + expect(commentOne?.comment.published_at).toBe( + commentTwo?.comment.published_at, + ); + expect(commentOne?.comment.updated_at).toBe(commentOne?.comment.updated_at); expect(commentOne?.comment.deleted).toBe(commentOne?.comment.deleted); expect(commentOne?.comment.removed).toBe(commentOne?.comment.removed); } @@ -87,7 +90,7 @@ test("Create a comment", async () => { // Make sure that comment is liked on beta let betaComment = await waitUntil( () => resolveComment(beta, commentRes.comment_view.comment), - c => c.comment.score === 1, + c => c?.comment.score === 1, ); expect(betaComment).toBeDefined(); expect(betaComment?.community.local).toBe(true); @@ -98,7 +101,7 @@ test("Create a comment", async () => { test("Create a comment in a non-existent post", async () => { await expect(createComment(alpha, -1)).rejects.toStrictEqual( - Error("not_found"), + new LemmyError("not_found"), ); }); @@ -121,7 +124,7 @@ test("Update a comment", async () => { // Make sure that post is updated on beta let betaCommentUpdated = await waitUntil( () => resolveComment(beta, commentRes.comment_view.comment), - c => c.comment.content === "A jest test federated comment update", + c => c?.comment.content === "A jest test federated comment update", ); assertCommentFederation(betaCommentUpdated, updateCommentRes.comment_view); }); @@ -132,9 +135,7 @@ test("Delete a comment", async () => { let commentRes = await createComment(alpha, post.post_view.post.id); // Find the comment on beta (home of community) - let betaComment = ( - await resolveComment(beta, commentRes.comment_view.comment) - ).comment; + let betaComment = await resolveComment(beta, commentRes.comment_view.comment); if (!betaComment) { throw "Missing beta comment before delete"; } @@ -161,13 +162,13 @@ test("Delete a comment", async () => { // Make sure that comment is deleted on beta await waitUntil( () => resolveComment(beta, commentRes.comment_view.comment), - c => c.comment.deleted === true, + c => c?.comment.deleted === true, ); // Make sure that comment is deleted on gamma after delete await waitUntil( () => resolveComment(gamma, commentRes.comment_view.comment), - c => c.comment.deleted === true, + c => c?.comment.deleted === true, ); // Test undeleting the comment @@ -181,7 +182,7 @@ test("Delete a comment", async () => { // Make sure that comment is undeleted on beta let betaComment2 = await waitUntil( () => resolveComment(beta, commentRes.comment_view.comment), - c => c.comment.deleted === false, + c => c?.comment.deleted === false, ); assertCommentFederation(betaComment2, undeleteCommentRes.comment_view); }); @@ -192,7 +193,7 @@ test.skip("Remove a comment from admin and community on the same instance", asyn // Get the id for beta let betaCommentId = ( await resolveComment(beta, commentRes.comment_view.comment) - ).comment.id; + )?.comment.id; if (!betaCommentId) { throw "beta comment id is missing"; @@ -282,7 +283,7 @@ test("Unlike a comment", async () => { let gammaComment1 = await waitUntil( () => resolveComment(gamma, commentRes.comment_view.comment), - c => c.comment.score === 1, + c => c?.comment.score === 1, ); expect(gammaComment1).toBeDefined(); expect(gammaComment1?.community.local).toBe(false); @@ -295,7 +296,7 @@ test("Unlike a comment", async () => { // Make sure that comment is unliked on beta let betaComment = await waitUntil( () => resolveComment(beta, commentRes.comment_view.comment), - c => c.comment.score === 0, + c => c?.comment.score === 0, ); expect(betaComment).toBeDefined(); expect(betaComment?.community.local).toBe(true); @@ -306,7 +307,7 @@ test("Unlike a comment", async () => { // This is testing replication from remote-home-remote (alpha-beta-gamma) let gammaComment = await waitUntil( () => resolveComment(gamma, commentRes.comment_view.comment), - c => c.comment.score === 0, + c => c?.comment.score === 0, ); expect(gammaComment).toBeDefined(); expect(gammaComment?.community.local).toBe(false); @@ -318,7 +319,7 @@ test("Federated comment like", async () => { let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id); await waitUntil( () => resolveComment(beta, commentRes.comment_view.comment), - c => c.comment.score === 1, + c => c?.comment.score === 1, ); // Find the comment on beta let betaComment = await resolveComment(beta, commentRes.comment_view.comment); @@ -343,7 +344,7 @@ test("Reply to a comment from another instance, get notification", async () => { let betaCommunity = await waitUntil( () => resolveBetaCommunity(alpha), - c => !!c.community.instance_id, + c => !!c?.community.instance_id, ); if (!betaCommunity) { throw "Missing beta community"; @@ -356,7 +357,7 @@ test("Reply to a comment from another instance, get notification", async () => { // find that comment id on beta let betaComment = await waitUntil( () => resolveComment(beta, commentRes.comment_view.comment), - c => c.comment.score === 1, + c => c?.comment.score === 1, ); if (!betaComment) { @@ -378,10 +379,11 @@ test("Reply to a comment from another instance, get notification", async () => { expect(replyRes.comment_view.comment.score).toBe(1); // Make sure that reply comment is seen on alpha - let alphaComment = await waitUntil( + let commentSearch = await waitUntil( () => resolveComment(alpha, replyRes.comment_view.comment), - c => c.comment.score === 1, + c => c?.comment.score === 1, ); + let alphaComment = commentSearch!; let postComments = await waitUntil( () => getComments(alpha, postOnAlphaRes.post_view.post.id), pc => pc.comments.length >= 2, @@ -557,13 +559,13 @@ test("A and G subscribe to B (center) A posts, G mentions B, it gets announced t beta, alphaCommunity.community.ap_id, ); - await followCommunity(beta, true, betaCommunity.community.id); + await followCommunity(beta, true, betaCommunity!.community.id); let alphaPost = await createPost(alpha, alphaCommunity.community.id); expect(alphaPost.post_view.community.local).toBe(true); // Make sure gamma sees it - let gammaPost = (await resolvePost(gamma, alphaPost.post_view.post))!; + let gammaPost = await resolvePost(gamma, alphaPost.post_view.post); if (!gammaPost) { throw "Missing gamma post"; @@ -627,11 +629,11 @@ test("Check that activity from another instance is sent to third instance", asyn expect(gammaFollow.community_view.community.name).toBe("main"); await waitUntil( () => resolveBetaCommunity(alpha), - c => c.community_actions?.follow_state === "Accepted", + c => c?.community_actions?.follow_state === "Accepted", ); await waitUntil( () => resolveBetaCommunity(gamma), - c => c.community_actions?.follow_state === "Accepted", + c => c?.community_actions?.follow_state === "Accepted", ); // Create a post on beta @@ -771,14 +773,15 @@ test("Report a comment", async () => { .comment; expect(commentRes).toBeDefined(); - let alphaComment = (await resolveComment(alpha, commentRes)).comment; + let alphaComment = await resolveComment(alpha, commentRes); if (!alphaComment) { throw "Missing alpha comment"; } const reason = randomString(10); - let alphaReport = (await reportComment(alpha, alphaComment.id, reason)) - .comment_report_view.comment_report; + let alphaReport = ( + await reportComment(alpha, alphaComment.comment.id, reason) + ).comment_report_view.comment_report; let betaReport = ( (await waitUntil( @@ -863,13 +866,13 @@ test("Fetch a deeply nested comment", async () => { lastComment!.comment_view.comment, ); - expect(betaComment!.comment).toBeDefined(); + expect(betaComment?.comment).toBeDefined(); expect(betaComment?.post).toBeDefined(); }); test("Distinguish comment", async () => { - const community = await resolveBetaCommunity(beta); - let post = await createPost(beta, community!.community.id); + const community = (await resolveBetaCommunity(beta))?.community; + let post = await createPost(beta, community!.id); let commentRes = await createComment(beta, post.post_view.post.id); const form: DistinguishComment = { comment_id: commentRes.comment_view.comment.id, diff --git a/api_tests/src/community.spec.ts b/api_tests/src/community.spec.ts index 5a86ccc71..b19468b1c 100644 --- a/api_tests/src/community.spec.ts +++ b/api_tests/src/community.spec.ts @@ -42,6 +42,7 @@ import { CommunityReportView, EditCommunity, GetPosts, + LemmyError, ReportCombinedView, ResolveCommunityReport, Search, @@ -62,8 +63,8 @@ function assertCommunityFederation( ); expect(communityOne?.community.icon).toBe(communityTwo?.community.icon); expect(communityOne?.community.banner).toBe(communityTwo?.community.banner); - expect(communityOne?.community.published).toBe( - communityTwo?.community.published, + expect(communityOne?.community.published_at).toBe( + communityTwo?.community.published_at, ); expect(communityOne?.community.nsfw).toBe(communityTwo?.community.nsfw); expect(communityOne?.community.removed).toBe(communityTwo?.community.removed); @@ -77,7 +78,7 @@ test("Create community", async () => { // A dupe check let prevName = communityRes.community_view.community.name; await expect(createCommunity(alpha, prevName)).rejects.toStrictEqual( - Error("community_already_exists"), + new LemmyError("community_already_exists"), ); // Cache the community on beta, make sure it has the other fields @@ -201,7 +202,7 @@ test("Report a community", async () => { alphaCommunity.community_view.community.ap_id, ); let betaReport = ( - await reportCommunity(beta, betaCommunity.community.id, randomString(10)) + await reportCommunity(beta, betaCommunity!.community.id, randomString(10)) ).community_report_view.community_report; expect(betaReport).toBeDefined(); @@ -290,7 +291,7 @@ test("Admin actions in remote community are not federated to origin", async () = await followCommunity(gamma, true, gammaCommunity.community.id); gammaCommunity = await waitUntil( () => resolveCommunity(gamma, communityRes.community.ap_id), - g => g.community_actions?.follow_state == "Accepted", + g => g?.community_actions?.follow_state == "Accepted", ); if (!gammaCommunity) { throw "Missing gamma community"; @@ -299,7 +300,7 @@ test("Admin actions in remote community are not federated to origin", async () = let gammaPost = (await createPost(gamma, gammaCommunity.community.id)) .post_view; expect(gammaPost.post.id).toBeDefined(); - expect(gammaPost.creator_community_actions?.received_ban).toBeUndefined(); + expect(gammaPost.creator_community_actions?.received_ban_at).toBeUndefined(); // admin of beta decides to ban gamma from community let betaCommunity = await resolveCommunity( @@ -314,6 +315,7 @@ test("Admin actions in remote community are not federated to origin", async () = throw "Missing banned user 1"; } let bannedUserInfo2 = await resolvePerson(beta, bannedUserInfo1.ap_id); + if (!bannedUserInfo2) { throw "Missing banned user 2"; } @@ -328,12 +330,12 @@ test("Admin actions in remote community are not federated to origin", async () = // ban doesn't federate to community's origin instance alpha let alphaPost = await resolvePost(alpha, gammaPost.post); - expect(alphaPost?.creator_community_actions?.received_ban).toBeUndefined(); + expect(alphaPost?.creator_community_actions?.received_ban_at).toBeUndefined(); // and neither to gamma let gammaPost2 = await getPost(gamma, gammaPost.post.id); expect( - gammaPost2.post_view.creator_community_actions?.received_ban, + gammaPost2.post_view.creator_community_actions?.received_ban_at, ).toBeUndefined(); }); @@ -417,7 +419,7 @@ test("Get community for different casing on domain", async () => { // A dupe check let prevName = communityRes.community_view.community.name; await expect(createCommunity(alpha, prevName)).rejects.toStrictEqual( - Error("community_already_exists"), + new LemmyError("community_already_exists"), ); // Cache the community on beta, make sure it has the other fields @@ -439,7 +441,7 @@ test("User blocks instance, communities are hidden", async () => { // fetch post to alpha let alphaPost = await resolvePost(alpha, postRes.post_view.post); - expect(alphaPost.post).toBeDefined(); + expect(alphaPost?.post).toBeDefined(); // post should be included in listing let listing = await getPosts(alpha, "All"); @@ -447,7 +449,7 @@ test("User blocks instance, communities are hidden", async () => { expect(listing_ids).toContain(postRes.post_view.post.ap_id); // block the beta instance - await userBlockInstance(alpha, alphaPost.community.instance_id, true); + await userBlockInstance(alpha, alphaPost!.community.instance_id, true); // after blocking, post should not be in listing let listing2 = await getPosts(alpha, "All"); @@ -455,7 +457,7 @@ test("User blocks instance, communities are hidden", async () => { expect(listing_ids2.indexOf(postRes.post_view.post.ap_id)).toBe(-1); // unblock instance again - await userBlockInstance(alpha, alphaPost.community.instance_id, false); + await userBlockInstance(alpha, alphaPost!.community.instance_id, false); // post should be included in listing let listing3 = await getPosts(alpha, "All"); @@ -469,14 +471,14 @@ test.skip("Community follower count is federated", async () => { let community = await createCommunity(beta); let communityActorId = community.community_view.community.ap_id; let resolved = await resolveCommunity(alpha, communityActorId); - if (!resolved.community) { + if (!resolved?.community) { throw "Missing beta community"; } await followCommunity(alpha, true, resolved.community.id); let followed = await waitUntil( () => resolveCommunity(alpha, communityActorId), - c => c.community_actions?.follow_state == "Accepted", + c => c?.community_actions?.follow_state == "Accepted", ); // Make sure there is 1 subscriber @@ -484,14 +486,14 @@ test.skip("Community follower count is federated", async () => { // Follow the community from gamma resolved = await resolveCommunity(gamma, communityActorId); - if (!resolved.community) { + if (!resolved?.community) { throw "Missing beta community"; } await followCommunity(gamma, true, resolved.community.id); followed = await waitUntil( () => resolveCommunity(gamma, communityActorId), - c => c.community_actions?.follow_state == "Accepted", + c => c?.community_actions?.follow_state == "Accepted", ); // Make sure there are 2 subscribers @@ -499,18 +501,15 @@ test.skip("Community follower count is federated", async () => { // Follow the community from delta resolved = await resolveCommunity(delta, communityActorId); - if (!resolved.community) { + if (!resolved?.community) { throw "Missing beta community"; } await followCommunity(delta, true, resolved.community.id); followed = await waitUntil( () => resolveCommunity(delta, communityActorId), - c => c.community_actions?.follow_state == "Accepted", + c => c?.community_actions?.follow_state == "Accepted", ); - - // Make sure there are 3 subscribers - expect(followed?.community?.subscribers).toBe(3); }); test("Dont receive community activities after unsubscribe", async () => { @@ -589,7 +588,7 @@ test("Fetch community, includes posts", async () => { let resolvedCommunity = await waitUntil( () => resolveCommunity(beta, communityRes.community_view.community.ap_id), - c => c.community.id != undefined, + c => c?.community.id != undefined, ); let betaCommunity = resolvedCommunity; expect(betaCommunity?.community.ap_id).toBe( @@ -615,12 +614,12 @@ test("Content in local-only community doesn't federate", async () => { // cant resolve the community from another instance await expect( resolveCommunity(beta, communityRes.ap_id), - ).rejects.toStrictEqual(Error("not_found")); + ).rejects.toStrictEqual(new LemmyError("not_found")); // create a post, also cant resolve it let postRes = await createPost(alpha, communityRes.id); await expect(resolvePost(beta, postRes.post_view.post)).rejects.toStrictEqual( - Error("not_found"), + new LemmyError("not_found"), ); }); @@ -631,14 +630,14 @@ test("Remote mods can edit communities", async () => { beta, communityRes.community_view.community.ap_id, ); - if (!betaCommunity.community) { + if (!betaCommunity?.community) { throw "Missing beta community"; } let betaOnAlpha = await resolvePerson(alpha, "lemmy_beta@lemmy-beta:8551"); let form: AddModToCommunity = { community_id: communityRes.community_view.community.id, - person_id: betaOnAlpha.person.id as number, + person_id: betaOnAlpha?.person.id as number, added: true, }; alpha.addModToCommunity(form); @@ -670,7 +669,7 @@ test("Community name with non-ascii chars", async () => { beta, communityRes.community_view.community.ap_id, ); - expect(betaCommunity1.community.name).toBe(name); + expect(betaCommunity1?.community.name).toBe(name); let alphaCommunity2 = await getCommunityByName(alpha, name); expect(alphaCommunity2.community_view.community.name).toBe(name); @@ -679,7 +678,7 @@ test("Community name with non-ascii chars", async () => { let betaCommunity2 = await getCommunityByName(beta, fediName); expect(betaCommunity2.community_view.community.name).toBe(name); - let postRes = await createPost(beta, betaCommunity1.community.id); + let postRes = await createPost(beta, betaCommunity1!.community.id); let form: GetPosts = { community_name: fediName, diff --git a/api_tests/src/follow.spec.ts b/api_tests/src/follow.spec.ts index 33bd7cf0f..6323e23b3 100644 --- a/api_tests/src/follow.spec.ts +++ b/api_tests/src/follow.spec.ts @@ -21,8 +21,8 @@ afterAll(unfollows); test("Follow local community", async () => { let user = await registerUser(beta, betaUrl); - let community = await resolveBetaCommunity(user)!; - let follow = await followCommunity(user, true, community.community.id); + let community = await resolveBetaCommunity(user); + let follow = await followCommunity(user, true, community!.community.id); // Make sure the follow response went through expect(follow.community_view.community.local).toBe(true); @@ -30,22 +30,22 @@ test("Follow local community", async () => { "Accepted", ); expect(follow.community_view.community.subscribers).toBe( - community.community.subscribers + 1, + community!.community.subscribers + 1, ); expect(follow.community_view.community.subscribers_local).toBe( - community.community.subscribers_local + 1, + community!.community.subscribers_local + 1, ); // Test an unfollow - let unfollow = await followCommunity(user, false, community.community.id); + let unfollow = await followCommunity(user, false, community!.community.id); expect( unfollow.community_view.community_actions?.follow_state, ).toBeUndefined(); expect(unfollow.community_view.community.subscribers).toBe( - community.community.subscribers, + community?.community.subscribers, ); expect(unfollow.community_view.community.subscribers_local).toBe( - community.community.subscribers_local, + community?.community.subscribers_local, ); }); @@ -54,7 +54,7 @@ test("Follow federated community", async () => { await delay(2000); // if this is the second test run, we don't have a way to wait for the correct number of subscribers const betaCommunityInitial = await waitUntil( () => resolveBetaCommunity(alpha), - c => !!c.community && c.community?.subscribers >= 1, + c => !!c?.community && c.community.subscribers >= 1, ); if (!betaCommunityInitial) { throw "Missing beta community"; @@ -67,7 +67,7 @@ test("Follow federated community", async () => { expect(follow.community_view.community_actions?.follow_state).toBe("Pending"); const betaCommunity = await waitUntil( () => resolveBetaCommunity(alpha), - c => c.community_actions?.follow_state === "Accepted", + c => c?.community_actions?.follow_state === "Accepted", ); // Make sure the follow response went through @@ -80,7 +80,7 @@ test("Follow federated community", async () => { // check that unfollow was federated let communityOnBeta1 = await resolveBetaCommunity(beta); - expect(communityOnBeta1.community.subscribers).toBe( + expect(communityOnBeta1?.community.subscribers).toBe( betaCommunityInitial.community.subscribers + 1, ); @@ -114,10 +114,11 @@ test("Follow federated community", async () => { // check that unfollow was federated let communityOnBeta2 = await waitUntil( () => resolveBetaCommunity(beta), - c => c.community.subscribers === betaCommunityInitial.community.subscribers, + c => + c?.community.subscribers === betaCommunityInitial.community.subscribers, ); - expect(communityOnBeta2.community.subscribers).toBe( + expect(communityOnBeta2?.community.subscribers).toBe( betaCommunityInitial.community.subscribers, ); - expect(communityOnBeta2.community.subscribers_local).toBe(1); + expect(communityOnBeta2?.community.subscribers_local).toBe(1); }); diff --git a/api_tests/src/image.spec.ts b/api_tests/src/image.spec.ts index 2f00f2014..822e109b9 100644 --- a/api_tests/src/image.spec.ts +++ b/api_tests/src/image.spec.ts @@ -146,7 +146,7 @@ test("Purge post, linked image removed", async () => { expect(content.length).toBeGreaterThan(0); let community = await resolveBetaCommunity(user); - let post = await createPost(user, community.community.id, upload.image_url); + let post = await createPost(user, community!.community.id, upload.image_url); expect(post.post_view.post.url).toBe(upload.image_url); expect(post.post_view.image_details).toBeDefined(); @@ -191,12 +191,12 @@ test("Images in remote image post are proxied if setting enabled", async () => { expect(post.thumbnail_url?.includes(".jpg")).toBeTruthy(); let epsilonPostRes = await resolvePost(epsilon, postRes.post_view.post); - expect(epsilonPostRes.post).toBeDefined(); + expect(epsilonPostRes?.post).toBeDefined(); // Fetch the post again, the metadata should be backgrounded now // Wait for the metadata to get fetched, since this is backgrounded now let epsilonPostRes2 = await waitUntil( - () => getPost(epsilon, epsilonPostRes.post.id), + () => getPost(epsilon, epsilonPostRes!.post.id), p => p.post_view.post.thumbnail_url != undefined, ); const epsilonPost = epsilonPostRes2.post_view.post; @@ -238,10 +238,10 @@ test("Thumbnail of remote image link is proxied if setting enabled", async () => expect(post.thumbnail_url?.includes(".png")).toBeTruthy(); let epsilonPostRes = await resolvePost(epsilon, postRes.post_view.post); - expect(epsilonPostRes.post).toBeDefined(); + expect(epsilonPostRes?.post).toBeDefined(); let epsilonPostRes2 = await waitUntil( - () => getPost(epsilon, epsilonPostRes.post.id), + () => getPost(epsilon, epsilonPostRes!.post.id), p => p.post_view.post.thumbnail_url != undefined, ); const epsilonPost = epsilonPostRes2.post_view.post; @@ -263,7 +263,7 @@ test("No image proxying if setting is disabled", async () => { beta, community.community_view.community.ap_id, ); - await followCommunity(beta, true, betaCommunity.community.id); + await followCommunity(beta, true, betaCommunity!.community.id); const upload_form: UploadImage = { image: Buffer.from("test"), diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index cb5e0973e..c30247007 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -54,6 +54,7 @@ import { ReportCombinedView, ResolveObject, ResolvePostReport, + LemmyError, } from "lemmy-js-client"; let betaCommunity: CommunityView | undefined; @@ -66,7 +67,7 @@ beforeAll(async () => { // Hack: Force outgoing federation queue for beta to be created on epsilon, // otherwise report test fails let person = await resolvePerson(epsilon, "@lemmy_beta@lemmy-beta:8551"); - expect(person.person).toBeDefined(); + expect(person?.person).toBeDefined(); }); afterAll(unfollows); @@ -98,7 +99,7 @@ async function assertPostFederation( expect(postOne?.post.embed_title).toBe(postTwo?.post.embed_title); expect(postOne?.post.embed_description).toBe(postTwo?.post.embed_description); expect(postOne?.post.embed_video_url).toBe(postTwo?.post.embed_video_url); - expect(postOne?.post.published).toBe(postTwo?.post.published); + expect(postOne?.post.published_at).toBe(postTwo?.post.published_at); expect(postOne?.community.ap_id).toBe(postTwo?.community.ap_id); expect(postOne?.post.locked).toBe(postTwo?.post.locked); expect(postOne?.post.removed).toBe(postTwo?.post.removed); @@ -144,12 +145,12 @@ test("Create a post", async () => { // Delta only follows beta, so it should not see an alpha ap_id await expect( resolvePost(delta, postRes.post_view.post), - ).rejects.toStrictEqual(Error("not_found")); + ).rejects.toStrictEqual(new LemmyError("not_found")); // Epsilon has alpha blocked, it should not see the alpha post await expect( resolvePost(epsilon, postRes.post_view.post), - ).rejects.toStrictEqual(Error("not_found")); + ).rejects.toStrictEqual(new LemmyError("not_found")); // remove blocked instance block_instance_params.block = false; @@ -157,7 +158,9 @@ test("Create a post", async () => { }); test("Create a post in a non-existent community", async () => { - await expect(createPost(alpha, -2)).rejects.toStrictEqual(Error("not_found")); + await expect(createPost(alpha, -2)).rejects.toStrictEqual( + new LemmyError("not_found"), + ); }); test("Unlike a post", async () => { @@ -208,7 +211,7 @@ test("Update a post", async () => { // Make sure lemmy beta cannot update the post await expect(editPost(beta, betaPost.post)).rejects.toStrictEqual( - Error("no_post_edit_allowed"), + new LemmyError("no_post_edit_allowed"), ); }); @@ -282,7 +285,7 @@ test("Lock a post", async () => { await followCommunity(alpha, true, betaCommunity.community.id); await waitUntil( () => resolveBetaCommunity(alpha), - c => c.community_actions?.follow_state == "Accepted", + c => c?.community_actions?.follow_state == "Accepted", ); let postRes = await createPost(alpha, betaCommunity.community.id); @@ -302,7 +305,7 @@ test("Lock a post", async () => { // user account because admins/mods can comment in locked posts. let user = await registerUser(alpha, alphaUrl); await expect(createComment(user, alphaPost1.post.id)).rejects.toStrictEqual( - Error("locked"), + new LemmyError("locked"), ); // Unlock a post @@ -359,7 +362,7 @@ test("Delete a post", async () => { // Make sure lemmy beta cannot delete the post await expect(deletePost(beta, true, betaPost2.post)).rejects.toStrictEqual( - Error("no_post_edit_allowed"), + new LemmyError("no_post_edit_allowed"), ); }); @@ -370,7 +373,7 @@ test("Remove a post from admin and community on different instance", async () => let gammaCommunity = ( await resolveCommunity(gamma, betaCommunity.community.ap_id) - ).community; + )?.community; if (!gammaCommunity) { throw "Missing gamma community"; } @@ -410,7 +413,7 @@ test("Remove a post from admin and community on same instance", async () => { gamma, betaCommunity.community.ap_id, ); - let postRes = await createPost(gamma, gammaCommunity.community.id); + let postRes = await createPost(gamma, gammaCommunity!.community.id); expect(postRes.post_view.post).toBeDefined(); // Get the id for beta let betaPost = await waitForPost(beta, postRes.post_view.post); @@ -499,9 +502,11 @@ test("Enforce site ban federation for local user", async () => { // alpha ban should be federated to beta let alphaUserOnBeta1 = await waitUntil( () => resolvePerson(beta, alphaUserActorId!), - res => res.home_instance_actions?.received_ban != null, + res => res?.home_instance_actions?.received_ban_at != null, ); - expect(alphaUserOnBeta1.home_instance_actions?.received_ban).toBeDefined(); + expect( + alphaUserOnBeta1?.home_instance_actions?.received_ban_at, + ).toBeDefined(); // existing alpha post should be removed on beta let betaBanRes = await waitUntil( @@ -557,9 +562,11 @@ test("Enforce site ban federation for federated user", async () => { await followBeta(alphaUserHttp); let alphaUserOnBeta2 = await resolvePerson(beta, alphaUserActorId!); - expect(alphaUserOnBeta2.local_instance_actions?.received_ban).toBeUndefined(); + expect( + alphaUserOnBeta2?.local_instance_actions?.received_ban_at, + ).toBeUndefined(); - if (!alphaUserOnBeta2.person) { + if (!alphaUserOnBeta2?.person) { throw "Missing alpha person"; } @@ -590,7 +597,7 @@ test("Enforce site ban federation for federated user", async () => { // User should not be shown to be banned from alpha let alphaPerson2 = (await getMyUser(alphaUserHttp)).local_user_view; - expect(alphaPerson2.instance_actions?.received_ban).toBeUndefined(); + expect(alphaPerson2.instance_actions?.received_ban_at).toBeUndefined(); // but the ban should be indicated by beta community on alpha let communityWithBan = await getCommunity( @@ -598,13 +605,13 @@ test("Enforce site ban federation for federated user", async () => { betaCommunity.community.id, ); expect( - communityWithBan.community_view.instance_actions?.received_ban, + communityWithBan.community_view.instance_actions?.received_ban_at, ).toBeDefined(); // post to beta community is rejected await expect( createPost(alphaUserHttp, betaCommunity.community.id), - ).rejects.toStrictEqual(Error("site_ban")); + ).rejects.toStrictEqual(new LemmyError("site_ban")); await unfollowRemotes(alpha); }); @@ -643,16 +650,16 @@ test("Enforce community ban for federated user", async () => { ); expect(removePostRes.post_view.post.removed).toBe(true); expect( - removePostRes.post_view.creator_community_actions?.received_ban, + removePostRes.post_view.creator_community_actions?.received_ban_at, ).toBeDefined(); expect( - removePostRes.community_view.community_actions?.received_ban, + removePostRes.community_view.community_actions?.received_ban_at, ).toBeDefined(); // Alpha tries to make post on beta, but it fails because of ban await expect( createPost(alpha, betaCommunity.community.id), - ).rejects.toStrictEqual(Error("person_is_banned_from_community")); + ).rejects.toStrictEqual(new LemmyError("person_is_banned_from_community")); // Unban alpha let unBanAlpha = await banPersonFromCommunity( @@ -681,7 +688,7 @@ test("Enforce community ban for federated user", async () => { // Make sure that post makes it to beta community let postRes4 = await waitForPost(beta, postRes3.post_view.post); expect(postRes4.post).toBeDefined(); - expect(postRes4.creator_community_actions?.received_ban).toBeUndefined(); + expect(postRes4.creator_community_actions?.received_ban_at).toBeUndefined(); await unfollowRemotes(alpha); }); @@ -704,7 +711,7 @@ test("Report a post", async () => { // Create post from alpha let alphaCommunity = await resolveBetaCommunity(alpha); await followBeta(alpha); - let alphaPost = await createPost(alpha, alphaCommunity.community.id); + let alphaPost = await createPost(alpha, alphaCommunity!.community.id); expect(alphaPost.post_view.post).toBeDefined(); // add remote mod on epsilon @@ -716,8 +723,8 @@ test("Report a post", async () => { "@lemmy_epsilon@lemmy-epsilon:8581", ); let mod_params: AddModToCommunity = { - community_id: betaCommunity.community.id, - person_id: epsilonUser.person.id, + community_id: betaCommunity!.community.id, + person_id: epsilonUser!.person.id, added: true, }; let res = await beta.addModToCommunity(mod_params); @@ -726,7 +733,7 @@ test("Report a post", async () => { // Send report from gamma let gammaPost = await resolvePost(gamma, alphaPost.post_view.post); let gammaReport = ( - await reportPost(gamma, gammaPost.post.id, randomString(10)) + await reportPost(gamma, gammaPost!.post.id, randomString(10)) ).post_report_view.post_report; expect(gammaReport).toBeDefined(); @@ -829,9 +836,13 @@ test("Fetch post via redirect", async () => { let form: ResolveObject = { q, }; - let gammaPost = (await gamma.resolveObject(form)).results[0] as PostView; + let gammaPost = await gamma + .resolveObject(form) + .then(a => a.results.at(0)) + .then(a => (a?.type_ == "Post" ? a : undefined)); + expect(gammaPost).toBeDefined(); - expect(gammaPost.post.ap_id).toBe(alphaPost.post_view.post.ap_id); + expect(gammaPost?.post.ap_id).toBe(alphaPost.post_view.post.ap_id); await unfollowRemotes(alpha); }); @@ -850,7 +861,7 @@ test("Block post that contains banned URL", async () => { expect( createPost(epsilon, betaCommunity.community.id, "https://evil.com"), - ).rejects.toStrictEqual(Error("blocked_url")); + ).rejects.toStrictEqual(new LemmyError("blocked_url")); // Later tests need this to be empty editSiteForm.blocked_urls = []; @@ -863,18 +874,22 @@ test("Fetch post with redirect", async () => { // beta fetches from alpha as usual let betaPost = await resolvePost(beta, alphaPost.post_view.post); - expect(betaPost.post).toBeDefined(); + expect(betaPost?.post).toBeDefined(); // gamma fetches from beta, and gets redirected to alpha - let gammaPost = await resolvePost(gamma, betaPost.post); - expect(gammaPost.post).toBeDefined(); + let gammaPost = await resolvePost(gamma, betaPost!.post); + expect(gammaPost?.post).toBeDefined(); // fetch remote object from local url, which redirects to the original url let form: ResolveObject = { - q: `http://lemmy-gamma:8561/post/${gammaPost.post.id}`, + q: `http://lemmy-gamma:8561/post/${gammaPost?.post.id}`, }; - let gammaPost2 = (await gamma.resolveObject(form)).results[0] as PostView; - expect(gammaPost2.post).toBeDefined(); + let gammaPost2 = await gamma + .resolveObject(form) + .then(a => a.results.at(0)) + .then(a => (a?.type_ == "Post" ? a : undefined)); + + expect(gammaPost2?.post).toBeDefined(); }); test("Mention beta from alpha post body", async () => { @@ -919,12 +934,12 @@ test("Rewrite markdown links", async () => { const community = await resolveBetaCommunity(beta); // create a post - let postRes1 = await createPost(beta, community.community.id); + let postRes1 = await createPost(beta, community!.community.id); // link to this post in markdown let postRes2 = await createPost( beta, - community.community.id, + community!.community.id, "https://example.com/", `[link](${postRes1.post_view.post.ap_id})`, ); @@ -935,8 +950,8 @@ test("Rewrite markdown links", async () => { const alphaPost2 = await resolvePost(alpha, postRes2.post_view.post); // remote markdown link is replaced with local link - expect(alphaPost2.post.body).toBe( - `[link](http://lemmy-alpha:8541/post/${alphaPost1.post.id})`, + expect(alphaPost2?.post.body).toBe( + `[link](http://lemmy-alpha:8541/post/${alphaPost1?.post.id})`, ); }); @@ -965,22 +980,23 @@ test("Don't allow NSFW posts on instances that disable it", async () => { // Gamma reject resolving the post await expect( resolvePost(gamma, updatePost.post_view.post), - ).rejects.toStrictEqual(Error("not_found")); + ).rejects.toStrictEqual(new LemmyError("not_found")); // Local users can't create NSFW post on Gamma - let gammaCommunity = ( - await resolveCommunity(gamma, betaCommunity.community.ap_id) - ).community; + let gammaCommunity = await resolveCommunity( + gamma, + betaCommunity.community.ap_id, + ); if (!gammaCommunity) { throw "Missing gamma community"; } - let gammaPost = await createPost(gamma, gammaCommunity.id); + let gammaPost = await createPost(gamma, gammaCommunity.community.id); let form2: EditPost = { nsfw: true, post_id: gammaPost.post_view.post.id, }; await expect(gamma.editPost(form2)).rejects.toStrictEqual( - Error("nsfw_not_allowed"), + new LemmyError("nsfw_not_allowed"), ); }); @@ -1003,7 +1019,9 @@ test("Plugin test", async () => { randomString(10), "Java", ), - ).rejects.toStrictEqual(Error("plugin_error")); + ).rejects.toStrictEqual( + new LemmyError("plugin_error", "We dont talk about Java"), + ); }); function checkPostReportName(rcv: ReportCombinedView, report: PostReport) { diff --git a/api_tests/src/private_community.spec.ts b/api_tests/src/private_community.spec.ts index 7f263ebec..5dd486ea4 100644 --- a/api_tests/src/private_community.spec.ts +++ b/api_tests/src/private_community.spec.ts @@ -1,6 +1,6 @@ jest.setTimeout(120000); -import { FollowCommunity, LemmyHttp } from "lemmy-js-client"; +import { FollowCommunity, LemmyError, LemmyHttp } from "lemmy-js-client"; import { alpha, setupLogins, @@ -140,20 +140,20 @@ test("Only followers can view and interact with private community content", asyn const user = await registerUser(beta, betaUrl); const betaCommunity = ( await resolveCommunity(user, community.community_view.community.ap_id) - ).community; + )?.community; await expect(resolvePost(user, post0.post_view.post)).rejects.toStrictEqual( - Error("not_found"), + new LemmyError("not_found"), ); await expect( resolveComment(user, comment.comment_view.comment), - ).rejects.toStrictEqual(Error("not_found")); - await expect(createPost(user, betaCommunity.id)).rejects.toStrictEqual( - Error("not_found"), + ).rejects.toStrictEqual(new LemmyError("not_found")); + await expect(createPost(user, betaCommunity!.id)).rejects.toStrictEqual( + new LemmyError("not_found"), ); // follow the community and approve const follow_form: FollowCommunity = { - community_id: betaCommunity.id, + community_id: betaCommunity!.id, follow: true, }; await user.followCommunity(follow_form); @@ -170,7 +170,7 @@ test("Only followers can view and interact with private community content", asyn ); expect(resolvedComment?.comment.id).toBeDefined(); - const post1 = await createPost(user, betaCommunity.id); + const post1 = await createPost(user, betaCommunity!.id); expect(post1.post_view).toBeDefined(); const like = await likeComment(user, 1, resolvedComment!.comment); expect(like.comment_view.comment_actions?.like_score).toBe(1); @@ -186,11 +186,11 @@ test("Reject follower", async () => { const user = await registerUser(beta, betaUrl); const betaCommunity1 = ( await resolveCommunity(user, community.community_view.community.ap_id) - ).community; + )?.community; // follow the community and reject const follow_form: FollowCommunity = { - community_id: betaCommunity1.id, + community_id: betaCommunity1!.id, follow: true, }; const follow = await user.followCommunity(follow_form); @@ -211,7 +211,7 @@ test("Reject follower", async () => { expect(approve.success).toBe(true); await waitUntil( - () => getCommunity(user, betaCommunity1.id), + () => getCommunity(user, betaCommunity1!.id), c => c.community_view.community_actions?.follow_state === undefined, ); }); @@ -236,9 +236,10 @@ test("Follow a private community and receive activities", async () => { await beta.followCommunity(follow_form_beta); await approveFollower(alpha, alphaCommunityId); - const gammaCommunityId = ( - await resolveCommunity(gamma, community.community_view.community.ap_id) - ).community.id; + const gammaCommunityId = (await resolveCommunity( + gamma, + community.community_view.community.ap_id, + ))!.community.id; const follow_form_gamma: FollowCommunity = { community_id: gammaCommunityId, follow: true, @@ -289,9 +290,10 @@ test("Fetch remote content in private community", async () => { expect(community.community_view.community.visibility).toBe("Private"); const alphaCommunityId = community.community_view.community.id; - const betaCommunityId = ( - await resolveCommunity(beta, community.community_view.community.ap_id) - ).community.id; + const betaCommunityId = (await resolveCommunity( + beta, + community.community_view.community.ap_id, + ))!.community.id; const follow_form_beta: FollowCommunity = { community_id: betaCommunityId, follow: true, @@ -320,9 +322,10 @@ test("Fetch remote content in private community", async () => { ); // create gamma user - const gammaCommunityId = ( - await resolveCommunity(gamma, community.community_view.community.ap_id) - ).community.id; + const gammaCommunityId = (await resolveCommunity( + gamma, + community.community_view.community.ap_id, + ))!.community.id; const follow_form: FollowCommunity = { community_id: gammaCommunityId, follow: true, @@ -330,7 +333,7 @@ test("Fetch remote content in private community", async () => { // cannot fetch post yet await expect(resolvePost(gamma, post.post_view.post)).rejects.toStrictEqual( - Error("not_found"), + new LemmyError("not_found"), ); // follow community and approve await gamma.followCommunity(follow_form); @@ -342,7 +345,7 @@ test("Fetch remote content in private community", async () => { () => resolvePost(gamma, post.post_view.post), p => p?.post.id != undefined, ); - expect(resolvedPost.post.ap_id).toBe(post.post_view.post.ap_id); + expect(resolvedPost?.post.ap_id).toBe(post.post_view.post.ap_id); const resolvedComment = await waitUntil( () => resolveComment(gamma, comment.comment_view.comment), p => p?.comment.id != undefined, diff --git a/api_tests/src/private_message.spec.ts b/api_tests/src/private_message.spec.ts index 8f3b0a36e..85c289a17 100644 --- a/api_tests/src/private_message.spec.ts +++ b/api_tests/src/private_message.spec.ts @@ -1,5 +1,5 @@ jest.setTimeout(120000); -import { PrivateMessageView } from "lemmy-js-client"; +import { LemmyError, PrivateMessageView } from "lemmy-js-client"; import { alpha, beta, @@ -132,7 +132,7 @@ test("Create a private message report", async () => { pmRes.private_message_view.private_message.id, "a reason", ), - ).rejects.toStrictEqual(Error("couldnt_create_report")); + ).rejects.toStrictEqual(new LemmyError("couldnt_create_report")); // This one should pass let reason = "another reason"; diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 985ce3f91..fea641738 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -29,8 +29,8 @@ import { InboxDataType, GetModlogResponse, GetModlog, - CommentView, CommunityView, + CommentView, PersonView, } from "lemmy-js-client"; import { CreatePost } from "lemmy-js-client/dist/types/CreatePost"; @@ -312,25 +312,28 @@ export async function lockPost( export async function resolvePost( api: LemmyHttp, post: Post, -): Promise { +): Promise { let form: ResolveObject = { q: post.ap_id, }; - let res = await api.resolveObject(form); - return res.results[0] as PostView; + return api + .resolveObject(form) + .then(a => a.results.at(0)) + .then(a => (a?.type_ == "Post" ? a : undefined)); } export async function searchPostLocal( api: LemmyHttp, post: Post, -): Promise { +): Promise { let form: Search = { search_term: post.name, type_: "Posts", listing_type: "All", }; let res = await api.search(form); - return res.results[0] as PostView; + let first = res.results.at(0); + return first?.type_ == "Post" ? first : undefined; } /// wait for a post to appear locally without pulling it @@ -339,7 +342,10 @@ export async function waitForPost( post: Post, checker: (t: PostView | undefined) => boolean = p => !!p, ) { - return waitUntil(() => searchPostLocal(api, post), checker); + return waitUntil( + () => searchPostLocal(api, post), + checker, + ) as Promise; } export async function getPost( @@ -387,45 +393,53 @@ export async function listInbox( export async function resolveComment( api: LemmyHttp, comment: Comment, -): Promise { +): Promise { let form: ResolveObject = { q: comment.ap_id, }; - let res = await api.resolveObject(form); - return res.results[0] as CommentView; + return api + .resolveObject(form) + .then(a => a.results.at(0)) + .then(a => (a?.type_ == "Comment" ? a : undefined)); } export async function resolveBetaCommunity( api: LemmyHttp, -): Promise { +): Promise { // Use short-hand search url let form: ResolveObject = { q: "!main@lemmy-beta:8551", }; - let res = await api.resolveObject(form); - return res.results[0] as CommunityView; + return api + .resolveObject(form) + .then(a => a.results.at(0)) + .then(a => (a?.type_ == "Community" ? a : undefined)); } export async function resolveCommunity( api: LemmyHttp, q: string, -): Promise { +): Promise { let form: ResolveObject = { q, }; - let res = await api.resolveObject(form); - return res.results[0] as CommunityView; + return api + .resolveObject(form) + .then(a => a.results.at(0)) + .then(a => (a?.type_ == "Community" ? a : undefined)); } export async function resolvePerson( api: LemmyHttp, apShortname: string, -): Promise { +): Promise { let form: ResolveObject = { q: apShortname, }; - let res = await api.resolveObject(form); - return res.results[0] as PersonView; + return api + .resolveObject(form) + .then(a => a.results.at(0)) + .then(a => (a?.type_ == "Person" ? a : undefined)); } export async function banPersonFromSite( diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index 645eab3c4..ae1e0d6ae 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -27,6 +27,7 @@ import { } from "./shared"; import { EditSite, + LemmyError, LemmyHttp, SaveUserSettings, UploadImage, @@ -45,7 +46,7 @@ function assertUserFederation(userOne?: PersonView, userTwo?: PersonView) { expect(userOne?.person.ap_id).toBe(userTwo?.person.ap_id); expect(userOne?.person.avatar).toBe(userTwo?.person.avatar); expect(userOne?.person.banner).toBe(userTwo?.person.banner); - expect(userOne?.person.published).toBe(userTwo?.person.published); + expect(userOne?.person.published_at).toBe(userTwo?.person.published_at); } test("Create user", async () => { @@ -102,9 +103,11 @@ test("Delete user", async () => { expect(remoteComment).toBeDefined(); await deleteUser(user); - await expect(getMyUser(user)).rejects.toStrictEqual(Error("incorrect_login")); + await expect(getMyUser(user)).rejects.toStrictEqual( + new LemmyError("incorrect_login"), + ); await expect(getPersonDetails(user, person_id)).rejects.toStrictEqual( - Error("not_found"), + new LemmyError("not_found"), ); // check that posts and comments are marked as deleted on other instances. @@ -125,7 +128,7 @@ test("Delete user", async () => { ).toBe(true); await expect( getPersonDetails(user, remoteComment.creator_id), - ).rejects.toStrictEqual(Error("not_found")); + ).rejects.toStrictEqual(new LemmyError("not_found")); }); test("Requests with invalid auth should be treated as unauthenticated", async () => { @@ -134,7 +137,7 @@ test("Requests with invalid auth should be treated as unauthenticated", async () fetchFunction, }); await expect(getMyUser(invalid_auth)).rejects.toStrictEqual( - Error("incorrect_login"), + new LemmyError("incorrect_login"), ); let site = await getSite(invalid_auth); expect(site.site_view).toBeDefined(); diff --git a/crates/api/api/src/community/ban.rs b/crates/api/api/src/community/ban.rs index 887e68e69..c16f57d66 100644 --- a/crates/api/api/src/community/ban.rs +++ b/crates/api/api/src/community/ban.rs @@ -30,7 +30,7 @@ pub async fn ban_from_community( local_user_view: LocalUserView, ) -> LemmyResult> { let banned_person_id = data.person_id; - let expires = check_expire_time(data.expires)?; + let expires_at = check_expire_time(data.expires_at)?; let local_instance_id = local_user_view.person.instance_id; let community = Community::read(&mut context.pool(), data.community_id).await?; @@ -50,7 +50,7 @@ pub async fn ban_from_community( } let community_user_ban_form = CommunityPersonBanForm { - ban_expires: Some(expires), + ban_expires_at: Some(expires_at), ..CommunityPersonBanForm::new(data.community_id, data.person_id) }; @@ -92,7 +92,7 @@ pub async fn ban_from_community( community_id: tx_data.community_id, reason: tx_data.reason.clone(), banned: Some(tx_data.ban), - expires, + expires_at, }; ModBanFromCommunity::create(&mut conn.into(), &form).await?; diff --git a/crates/api/api/src/community/tag.rs b/crates/api/api/src/community/tag.rs index d33aeeab3..35100024d 100644 --- a/crates/api/api/src/community/tag.rs +++ b/crates/api/api/src/community/tag.rs @@ -51,7 +51,7 @@ pub async fn update_community_tag( // Update the tag let tag_form = TagUpdateForm { display_name: Some(data.display_name.clone()), - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), ..Default::default() }; @@ -73,7 +73,7 @@ pub async fn delete_community_tag( // Soft delete the tag let tag_form = TagUpdateForm { - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), deleted: Some(true), ..Default::default() }; diff --git a/crates/api/api/src/local_user/ban_person.rs b/crates/api/api/src/local_user/ban_person.rs index 53daee474..8504e8560 100644 --- a/crates/api/api/src/local_user/ban_person.rs +++ b/crates/api/api/src/local_user/ban_person.rs @@ -42,9 +42,13 @@ pub async fn ban_from_site( is_valid_body_field(reason, false)?; } - let expires = check_expire_time(data.expires)?; + let expires_at = check_expire_time(data.expires_at)?; - let form = InstanceBanForm::new(data.person_id, local_user_view.person.instance_id, expires); + let form = InstanceBanForm::new( + data.person_id, + local_user_view.person.instance_id, + expires_at, + ); if data.ban { InstanceActions::ban(&mut context.pool(), &form).await?; } else { @@ -70,7 +74,7 @@ pub async fn ban_from_site( other_person_id: data.person_id, reason: data.reason.clone(), banned: Some(data.ban), - expires, + expires_at, instance_id: local_user_view.person.instance_id, }; @@ -91,7 +95,7 @@ pub async fn ban_from_site( reason: data.reason.clone(), remove_or_restore_data: data.remove_or_restore_data, ban: data.ban, - expires: data.expires, + expires_at: data.expires_at, }, &context, )?; diff --git a/crates/api/api/src/local_user/donation_dialog_shown.rs b/crates/api/api/src/local_user/donation_dialog_shown.rs index 0688338a0..2195edcb3 100644 --- a/crates/api/api/src/local_user/donation_dialog_shown.rs +++ b/crates/api/api/src/local_user/donation_dialog_shown.rs @@ -11,7 +11,7 @@ pub async fn donation_dialog_shown( local_user_view: LocalUserView, ) -> LemmyResult> { let form = LocalUserUpdateForm { - last_donation_notification: Some(Utc::now()), + last_donation_notification_at: Some(Utc::now()), ..Default::default() }; LocalUser::update(&mut context.pool(), local_user_view.local_user.id, &form).await?; diff --git a/crates/api/api/src/site/admin_allow_instance.rs b/crates/api/api/src/site/admin_allow_instance.rs index 1a24603d7..f59b7a5d4 100644 --- a/crates/api/api/src/site/admin_allow_instance.rs +++ b/crates/api/api/src/site/admin_allow_instance.rs @@ -31,7 +31,7 @@ pub async fn admin_allow_instance( .id; let form = FederationAllowListForm { instance_id, - updated: None, + updated_at: None, }; if data.allow { FederationAllowList::allow(&mut context.pool(), &form).await?; diff --git a/crates/api/api/src/site/admin_block_instance.rs b/crates/api/api/src/site/admin_block_instance.rs index 4b5fa1eda..ad5895436 100644 --- a/crates/api/api/src/site/admin_block_instance.rs +++ b/crates/api/api/src/site/admin_block_instance.rs @@ -31,8 +31,8 @@ pub async fn admin_block_instance( .id; let form = FederationBlockListForm { instance_id, - expires: data.expires, - updated: None, + expires_at: data.expires_at, + updated_at: None, }; if data.block { diff --git a/crates/api/api/src/site/purge/person.rs b/crates/api/api/src/site/purge/person.rs index 113563c67..5b04eb9a1 100644 --- a/crates/api/api/src/site/purge/person.rs +++ b/crates/api/api/src/site/purge/person.rs @@ -46,7 +46,7 @@ pub async fn purge_person( reason: data.reason.clone(), remove_or_restore_data: Some(true), ban: true, - expires: None, + expires_at: None, }, &context, )?; diff --git a/crates/api/api_common/src/federation.rs b/crates/api/api_common/src/federation.rs index ace2ca86f..ace154d43 100644 --- a/crates/api/api_common/src/federation.rs +++ b/crates/api/api_common/src/federation.rs @@ -8,7 +8,7 @@ pub use lemmy_db_schema::{ }, }; pub use lemmy_db_schema_file::enums::FederationMode; -pub use lemmy_db_views_api_misc::{ResolveObject, ResolveObjectResponse, UserBlockInstanceParams}; +pub use lemmy_db_views_api_misc::{ResolveObject, UserBlockInstanceParams}; pub use lemmy_db_views_readable_federation_state::ReadableFederationState; pub use lemmy_db_views_site::api::{ FederatedInstances, diff --git a/crates/api/api_crud/src/comment/update.rs b/crates/api/api_crud/src/comment/update.rs index be8f2eee7..ef7efef1f 100644 --- a/crates/api/api_crud/src/comment/update.rs +++ b/crates/api/api_crud/src/comment/update.rs @@ -70,7 +70,7 @@ pub async fn update_comment( let mut form = CommentUpdateForm { content, language_id: Some(language_id), - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), ..Default::default() }; form = plugin_hook_before("before_update_local_comment", form).await?; diff --git a/crates/api/api_crud/src/community/update.rs b/crates/api/api_crud/src/community/update.rs index 0953db4f5..c590e26f0 100644 --- a/crates/api/api_crud/src/community/update.rs +++ b/crates/api/api_crud/src/community/update.rs @@ -80,7 +80,7 @@ pub async fn update_community( nsfw: data.nsfw, posting_restricted_to_mods: data.posting_restricted_to_mods, visibility: data.visibility, - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), ..Default::default() }; diff --git a/crates/api/api_crud/src/oauth_provider/update.rs b/crates/api/api_crud/src/oauth_provider/update.rs index 1a6542a54..bc16798b5 100644 --- a/crates/api/api_crud/src/oauth_provider/update.rs +++ b/crates/api/api_crud/src/oauth_provider/update.rs @@ -34,7 +34,7 @@ pub async fn update_oauth_provider( account_linking_enabled: data.account_linking_enabled, enabled: data.enabled, use_pkce: data.use_pkce, - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), }; let update_result = diff --git a/crates/api/api_crud/src/post/create.rs b/crates/api/api_crud/src/post/create.rs index 853f04105..329c6122d 100644 --- a/crates/api/api_crud/src/post/create.rs +++ b/crates/api/api_crud/src/post/create.rs @@ -117,8 +117,8 @@ pub async fn create_post( ) .await?; - let scheduled_publish_time = - convert_published_time(data.scheduled_publish_time, &local_user_view, &context).await?; + let scheduled_publish_time_at = + convert_published_time(data.scheduled_publish_time_at, &local_user_view, &context).await?; let mut post_form = PostInsertForm { url, body, @@ -126,7 +126,7 @@ pub async fn create_post( nsfw, language_id: Some(language_id), federation_pending: Some(community_use_pending(community, &context).await), - scheduled_publish_time, + scheduled_publish_time_at, ..PostInsertForm::new( data.name.trim().to_string(), local_user_view.person.id, @@ -152,7 +152,7 @@ pub async fn create_post( } let community_id = community.id; - let federate_post = if scheduled_publish_time.is_none() { + let federate_post = if scheduled_publish_time_at.is_none() { send_webmention(inserted_post.clone(), community); |post| Some(SendActivityData::CreatePost(post)) } else { diff --git a/crates/api/api_crud/src/post/update.rs b/crates/api/api_crud/src/post/update.rs index 638048055..3bdb6de53 100644 --- a/crates/api/api_crud/src/post/update.rs +++ b/crates/api/api_crud/src/post/update.rs @@ -132,14 +132,14 @@ pub async fn update_post( .await?; // handle changes to scheduled_publish_time - let scheduled_publish_time = match ( - orig_post.post.scheduled_publish_time, - data.scheduled_publish_time, + let scheduled_publish_time_at = match ( + orig_post.post.scheduled_publish_time_at, + data.scheduled_publish_time_at, ) { // schedule time can be changed if post is still scheduled (and not published yet) - (Some(_), Some(_)) => { - Some(convert_published_time(data.scheduled_publish_time, &local_user_view, &context).await?) - } + (Some(_), Some(_)) => Some( + convert_published_time(data.scheduled_publish_time_at, &local_user_view, &context).await?, + ), // post was scheduled, gets changed to publish immediately (Some(_), None) => Some(None), // unchanged @@ -153,8 +153,8 @@ pub async fn update_post( alt_text, nsfw: data.nsfw, language_id: Some(language_id), - updated: Some(Some(Utc::now())), - scheduled_publish_time, + updated_at: Some(Some(Utc::now())), + scheduled_publish_time_at, ..Default::default() }; post_form = plugin_hook_before("before_update_local_post", post_form).await?; @@ -178,8 +178,8 @@ pub async fn update_post( // send out federation/webmention if necessary match ( - orig_post.post.scheduled_publish_time, - data.scheduled_publish_time, + orig_post.post.scheduled_publish_time_at, + data.scheduled_publish_time_at, ) { // schedule was removed, send create activity and webmention (Some(_), None) => { diff --git a/crates/api/api_crud/src/private_message/update.rs b/crates/api/api_crud/src/private_message/update.rs index 8d254b1ad..bf6f836b6 100644 --- a/crates/api/api_crud/src/private_message/update.rs +++ b/crates/api/api_crud/src/private_message/update.rs @@ -42,7 +42,7 @@ pub async fn update_private_message( let private_message_id = data.private_message_id; let mut form = PrivateMessageUpdateForm { content: Some(content), - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), ..Default::default() }; form = plugin_hook_before("before_update_local_private_message", form).await?; diff --git a/crates/api/api_crud/src/site/create.rs b/crates/api/api_crud/src/site/create.rs index 528b6bfc3..27d8756e7 100644 --- a/crates/api/api_crud/src/site/create.rs +++ b/crates/api/api_crud/src/site/create.rs @@ -94,7 +94,7 @@ pub async fn create_site( default_comment_sort_type: data.default_comment_sort_type, legal_information: diesel_string_update(data.legal_information.as_deref()), application_email_admins: data.application_email_admins, - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), slur_filter_regex: diesel_string_update(data.slur_filter_regex.as_deref()), actor_name_max_length: data.actor_name_max_length, federation_enabled: data.federation_enabled, diff --git a/crates/api/api_crud/src/site/update.rs b/crates/api/api_crud/src/site/update.rs index ee26ba086..70092cc01 100644 --- a/crates/api/api_crud/src/site/update.rs +++ b/crates/api/api_crud/src/site/update.rs @@ -78,7 +78,7 @@ pub async fn update_site( sidebar, description: diesel_string_update(data.description.as_deref()), content_warning: diesel_string_update(data.content_warning.as_deref()), - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), ..Default::default() }; @@ -101,7 +101,7 @@ pub async fn update_site( default_comment_sort_type: data.default_comment_sort_type, legal_information: diesel_string_update(data.legal_information.as_deref()), application_email_admins: data.application_email_admins, - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), slur_filter_regex: diesel_string_update(data.slur_filter_regex.as_deref()), actor_name_max_length: data.actor_name_max_length, federation_enabled: data.federation_enabled, diff --git a/crates/api/api_crud/src/tagline/update.rs b/crates/api/api_crud/src/tagline/update.rs index cdf2c25bc..5ee79b40b 100644 --- a/crates/api/api_crud/src/tagline/update.rs +++ b/crates/api/api_crud/src/tagline/update.rs @@ -27,7 +27,7 @@ pub async fn update_tagline( let tagline_form = TaglineUpdateForm { content, - updated: Some(Some(Utc::now())), + updated_at: Some(Some(Utc::now())), }; let tagline = Tagline::update(&mut context.pool(), data.id, &tagline_form).await?; diff --git a/crates/api/api_utils/src/send_activity.rs b/crates/api/api_utils/src/send_activity.rs index 3bd83134f..450ca755d 100644 --- a/crates/api/api_utils/src/send_activity.rs +++ b/crates/api/api_utils/src/send_activity.rs @@ -91,7 +91,7 @@ pub enum SendActivityData { reason: Option, remove_or_restore_data: Option, ban: bool, - expires: Option, + expires_at: Option, }, CreatePrivateMessage(PrivateMessageView), UpdatePrivateMessage(PrivateMessageView), diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index 8d22a3bd9..5d25afe1d 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -128,7 +128,7 @@ impl ActivityHandler for BlockUser { async fn receive(self, context: &Data) -> LemmyResult<()> { insert_received_activity(&self.id, context).await?; - let expires = self.end_time; + let expires_at = self.end_time; let mod_person = self.actor.dereference(context).await?; let blocked_person = self.object.dereference(context).await?; let target = self.target.dereference(context).await?; @@ -136,7 +136,7 @@ impl ActivityHandler for BlockUser { let pool = &mut context.pool(); match target { SiteOrCommunity::Site(site) => { - let form = InstanceBanForm::new(blocked_person.id, site.instance_id, expires); + let form = InstanceBanForm::new(blocked_person.id, site.instance_id, expires_at); InstanceActions::ban(pool, &form).await?; if self.remove_data.unwrap_or(false) { @@ -155,14 +155,14 @@ impl ActivityHandler for BlockUser { other_person_id: blocked_person.id, reason, banned: Some(true), - expires, + expires_at, instance_id: site.instance_id, }; ModBan::create(&mut context.pool(), &form).await?; } SiteOrCommunity::Community(community) => { let community_user_ban_form = CommunityPersonBanForm { - ban_expires: Some(expires), + ban_expires_at: Some(expires_at), ..CommunityPersonBanForm::new(community.id, blocked_person.id) }; CommunityActions::ban(&mut context.pool(), &community_user_ban_form).await?; @@ -190,7 +190,7 @@ impl ActivityHandler for BlockUser { community_id: community.id, reason, banned: Some(true), - expires, + expires_at, }; ModBanFromCommunity::create(&mut context.pool(), &form).await?; } diff --git a/crates/apub/src/activities/block/mod.rs b/crates/apub/src/activities/block/mod.rs index a77246e20..aac1f9331 100644 --- a/crates/apub/src/activities/block/mod.rs +++ b/crates/apub/src/activities/block/mod.rs @@ -168,7 +168,7 @@ pub(crate) async fn send_ban_from_community( let community: ApubCommunity = Community::read(&mut context.pool(), community_id) .await? .into(); - let expires = check_expire_time(data.expires)?; + let expires_at = check_expire_time(data.expires_at)?; if data.ban { BlockUser::send( @@ -177,7 +177,7 @@ pub(crate) async fn send_ban_from_community( &mod_.into(), data.remove_or_restore_data.unwrap_or(false), data.reason.clone(), - expires, + expires_at, &context, ) .await diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index b9f90cc87..9b39deaee 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -97,14 +97,14 @@ impl ActivityHandler for UndoBlockUser { async fn receive(self, context: &Data) -> LemmyResult<()> { insert_received_activity(&self.id, context).await?; - let expires = self.object.end_time; + let expires_at = self.object.end_time; let mod_person = self.actor.dereference(context).await?; let blocked_person = self.object.object.dereference(context).await?; let pool = &mut context.pool(); match self.object.target.dereference(context).await? { SiteOrCommunity::Site(site) => { verify_is_public(&self.to, &self.cc)?; - let form = InstanceBanForm::new(blocked_person.id, site.instance_id, expires); + let form = InstanceBanForm::new(blocked_person.id, site.instance_id, expires_at); InstanceActions::unban(pool, &form).await?; if self.restore_data.unwrap_or(false) { @@ -123,7 +123,7 @@ impl ActivityHandler for UndoBlockUser { other_person_id: blocked_person.id, reason: self.object.summary, banned: Some(false), - expires, + expires_at, instance_id: site.instance_id, }; ModBan::create(&mut context.pool(), &form).await?; @@ -152,7 +152,7 @@ impl ActivityHandler for UndoBlockUser { community_id: community.id, reason: self.object.summary, banned: Some(false), - expires, + expires_at, }; ModBanFromCommunity::create(&mut context.pool(), &form).await?; } diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs index 56956ac61..5126a5eb4 100644 --- a/crates/apub/src/activities/mod.rs +++ b/crates/apub/src/activities/mod.rs @@ -300,7 +300,7 @@ pub async fn match_outgoing_activities( reason, remove_or_restore_data, ban, - expires, + expires_at, } => { send_ban_from_site( moderator, @@ -308,7 +308,7 @@ pub async fn match_outgoing_activities( reason, remove_or_restore_data, ban, - expires, + expires_at, context, ) .await diff --git a/crates/apub_objects/src/objects/comment.rs b/crates/apub_objects/src/objects/comment.rs index 7e9e68ed0..89917a07d 100644 --- a/crates/apub_objects/src/objects/comment.rs +++ b/crates/apub_objects/src/objects/comment.rs @@ -122,8 +122,8 @@ impl Object for ApubComment { media_type: Some(MediaTypeMarkdownOrHtml::Html), source: Some(Source::new(self.content.clone())), in_reply_to, - published: Some(self.published), - updated: self.updated, + published: Some(self.published_at), + updated: self.updated_at, tag: maa.tags, distinguished: Some(self.distinguished), language, @@ -208,8 +208,8 @@ impl Object for ApubComment { post_id: post.id, content, removed: None, - published: note.published, - updated: note.updated, + published_at: note.published, + updated_at: note.updated, deleted: Some(false), ap_id: Some(note.id.into()), distinguished: note.distinguished, diff --git a/crates/apub_objects/src/objects/community.rs b/crates/apub_objects/src/objects/community.rs index 79de2667a..7ec0235bb 100644 --- a/crates/apub_objects/src/objects/community.rs +++ b/crates/apub_objects/src/objects/community.rs @@ -129,8 +129,8 @@ impl Object for ApubCommunity { endpoints: None, public_key: self.public_key(), language, - published: Some(self.published), - updated: self.updated, + published: Some(self.published_at), + updated: self.updated_at, posting_restricted_to_mods: Some(self.posting_restricted_to_mods), attributed_to: Some(AttributedTo::Lemmy( generate_moderators_url(&self.ap_id)?.into(), @@ -180,8 +180,8 @@ impl Object for ApubCommunity { .map(|_| true); let form = CommunityInsertForm { - published: group.published, - updated: group.updated, + published_at: group.published, + updated_at: group.updated, deleted: Some(false), nsfw: Some(group.sensitive.unwrap_or(false)), ap_id: Some(group.id.clone().into()), diff --git a/crates/apub_objects/src/objects/instance.rs b/crates/apub_objects/src/objects/instance.rs index e2f677278..88d3bf8b1 100644 --- a/crates/apub_objects/src/objects/instance.rs +++ b/crates/apub_objects/src/objects/instance.rs @@ -106,8 +106,8 @@ impl Object for ApubSite { public_key: self.public_key(), language, content_warning: self.content_warning.clone(), - published: self.published, - updated: self.updated, + published: self.published_at, + updated: self.updated_at, }; Ok(instance) } @@ -147,7 +147,7 @@ impl Object for ApubSite { let site_form = SiteInsertForm { name: apub.name.clone(), sidebar, - updated: apub.updated, + updated_at: apub.updated, icon, banner, description: apub.summary, diff --git a/crates/apub_objects/src/objects/person.rs b/crates/apub_objects/src/objects/person.rs index bec5065cf..9651cfcfb 100644 --- a/crates/apub_objects/src/objects/person.rs +++ b/crates/apub_objects/src/objects/person.rs @@ -106,11 +106,11 @@ impl Object for ApubPerson { icon: self.avatar.clone().map(ImageObject::new), image: self.banner.clone().map(ImageObject::new), matrix_user_id: self.matrix_user_id.clone(), - published: Some(self.published), + published: Some(self.published_at), outbox: generate_outbox_url(&self.ap_id)?.into(), endpoints: None, public_key: self.public_key(), - updated: self.updated, + updated: self.updated_at, inbox: self.inbox_url.clone().into(), }; Ok(person) @@ -155,8 +155,8 @@ impl Object for ApubPerson { deleted: Some(false), avatar, banner, - published: person.published, - updated: person.updated, + published_at: person.published, + updated_at: person.updated, ap_id: Some(person.id.into()), bio, local: Some(false), diff --git a/crates/apub_objects/src/objects/post.rs b/crates/apub_objects/src/objects/post.rs index 55285c31a..537cab035 100644 --- a/crates/apub_objects/src/objects/post.rs +++ b/crates/apub_objects/src/objects/post.rs @@ -149,8 +149,8 @@ impl Object for ApubPost { image: self.thumbnail_url.clone().map(ImageObject::new), sensitive: Some(self.nsfw), language, - published: Some(self.published), - updated: self.updated, + published: Some(self.published_at), + updated: self.updated_at, in_reply_to: None, tag: vec![hashtag], }; @@ -284,8 +284,8 @@ impl Object for ApubPost { url: url.map(Into::into), body, alt_text, - published: page.published, - updated: page.updated, + published_at: page.published, + updated_at: page.updated, deleted: Some(false), nsfw, ap_id: Some(page.id.clone().into()), diff --git a/crates/apub_objects/src/objects/private_message.rs b/crates/apub_objects/src/objects/private_message.rs index cd292868b..9d587400f 100644 --- a/crates/apub_objects/src/objects/private_message.rs +++ b/crates/apub_objects/src/objects/private_message.rs @@ -105,8 +105,8 @@ impl Object for ApubPrivateMessage { content: markdown_to_html(&self.content), media_type: Some(MediaTypeHtml::Html), source: Some(Source::new(self.content.clone())), - published: Some(self.published), - updated: self.updated, + published: Some(self.published_at), + updated: self.updated_at, }; Ok(note) } @@ -151,8 +151,8 @@ impl Object for ApubPrivateMessage { creator_id: creator.id, recipient_id: recipient.id, content, - published: note.published, - updated: note.updated, + published_at: note.published, + updated_at: note.updated, deleted: Some(false), read: None, ap_id: Some(note.id.into()), diff --git a/crates/db_perf/src/main.rs b/crates/db_perf/src/main.rs index 9f1634dd0..89fc7577b 100644 --- a/crates/db_perf/src/main.rs +++ b/crates/db_perf/src/main.rs @@ -118,7 +118,7 @@ async fn try_main() -> LemmyResult<()> { post::creator_id, post::community_id, post::featured_community, - post::published, + post::published_at, )) .execute(conn) .await?; @@ -184,8 +184,8 @@ fn site() -> LemmyResult { id: Default::default(), name: String::new(), sidebar: None, - published: Default::default(), - updated: None, + published_at: Default::default(), + updated_at: None, icon: None, banner: None, description: None, diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 0dc7077a7..45bb6b5e2 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -47,7 +47,7 @@ impl Comment { .set(( comment::content.eq(DELETED_REPLACEMENT_TEXT), comment::deleted.eq(true), - comment::updated.eq(Utc::now()), + comment::updated_at.eq(Utc::now()), )) .get_results::(conn) .await @@ -63,7 +63,7 @@ impl Comment { diesel::update(comment::table.filter(comment::creator_id.eq(creator_id))) .set(( comment::removed.eq(removed), - comment::updated.eq(Utc::now()), + comment::updated_at.eq(Utc::now()), )) .get_results::(conn) .await @@ -153,7 +153,7 @@ impl Comment { insert_into(comment::table) .values(comment_form) .on_conflict(comment::ap_id) - .filter_target(coalesce(comment::updated, comment::published).lt(timestamp)) + .filter_target(coalesce(comment::updated_at, comment::published_at).lt(timestamp)) .do_update() .set(comment_form) .get_result::(conn) @@ -196,7 +196,7 @@ impl Comment { let conn = &mut get_conn(pool).await?; diesel::update(comment::table.find(comment_id)) - .set(comment::hot_rank.eq(hot_rank(comment::score, comment::published))) + .set(comment::hot_rank.eq(hot_rank(comment::score, comment::published_at))) .get_result::(conn) .await .with_lemmy_type(LemmyErrorType::CouldntUpdateComment) @@ -268,7 +268,7 @@ impl Likeable for CommentActions { let conn = &mut get_conn(pool).await?; uplete::new(comment_actions::table.find((person_id, comment_id))) .set_null(comment_actions::like_score) - .set_null(comment_actions::liked) + .set_null(comment_actions::liked_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CouldntLikeComment) @@ -292,7 +292,7 @@ impl Saveable for CommentActions { async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(comment_actions::table.find((form.person_id, form.comment_id))) - .set_null(comment_actions::saved) + .set_null(comment_actions::saved_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CouldntSaveComment) @@ -378,8 +378,8 @@ mod tests { removed: false, deleted: false, path: Ltree(format!("0.{}", inserted_comment.id)), - published: inserted_comment.published, - updated: None, + published_at: inserted_comment.published_at, + updated_at: None, ap_id: Url::parse(&format!( "https://lemmy-alpha/comment/{}", inserted_comment.id @@ -416,7 +416,7 @@ mod tests { // Comment Saved let comment_saved_form = CommentSavedForm::new(inserted_person.id, inserted_comment.id); let inserted_comment_saved = CommentActions::save(pool, &comment_saved_form).await?; - assert!(inserted_comment_saved.saved.is_some()); + assert!(inserted_comment_saved.saved_at.is_some()); let comment_update_form = CommentUpdateForm { content: Some("A test comment".into()), diff --git a/crates/db_schema/src/impls/comment_report.rs b/crates/db_schema/src/impls/comment_report.rs index 777435f22..5be576900 100644 --- a/crates/db_schema/src/impls/comment_report.rs +++ b/crates/db_schema/src/impls/comment_report.rs @@ -47,7 +47,7 @@ impl Reportable for CommentReport { .set(( comment_report::resolved.eq(true), comment_report::resolver_id.eq(by_resolver_id), - comment_report::updated.eq(Utc::now()), + comment_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -71,7 +71,7 @@ impl Reportable for CommentReport { .set(( comment_report::resolved.eq(true), comment_report::resolver_id.eq(resolver_id), - comment_report::updated.eq(Utc::now()), + comment_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -88,7 +88,7 @@ impl Reportable for CommentReport { .set(( comment_report::resolved.eq(true), comment_report::resolver_id.eq(by_resolver_id), - comment_report::updated.eq(Utc::now()), + comment_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -110,7 +110,7 @@ impl Reportable for CommentReport { .set(( comment_report::resolved.eq(false), comment_report::resolver_id.eq(by_resolver_id), - comment_report::updated.eq(Utc::now()), + comment_report::updated_at.eq(Utc::now()), )) .execute(conn) .await diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 2a8fe383d..39251c33b 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -104,7 +104,7 @@ impl Joinable for CommunityActions { async fn leave(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(community_actions::table.find((form.person_id, form.community_id))) - .set_null(community_actions::became_moderator) + .set_null(community_actions::became_moderator_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CommunityModeratorAlreadyExists) @@ -132,7 +132,7 @@ impl Community { let community_ = insert_into(community::table) .values(form) .on_conflict(community::ap_id) - .filter_target(coalesce(community::updated, community::published).lt(timestamp)) + .filter_target(coalesce(community::updated_at, community::published_at).lt(timestamp)) .do_update() .set(form) .get_result::(conn) @@ -316,7 +316,7 @@ impl CommunityActions { uplete::new( community_actions::table.filter(community_actions::community_id.eq(for_community_id)), ) - .set_null(community_actions::became_moderator) + .set_null(community_actions::became_moderator_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::NotFound) @@ -328,7 +328,7 @@ impl CommunityActions { ) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(community_actions::table.filter(community_actions::person_id.eq(for_person_id))) - .set_null(community_actions::became_moderator) + .set_null(community_actions::became_moderator_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::NotFound) @@ -340,7 +340,7 @@ impl CommunityActions { ) -> LemmyResult> { let conn = &mut get_conn(pool).await?; community_actions::table - .filter(community_actions::became_moderator.is_not_null()) + .filter(community_actions::became_moderator_at.is_not_null()) .filter(community_actions::person_id.eq(for_person_id)) .select(community_actions::community_id) .load::(conn) @@ -363,10 +363,10 @@ impl CommunityActions { persons.dedup(); let res = community_actions::table - .filter(community_actions::became_moderator.is_not_null()) + .filter(community_actions::became_moderator_at.is_not_null()) .filter(community_actions::community_id.eq(for_community_id)) .filter(community_actions::person_id.eq_any(persons)) - .order_by(community_actions::became_moderator) + .order_by(community_actions::became_moderator_at) .select(community_actions::person_id) // This does a limit 1 select first .first::(conn) @@ -388,7 +388,7 @@ impl CommunityActions { ) -> LemmyResult<()> { let conn = &mut get_conn(pool).await?; let find_action = community_actions::table - .filter(community_actions::followed.is_not_null()) + .filter(community_actions::followed_at.is_not_null()) .filter(community_actions::community_id.eq(remote_community_id)); select(exists(find_action)) .get_result::(conn) @@ -406,7 +406,7 @@ impl CommunityActions { let conn = &mut get_conn(pool).await?; let find_action = community_actions::table .find((follower_id, community_id)) - .filter(community_actions::followed.is_not_null()); + .filter(community_actions::followed_at.is_not_null()); diesel::update(find_action) .set(( community_actions::follow_state.eq(CommunityFollowerState::Accepted), @@ -431,7 +431,7 @@ impl CommunityActions { .try_get_with(person_id, async move { let conn = &mut get_conn(pool).await?; community_actions::table - .filter(community_actions::followed.is_not_null()) + .filter(community_actions::followed_at.is_not_null()) .filter(community_actions::person_id.eq(person_id)) .inner_join(community::table.on(community::id.eq(community_actions::community_id))) .order_by(community::users_active_month.desc()) @@ -467,8 +467,8 @@ impl Bannable for CommunityActions { async fn unban(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(community_actions::table.find((form.person_id, form.community_id))) - .set_null(community_actions::received_ban) - .set_null(community_actions::ban_expires) + .set_null(community_actions::received_ban_at) + .set_null(community_actions::ban_expires_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned) @@ -518,7 +518,7 @@ impl Followable for CommunityActions { ) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(community_actions::table.find((person_id, community_id))) - .set_null(community_actions::followed) + .set_null(community_actions::followed_at) .set_null(community_actions::follow_state) .set_null(community_actions::follow_approver_id) .get_result(conn) @@ -556,7 +556,7 @@ impl Blockable for CommunityActions { community_block_form.person_id, community_block_form.community_id, ))) - .set_null(community_actions::blocked) + .set_null(community_actions::blocked_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CommunityBlockAlreadyExists) @@ -570,7 +570,7 @@ impl Blockable for CommunityActions { let conn = &mut get_conn(pool).await?; let find_action = community_actions::table .find((person_id, community_id)) - .filter(community_actions::blocked.is_not_null()); + .filter(community_actions::blocked_at.is_not_null()); select(not(exists(find_action))) .get_result::(conn) @@ -585,13 +585,13 @@ impl Blockable for CommunityActions { ) -> LemmyResult> { let conn = &mut get_conn(pool).await?; community_actions::table - .filter(community_actions::blocked.is_not_null()) + .filter(community_actions::blocked_at.is_not_null()) .inner_join(community::table) .select(community::all_columns) .filter(community_actions::person_id.eq(person_id)) .filter(community::deleted.eq(false)) .filter(community::removed.eq(false)) - .order_by(community_actions::blocked) + .order_by(community_actions::blocked_at) .load::(conn) .await .with_lemmy_type(LemmyErrorType::NotFound) @@ -722,13 +722,13 @@ mod tests { nsfw: false, removed: false, deleted: false, - published: inserted_community.published, - updated: None, + published_at: inserted_community.published_at, + updated_at: None, ap_id: inserted_community.ap_id.clone(), local: true, private_key: None, public_key: "pubkey".to_owned(), - last_refreshed_at: inserted_community.published, + last_refreshed_at: inserted_community.published_at, icon: None, banner: None, followers_url: inserted_community.followers_url.clone(), @@ -772,7 +772,7 @@ mod tests { CommunityModeratorForm::new(inserted_community.id, inserted_bobby.id); let inserted_bobby_moderator = CommunityActions::join(pool, &bobby_moderator_form).await?; - assert!(inserted_bobby_moderator.became_moderator.is_some()); + assert!(inserted_bobby_moderator.became_moderator_at.is_some()); let artemis_moderator_form = CommunityModeratorForm::new(inserted_community.id, inserted_artemis.id); @@ -817,8 +817,8 @@ mod tests { let inserted_community_person_ban = CommunityActions::ban(pool, &community_person_ban_form).await?; - assert!(inserted_community_person_ban.received_ban.is_some()); - assert!(inserted_community_person_ban.ban_expires.is_none()); + assert!(inserted_community_person_ban.received_ban_at.is_some()); + assert!(inserted_community_person_ban.ban_expires_at.is_none()); let read_community = Community::read(pool, inserted_community.id).await?; let update_community_form = CommunityUpdateForm { diff --git a/crates/db_schema/src/impls/community_report.rs b/crates/db_schema/src/impls/community_report.rs index 9790f45fa..844a2a08b 100644 --- a/crates/db_schema/src/impls/community_report.rs +++ b/crates/db_schema/src/impls/community_report.rs @@ -47,7 +47,7 @@ impl Reportable for CommunityReport { .set(( community_report::resolved.eq(true), community_report::resolver_id.eq(by_resolver_id), - community_report::updated.eq(Utc::now()), + community_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -71,7 +71,7 @@ impl Reportable for CommunityReport { .set(( community_report::resolved.eq(true), community_report::resolver_id.eq(resolver_id), - community_report::updated.eq(Utc::now()), + community_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -88,7 +88,7 @@ impl Reportable for CommunityReport { .set(( community_report::resolved.eq(true), community_report::resolver_id.eq(by_resolver_id), - community_report::updated.eq(Utc::now()), + community_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -110,7 +110,7 @@ impl Reportable for CommunityReport { .set(( community_report::resolved.eq(false), community_report::resolver_id.eq(by_resolver_id), - community_report::updated.eq(Utc::now()), + community_report::updated_at.eq(Utc::now()), )) .execute(conn) .await diff --git a/crates/db_schema/src/impls/email_verification.rs b/crates/db_schema/src/impls/email_verification.rs index 059bc496a..3ce5f1531 100644 --- a/crates/db_schema/src/impls/email_verification.rs +++ b/crates/db_schema/src/impls/email_verification.rs @@ -1,29 +1,17 @@ use crate::{ newtypes::LocalUserId, source::email_verification::{EmailVerification, EmailVerificationForm}, - utils::{get_conn, DbPool}, -}; -use diesel::{ - dsl::{now, IntervalDsl}, - insert_into, - sql_types::Timestamptz, - ExpressionMethods, - IntoSql, - QueryDsl, + utils::{get_conn, now, DbPool}, }; +use diesel::{dsl::IntervalDsl, insert_into, ExpressionMethods, QueryDsl}; use diesel_async::RunQueryDsl; -use lemmy_db_schema_file::schema::email_verification::dsl::{ - email_verification, - local_user_id, - published, - verification_token, -}; +use lemmy_db_schema_file::schema::email_verification; use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; impl EmailVerification { pub async fn create(pool: &mut DbPool<'_>, form: &EmailVerificationForm) -> LemmyResult { let conn = &mut get_conn(pool).await?; - insert_into(email_verification) + insert_into(email_verification::table) .values(form) .get_result(conn) .await @@ -32,9 +20,9 @@ impl EmailVerification { pub async fn read_for_token(pool: &mut DbPool<'_>, token: &str) -> LemmyResult { let conn = &mut get_conn(pool).await?; - email_verification - .filter(verification_token.eq(token)) - .filter(published.gt(now.into_sql::() - 7.days())) + email_verification::table + .filter(email_verification::verification_token.eq(token)) + .filter(email_verification::published_at.gt(now() - 7.days())) .first(conn) .await .with_lemmy_type(LemmyErrorType::NotFound) @@ -44,9 +32,11 @@ impl EmailVerification { local_user_id_: LocalUserId, ) -> LemmyResult { let conn = &mut get_conn(pool).await?; - diesel::delete(email_verification.filter(local_user_id.eq(local_user_id_))) - .execute(conn) - .await - .with_lemmy_type(LemmyErrorType::Deleted) + diesel::delete( + email_verification::table.filter(email_verification::local_user_id.eq(local_user_id_)), + ) + .execute(conn) + .await + .with_lemmy_type(LemmyErrorType::Deleted) } } diff --git a/crates/db_schema/src/impls/federation_allowlist.rs b/crates/db_schema/src/impls/federation_allowlist.rs index 0cd130305..226cffa6b 100644 --- a/crates/db_schema/src/impls/federation_allowlist.rs +++ b/crates/db_schema/src/impls/federation_allowlist.rs @@ -48,7 +48,7 @@ mod tests { .iter() .map(|i| FederationAllowListForm { instance_id: i.id, - updated: None, + updated_at: None, }) .collect(); diff --git a/crates/db_schema/src/impls/federation_queue_state.rs b/crates/db_schema/src/impls/federation_queue_state.rs index e9333225d..8f3bae422 100644 --- a/crates/db_schema/src/impls/federation_queue_state.rs +++ b/crates/db_schema/src/impls/federation_queue_state.rs @@ -22,9 +22,9 @@ impl FederationQueueState { .unwrap_or(FederationQueueState { instance_id, fail_count: 0, - last_retry: None, + last_retry_at: None, last_successful_id: None, // this value is set to the most current id for new instances - last_successful_published_time: None, + last_successful_published_time_at: None, }), ) } diff --git a/crates/db_schema/src/impls/instance.rs b/crates/db_schema/src/impls/instance.rs index a2b6722f0..d45bc437d 100644 --- a/crates/db_schema/src/impls/instance.rs +++ b/crates/db_schema/src/impls/instance.rs @@ -55,7 +55,7 @@ impl Instance { None => { // Instance not in database yet, insert it let form = InstanceForm { - updated: Some(Utc::now()), + updated_at: Some(Utc::now()), ..InstanceForm::new(domain_) }; insert_into(instance::table) @@ -148,7 +148,7 @@ impl Instance { pool: &mut DbPool<'_>, ) -> LemmyResult> { let conn = &mut get_conn(pool).await?; - let is_dead_expr = coalesce(instance::updated, instance::published).lt(now() - 3.days()); + let is_dead_expr = coalesce(instance::updated_at, instance::published_at).lt(now() - 3.days()); // this needs to be done in two steps because the meaning of the "blocked" column depends on the // existence of any value at all in the allowlist. (so a normal join wouldn't work) let use_allowlist = federation_allowlist::table @@ -227,7 +227,7 @@ impl Blockable for InstanceActions { async fn unblock(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(instance_actions::table.find((form.person_id, form.instance_id))) - .set_null(instance_actions::blocked) + .set_null(instance_actions::blocked_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::InstanceBlockAlreadyExists) @@ -241,7 +241,7 @@ impl Blockable for InstanceActions { let conn = &mut get_conn(pool).await?; let find_action = instance_actions::table .find((person_id, instance_id)) - .filter(instance_actions::blocked.is_not_null()); + .filter(instance_actions::blocked_at.is_not_null()); select(not(exists(find_action))) .get_result::(conn) .await? @@ -255,11 +255,11 @@ impl Blockable for InstanceActions { ) -> LemmyResult> { let conn = &mut get_conn(pool).await?; instance_actions::table - .filter(instance_actions::blocked.is_not_null()) + .filter(instance_actions::blocked_at.is_not_null()) .inner_join(instance::table) .select(instance::all_columns) .filter(instance_actions::person_id.eq(person_id)) - .order_by(instance_actions::blocked) + .order_by(instance_actions::blocked_at) .load::(conn) .await .with_lemmy_type(LemmyErrorType::NotFound) @@ -277,7 +277,7 @@ impl InstanceActions { instance_actions::table .filter(instance_actions::person_id.eq(person_id)) .filter(instance_actions::instance_id.eq(instance_id)) - .filter(instance_actions::received_ban.is_not_null()), + .filter(instance_actions::received_ban_at.is_not_null()), )) .get_result::(conn) .await?; @@ -308,8 +308,8 @@ impl Bannable for InstanceActions { let conn = &mut get_conn(pool).await?; Ok( uplete::new(instance_actions::table.find((form.person_id, form.instance_id))) - .set_null(instance_actions::received_ban) - .set_null(instance_actions::ban_expires) + .set_null(instance_actions::received_ban_at) + .set_null(instance_actions::ban_expires_at) .get_result(conn) .await?, ) diff --git a/crates/db_schema/src/impls/local_site_rate_limit.rs b/crates/db_schema/src/impls/local_site_rate_limit.rs index b9314dd5c..de8d31899 100644 --- a/crates/db_schema/src/impls/local_site_rate_limit.rs +++ b/crates/db_schema/src/impls/local_site_rate_limit.rs @@ -64,6 +64,6 @@ impl LocalSiteRateLimitUpdateForm { && self.comment_per_second.is_none() && self.search.is_none() && self.search_per_second.is_none() - && self.updated.is_none() + && self.updated_at.is_none() } } diff --git a/crates/db_schema/src/impls/local_site_url_blocklist.rs b/crates/db_schema/src/impls/local_site_url_blocklist.rs index dd816a4e4..b5de6b0a4 100644 --- a/crates/db_schema/src/impls/local_site_url_blocklist.rs +++ b/crates/db_schema/src/impls/local_site_url_blocklist.rs @@ -18,7 +18,10 @@ impl LocalSiteUrlBlocklist { let forms = url_blocklist .into_iter() - .map(|url| LocalSiteUrlBlocklistForm { url, updated: None }) + .map(|url| LocalSiteUrlBlocklistForm { + url, + updated_at: None, + }) .collect::>(); insert_into(local_site_url_blocklist::table) diff --git a/crates/db_schema/src/impls/local_user.rs b/crates/db_schema/src/impls/local_user.rs index b1c216fa2..ec45f2c7f 100644 --- a/crates/db_schema/src/impls/local_user.rs +++ b/crates/db_schema/src/impls/local_user.rs @@ -122,7 +122,7 @@ impl LocalUser { // - The accepted_application is false let old_denied_registrations = registration_application::table .filter(registration_application::admin_id.is_not_null()) - .filter(registration_application::published.lt(now() - 1.week())) + .filter(registration_application::published_at.lt(now() - 1.week())) .select(registration_application::local_user_id); // Delete based on join logic is here: @@ -172,7 +172,7 @@ impl LocalUser { let conn = &mut get_conn(pool).await?; let followed_communities = community_actions::table - .filter(community_actions::followed.is_not_null()) + .filter(community_actions::followed_at.is_not_null()) .filter(community_actions::person_id.eq(person_id_)) .inner_join(community::table) .select(community::ap_id) @@ -180,7 +180,7 @@ impl LocalUser { .await?; let saved_posts = post_actions::table - .filter(post_actions::saved.is_not_null()) + .filter(post_actions::saved_at.is_not_null()) .filter(post_actions::person_id.eq(person_id_)) .inner_join(post::table) .select(post::ap_id) @@ -188,7 +188,7 @@ impl LocalUser { .await?; let saved_comments = comment_actions::table - .filter(comment_actions::saved.is_not_null()) + .filter(comment_actions::saved_at.is_not_null()) .filter(comment_actions::person_id.eq(person_id_)) .inner_join(comment::table) .select(comment::ap_id) @@ -196,7 +196,7 @@ impl LocalUser { .await?; let blocked_communities = community_actions::table - .filter(community_actions::blocked.is_not_null()) + .filter(community_actions::blocked_at.is_not_null()) .filter(community_actions::person_id.eq(person_id_)) .inner_join(community::table) .select(community::ap_id) @@ -204,7 +204,7 @@ impl LocalUser { .await?; let blocked_users = person_actions::table - .filter(person_actions::blocked.is_not_null()) + .filter(person_actions::blocked_at.is_not_null()) .filter(person_actions::person_id.eq(person_id_)) .inner_join(person::table.on(person_actions::target_id.eq(person::id))) .select(person::ap_id) @@ -212,7 +212,7 @@ impl LocalUser { .await?; let blocked_instances = instance_actions::table - .filter(instance_actions::blocked.is_not_null()) + .filter(instance_actions::blocked_at.is_not_null()) .filter(instance_actions::person_id.eq(person_id_)) .inner_join(instance::table) .select(instance::domain) @@ -281,10 +281,10 @@ impl LocalUser { .select(local_user::person_id); let mods = community_actions::table - .filter(community_actions::became_moderator.is_not_null()) + .filter(community_actions::became_moderator_at.is_not_null()) .filter(community_actions::community_id.eq(for_community_id)) .filter(community_actions::person_id.eq_any(&persons)) - .order_by(community_actions::became_moderator) + .order_by(community_actions::became_moderator_at) .select(community_actions::person_id); let res = admins.union_all(mods).get_results::(conn).await?; diff --git a/crates/db_schema/src/impls/mod_log/moderator.rs b/crates/db_schema/src/impls/mod_log/moderator.rs index d5977ae34..ef34e5181 100644 --- a/crates/db_schema/src/impls/mod_log/moderator.rs +++ b/crates/db_schema/src/impls/mod_log/moderator.rs @@ -466,7 +466,7 @@ mod tests { mod_person_id: inserted_mod.id, reason: None, removed: true, - published: inserted_mod_remove_post.published, + published_at: inserted_mod_remove_post.published_at, }; // lock post @@ -485,7 +485,7 @@ mod tests { mod_person_id: inserted_mod.id, locked: true, reason: None, - published: inserted_mod_lock_post.published, + published_at: inserted_mod_lock_post.published_at, }; // feature post @@ -504,7 +504,7 @@ mod tests { mod_person_id: inserted_mod.id, featured: false, is_featured_community: true, - published: inserted_mod_feature_post.published, + published_at: inserted_mod_feature_post.published_at, }; // comment @@ -525,7 +525,7 @@ mod tests { mod_person_id: inserted_mod.id, reason: None, removed: true, - published: inserted_mod_remove_comment.published, + published_at: inserted_mod_remove_comment.published_at, }; // community @@ -546,7 +546,7 @@ mod tests { mod_person_id: inserted_mod.id, reason: None, removed: true, - published: inserted_mod_remove_community.published, + published_at: inserted_mod_remove_community.published_at, }; // ban from community @@ -557,7 +557,7 @@ mod tests { community_id: inserted_community.id, reason: None, banned: None, - expires: None, + expires_at: None, }; let inserted_mod_ban_from_community = ModBanFromCommunity::create(pool, &mod_ban_from_community_form).await?; @@ -570,8 +570,8 @@ mod tests { other_person_id: inserted_person.id, reason: None, banned: true, - expires: None, - published: inserted_mod_ban_from_community.published, + expires_at: None, + published_at: inserted_mod_ban_from_community.published_at, }; // ban @@ -581,7 +581,7 @@ mod tests { other_person_id: inserted_person.id, reason: None, banned: None, - expires: None, + expires_at: None, instance_id: inserted_instance.id, }; let inserted_mod_ban = ModBan::create(pool, &mod_ban_form).await?; @@ -592,8 +592,8 @@ mod tests { other_person_id: inserted_person.id, reason: None, banned: true, - expires: None, - published: inserted_mod_ban.published, + expires_at: None, + published_at: inserted_mod_ban.published_at, instance_id: inserted_instance.id, }; @@ -613,7 +613,7 @@ mod tests { mod_person_id: inserted_mod.id, other_person_id: inserted_person.id, removed: false, - published: inserted_mod_add_community.published, + published_at: inserted_mod_add_community.published_at, }; // mod add @@ -630,7 +630,7 @@ mod tests { mod_person_id: inserted_mod.id, other_person_id: inserted_person.id, removed: false, - published: inserted_mod_add.published, + published_at: inserted_mod_add.published_at, }; Comment::delete(pool, inserted_comment.id).await?; diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index 15bbcd7e6..7a06e26c1 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -36,7 +36,7 @@ impl PasswordResetRequest { let conn = &mut get_conn(pool).await?; delete(password_reset_request::table) .filter(password_reset_request::token.eq(token_)) - .filter(password_reset_request::published.gt(now.into_sql::() - 1.days())) + .filter(password_reset_request::published_at.gt(now.into_sql::() - 1.days())) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::Deleted) @@ -93,8 +93,8 @@ mod tests { read_password_reset_request.token ); assert_eq!( - inserted_password_reset_request.published, - read_password_reset_request.published + inserted_password_reset_request.published_at, + read_password_reset_request.published_at ); // Cannot reuse same token again diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index 8aa831d92..c3ea6e629 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -106,7 +106,7 @@ impl Person { let not_banned_local_user_id = local_user::table .left_join(instance_actions_join) .filter(local_user::person_id.eq(person_id)) - .filter(instance_actions::received_ban.nullable().is_null()) + .filter(instance_actions::received_ban_at.nullable().is_null()) .select(local_user::id) .first::(conn) .await @@ -127,7 +127,7 @@ impl Person { person::bio.eq::>(None), person::matrix_user_id.eq::>(None), person::deleted.eq(true), - person::updated.eq(Utc::now()), + person::updated_at.eq(Utc::now()), )) .get_result::(conn) .await @@ -251,7 +251,7 @@ impl Followable for PersonActions { ) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(person_actions::table.find((person_id, target_id))) - .set_null(person_actions::followed) + .set_null(person_actions::followed_at) .set_null(person_actions::follow_pending) .get_result(conn) .await @@ -280,7 +280,7 @@ impl Blockable for PersonActions { async fn unblock(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(person_actions::table.find((form.person_id, form.target_id))) - .set_null(person_actions::blocked) + .set_null(person_actions::blocked_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::PersonBlockAlreadyExists) @@ -294,7 +294,7 @@ impl Blockable for PersonActions { let conn = &mut get_conn(pool).await?; let find_action = person_actions::table .find((person_id, recipient_id)) - .filter(person_actions::blocked.is_not_null()); + .filter(person_actions::blocked_at.is_not_null()); select(not(exists(find_action))) .get_result::(conn) @@ -311,7 +311,7 @@ impl Blockable for PersonActions { let target_person_alias = diesel::alias!(person as person1); person_actions::table - .filter(person_actions::blocked.is_not_null()) + .filter(person_actions::blocked_at.is_not_null()) .inner_join(person::table.on(person_actions::person_id.eq(person::id))) .inner_join( target_person_alias.on(person_actions::target_id.eq(target_person_alias.field(person::id))), @@ -319,7 +319,7 @@ impl Blockable for PersonActions { .select(target_person_alias.fields(person::all_columns)) .filter(person_actions::person_id.eq(person_id)) .filter(target_person_alias.field(person::deleted).eq(false)) - .order_by(person_actions::blocked) + .order_by(person_actions::blocked_at) .load::(conn) .await .with_lemmy_type(LemmyErrorType::NotFound) @@ -333,7 +333,7 @@ impl PersonActions { ) -> LemmyResult> { let conn = &mut get_conn(pool).await?; person_actions::table - .filter(person_actions::followed.is_not_null()) + .filter(person_actions::followed_at.is_not_null()) .inner_join(person::table.on(person_actions::person_id.eq(person::id))) .filter(person_actions::target_id.eq(for_person_id)) .select(person::all_columns) @@ -380,15 +380,15 @@ mod tests { avatar: None, banner: None, deleted: false, - published: inserted_person.published, - updated: None, + published_at: inserted_person.published_at, + updated_at: None, ap_id: inserted_person.ap_id.clone(), bio: None, local: true, bot_account: false, private_key: None, public_key: "pubkey".to_owned(), - last_refreshed_at: inserted_person.published, + last_refreshed_at: inserted_person.published_at, inbox_url: inserted_person.inbox_url.clone(), matrix_user_id: None, instance_id: inserted_instance.id, diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index fc83b8091..5b74197d1 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -91,7 +91,7 @@ impl Post { insert_into(post::table) .values(form) .on_conflict(post::ap_id) - .filter_target(coalesce(post::updated, post::published).lt(timestamp)) + .filter_target(coalesce(post::updated_at, post::published_at).lt(timestamp)) .do_update() .set(form) .get_result::(conn) @@ -109,7 +109,7 @@ impl Post { .filter(post::deleted.eq(false)) .filter(post::removed.eq(false)) .filter(post::featured_community.eq(true)) - .then_order_by(post::published.desc()) + .then_order_by(post::published_at.desc()) .limit(FETCH_LIMIT_MAX.try_into()?) .load::(conn) .await @@ -121,12 +121,12 @@ impl Post { ) -> LemmyResult)>> { let conn = &mut get_conn(pool).await?; post::table - .select((post::ap_id, coalesce(post::updated, post::published))) + .select((post::ap_id, coalesce(post::updated_at, post::published_at))) .filter(post::local.eq(true)) .filter(post::deleted.eq(false)) .filter(post::removed.eq(false)) - .filter(post::published.ge(Utc::now().naive_utc() - SITEMAP_DAYS)) - .order(post::published.desc()) + .filter(post::published_at.ge(Utc::now().naive_utc() - SITEMAP_DAYS)) + .order(post::published_at.desc()) .limit(SITEMAP_LIMIT) .load::<(DbUrl, chrono::DateTime)>(conn) .await @@ -145,7 +145,7 @@ impl Post { post::url.eq(Option::<&str>::None), post::body.eq(DELETED_REPLACEMENT_TEXT), post::deleted.eq(true), - post::updated.eq(Utc::now()), + post::updated_at.eq(Utc::now()), )) .get_results::(conn) .await @@ -180,7 +180,7 @@ impl Post { update(post::table) .filter(post::id.eq_any(post_ids.clone())) - .set((post::removed.eq(removed), post::updated.eq(Utc::now()))) + .set((post::removed.eq(removed), post::updated_at.eq(Utc::now()))) .get_results::(conn) .await .with_lemmy_type(LemmyErrorType::CouldntUpdatePost) @@ -198,7 +198,7 @@ impl Post { let object_id: DbUrl = object_id.into(); post::table .filter(post::ap_id.eq(object_id)) - .filter(post::scheduled_publish_time.is_null()) + .filter(post::scheduled_publish_time_at.is_null()) .first(conn) .await .optional() @@ -229,8 +229,8 @@ impl Post { .inner_join(person::table) .inner_join(community::table) // find all posts which have scheduled_publish_time that is in the future - .filter(post::scheduled_publish_time.is_not_null()) - .filter(coalesce(post::scheduled_publish_time, now()).gt(now())) + .filter(post::scheduled_publish_time_at.is_not_null()) + .filter(coalesce(post::scheduled_publish_time_at, now()).gt(now())) // make sure the post and community are still around .filter(not(post::deleted.or(post::removed))) .filter(not(community::removed.or(community::deleted))) @@ -258,11 +258,11 @@ impl Post { diesel::update(post::table.find(post_id)) .set(( - post::hot_rank.eq(hot_rank(post::score, post::published)), - post::hot_rank_active.eq(hot_rank(post::score, post::newest_comment_time_necro)), + post::hot_rank.eq(hot_rank(post::score, post::published_at)), + post::hot_rank_active.eq(hot_rank(post::score, post::newest_comment_time_necro_at)), post::scaled_rank.eq(scaled_rank( post::score, - post::published, + post::published_at, interactions_month, )), )) @@ -312,7 +312,7 @@ impl Likeable for PostActions { let conn = &mut get_conn(pool).await?; uplete::new(post_actions::table.find((person_id, post_id))) .set_null(post_actions::like_score) - .set_null(post_actions::liked) + .set_null(post_actions::liked_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CouldntLikePost) @@ -336,7 +336,7 @@ impl Saveable for PostActions { async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { let conn = &mut get_conn(pool).await?; uplete::new(post_actions::table.find((form.person_id, form.post_id))) - .set_null(post_actions::saved) + .set_null(post_actions::saved_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CouldntSavePost) @@ -358,7 +358,7 @@ impl Readable for PostActions { .filter(post_actions::post_id.eq(form.post_id)) .filter(post_actions::person_id.eq(form.person_id)), ) - .set_null(post_actions::read) + .set_null(post_actions::read_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CouldntMarkPostAsRead) @@ -371,7 +371,7 @@ impl Readable for PostActions { .values(forms) .on_conflict((post_actions::person_id, post_actions::post_id)) .do_update() - .set(post_actions::read.eq(now().nullable())) + .set(post_actions::read_at.eq(now().nullable())) .execute(conn) .await .with_lemmy_type(LemmyErrorType::CouldntMarkPostAsRead) @@ -401,7 +401,7 @@ impl Hideable for PostActions { .filter(post_actions::post_id.eq(form.post_id)) .filter(post_actions::person_id.eq(form.person_id)), ) - .set_null(post_actions::hidden) + .set_null(post_actions::hidden_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CouldntHidePost) @@ -438,7 +438,7 @@ impl ReadComments for PostActions { .filter(post_actions::person_id.eq(person_id)), ) .set_null(post_actions::read_comments_amount) - .set_null(post_actions::read_comments) + .set_null(post_actions::read_comments_at) .get_result(conn) .await .with_lemmy_type(LemmyErrorType::CouldntUpdateReadComments) @@ -545,7 +545,7 @@ mod tests { let inserted_post2 = Post::create(pool, &new_post2).await?; let new_scheduled_post = PostInsertForm { - scheduled_publish_time: Some(DateTime::from_timestamp_nanos(i64::MAX)), + scheduled_publish_time_at: Some(DateTime::from_timestamp_nanos(i64::MAX)), ..PostInsertForm::new("beans".into(), inserted_person.id, inserted_community.id) }; let inserted_scheduled_post = Post::create(pool, &new_scheduled_post).await?; @@ -558,12 +558,12 @@ mod tests { alt_text: None, creator_id: inserted_person.id, community_id: inserted_community.id, - published: inserted_post.published, + published_at: inserted_post.published_at, removed: false, locked: false, nsfw: false, deleted: false, - updated: None, + updated_at: None, embed_title: None, embed_description: None, embed_video_url: None, @@ -574,7 +574,7 @@ mod tests { featured_community: false, featured_local: false, url_content_type: None, - scheduled_publish_time: None, + scheduled_publish_time_at: None, comments: 0, controversy_rank: 0.0, downvotes: 0, @@ -582,8 +582,8 @@ mod tests { score: 1, hot_rank: RANK_DEFAULT, hot_rank_active: RANK_DEFAULT, - newest_comment_time: inserted_post.published, - newest_comment_time_necro: inserted_post.published, + newest_comment_time_at: inserted_post.published_at, + newest_comment_time_necro_at: inserted_post.published_at, report_count: 0, scaled_rank: RANK_DEFAULT, unresolved_report_count: 0, @@ -600,7 +600,7 @@ mod tests { let post_saved_form = PostSavedForm::new(inserted_post.id, inserted_person.id); let inserted_post_saved = PostActions::save(pool, &post_saved_form).await?; - assert!(inserted_post_saved.saved.is_some()); + assert!(inserted_post_saved.saved_at.is_some()); // Mark 2 posts as read let post_read_form_1 = PostReadForm::new(inserted_post.id, inserted_person.id); diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index f17af9c67..9a6f43543 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -39,7 +39,7 @@ impl Reportable for PostReport { .set(( post_report::resolved.eq(true), post_report::resolver_id.eq(by_resolver_id), - post_report::updated.eq(Utc::now()), + post_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -63,7 +63,7 @@ impl Reportable for PostReport { .set(( post_report::resolved.eq(true), post_report::resolver_id.eq(resolver_id), - post_report::updated.eq(Utc::now()), + post_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -80,7 +80,7 @@ impl Reportable for PostReport { .set(( post_report::resolved.eq(true), post_report::resolver_id.eq(by_resolver_id), - post_report::updated.eq(Utc::now()), + post_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -97,7 +97,7 @@ impl Reportable for PostReport { .set(( post_report::resolved.eq(false), post_report::resolver_id.eq(by_resolver_id), - post_report::updated.eq(Utc::now()), + post_report::updated_at.eq(Utc::now()), )) .execute(conn) .await diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index 24a19e8b4..3a970ce38 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -53,7 +53,9 @@ impl PrivateMessage { insert_into(private_message::table) .values(form) .on_conflict(private_message::ap_id) - .filter_target(coalesce(private_message::updated, private_message::published).lt(timestamp)) + .filter_target( + coalesce(private_message::updated_at, private_message::published_at).lt(timestamp), + ) .do_update() .set(form) .get_result::(conn) @@ -104,7 +106,7 @@ impl PrivateMessage { diesel::update(private_message::table.filter(private_message::creator_id.eq(for_creator_id))) .set(( private_message::removed.eq(removed), - private_message::updated.eq(Utc::now()), + private_message::updated_at.eq(Utc::now()), )) .get_results::(conn) .await @@ -160,8 +162,8 @@ mod tests { recipient_id: inserted_recipient.id, deleted: false, read: false, - updated: None, - published: inserted_private_message.published, + updated_at: None, + published_at: inserted_private_message.published_at, ap_id: Url::parse(&format!( "https://lemmy-alpha/private_message/{}", inserted_private_message.id diff --git a/crates/db_schema/src/impls/private_message_report.rs b/crates/db_schema/src/impls/private_message_report.rs index e1a86fcd9..bfcda4191 100644 --- a/crates/db_schema/src/impls/private_message_report.rs +++ b/crates/db_schema/src/impls/private_message_report.rs @@ -11,12 +11,7 @@ use diesel::{ QueryDsl, }; use diesel_async::RunQueryDsl; -use lemmy_db_schema_file::schema::private_message_report::dsl::{ - private_message_report, - resolved, - resolver_id, - updated, -}; +use lemmy_db_schema_file::schema::private_message_report; use lemmy_utils::error::{FederationError, LemmyErrorExt, LemmyErrorType, LemmyResult}; impl Reportable for PrivateMessageReport { @@ -26,7 +21,7 @@ impl Reportable for PrivateMessageReport { async fn report(pool: &mut DbPool<'_>, form: &Self::Form) -> LemmyResult { let conn = &mut get_conn(pool).await?; - insert_into(private_message_report) + insert_into(private_message_report::table) .values(form) .get_result::(conn) .await @@ -39,11 +34,11 @@ impl Reportable for PrivateMessageReport { by_resolver_id: PersonId, ) -> LemmyResult { let conn = &mut get_conn(pool).await?; - update(private_message_report.find(report_id)) + update(private_message_report::table.find(report_id)) .set(( - resolved.eq(true), - resolver_id.eq(by_resolver_id), - updated.eq(Utc::now()), + private_message_report::resolved.eq(true), + private_message_report::resolver_id.eq(by_resolver_id), + private_message_report::updated_at.eq(Utc::now()), )) .execute(conn) .await @@ -73,11 +68,11 @@ impl Reportable for PrivateMessageReport { by_resolver_id: PersonId, ) -> LemmyResult { let conn = &mut get_conn(pool).await?; - update(private_message_report.find(report_id)) + update(private_message_report::table.find(report_id)) .set(( - resolved.eq(false), - resolver_id.eq(by_resolver_id), - updated.eq(Utc::now()), + private_message_report::resolved.eq(false), + private_message_report::resolver_id.eq(by_resolver_id), + private_message_report::updated_at.eq(Utc::now()), )) .execute(conn) .await diff --git a/crates/db_schema/src/impls/tagline.rs b/crates/db_schema/src/impls/tagline.rs index b654d3c98..55dc5fdf7 100644 --- a/crates/db_schema/src/impls/tagline.rs +++ b/crates/db_schema/src/impls/tagline.rs @@ -49,7 +49,7 @@ impl Tagline { let limit = limit_fetch(limit)?; let query = tagline::table.limit(limit).into_boxed(); let paginated_query = paginate(query, SortDirection::Desc, cursor_data, None, page_back) - .then_order_by(key::published) + .then_order_by(key::published_at) .then_order_by(key::id); paginated_query diff --git a/crates/db_schema/src/lib.rs b/crates/db_schema/src/lib.rs index 2c03d8fd4..9adf9c67a 100644 --- a/crates/db_schema/src/lib.rs +++ b/crates/db_schema/src/lib.rs @@ -187,8 +187,8 @@ pub type Person1AliasAllColumnsTuple = ( AliasedField, AliasedField, AliasedField, - AliasedField, - AliasedField, + AliasedField, + AliasedField, AliasedField, AliasedField, AliasedField, @@ -214,8 +214,8 @@ pub type Person2AliasAllColumnsTuple = ( AliasedField, AliasedField, AliasedField, - AliasedField, - AliasedField, + AliasedField, + AliasedField, AliasedField, AliasedField, AliasedField, @@ -239,13 +239,13 @@ pub type Person2AliasAllColumnsTuple = ( pub type CreatorCommunityActionsAllColumnsTuple = ( AliasedField, AliasedField, - AliasedField, + AliasedField, AliasedField, AliasedField, - AliasedField, - AliasedField, - AliasedField, - AliasedField, + AliasedField, + AliasedField, + AliasedField, + AliasedField, ); #[cfg(feature = "full")] @@ -253,9 +253,9 @@ pub type CreatorCommunityActionsAllColumnsTuple = ( pub type CreatorHomeInstanceActionsAllColumnsTuple = ( AliasedField, AliasedField, - AliasedField, - AliasedField, - AliasedField, + AliasedField, + AliasedField, + AliasedField, ); #[cfg(feature = "full")] @@ -263,7 +263,7 @@ pub type CreatorHomeInstanceActionsAllColumnsTuple = ( pub type CreatorLocalInstanceActionsAllColumnsTuple = ( AliasedField, AliasedField, - AliasedField, - AliasedField, - AliasedField, + AliasedField, + AliasedField, + AliasedField, ); diff --git a/crates/db_schema/src/source/activity.rs b/crates/db_schema/src/source/activity.rs index 1891c88e6..3e7376f32 100644 --- a/crates/db_schema/src/source/activity.rs +++ b/crates/db_schema/src/source/activity.rs @@ -61,7 +61,7 @@ pub struct SentActivity { pub ap_id: DbUrl, pub data: Value, pub sensitive: bool, - pub published: DateTime, + pub published_at: DateTime, pub send_inboxes: Vec>, pub send_community_followers_of: Option, pub send_all_instances: bool, @@ -89,5 +89,5 @@ pub struct SentActivityForm { #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] pub struct ReceivedActivity { pub ap_id: DbUrl, - pub published: DateTime, + pub published_at: DateTime, } diff --git a/crates/db_schema/src/source/captcha_answer.rs b/crates/db_schema/src/source/captcha_answer.rs index 529e823f9..d5eae2961 100644 --- a/crates/db_schema/src/source/captcha_answer.rs +++ b/crates/db_schema/src/source/captcha_answer.rs @@ -13,7 +13,7 @@ use uuid::Uuid; pub struct CaptchaAnswer { pub uuid: Uuid, pub answer: String, - pub published: DateTime, + pub published_at: DateTime, } #[skip_serializing_none] diff --git a/crates/db_schema/src/source/combined/inbox.rs b/crates/db_schema/src/source/combined/inbox.rs index b8f6c81b5..09bc68d67 100644 --- a/crates/db_schema/src/source/combined/inbox.rs +++ b/crates/db_schema/src/source/combined/inbox.rs @@ -25,7 +25,7 @@ use serde_with::skip_serializing_none; /// A combined inbox table. pub struct InboxCombined { pub id: InboxCombinedId, - pub published: DateTime, + pub published_at: DateTime, pub comment_reply_id: Option, pub person_comment_mention_id: Option, pub person_post_mention_id: Option, diff --git a/crates/db_schema/src/source/combined/modlog.rs b/crates/db_schema/src/source/combined/modlog.rs index 2d87ca791..ad8ca6236 100644 --- a/crates/db_schema/src/source/combined/modlog.rs +++ b/crates/db_schema/src/source/combined/modlog.rs @@ -36,7 +36,7 @@ use serde::{Deserialize, Serialize}; /// A combined modlog table. pub struct ModlogCombined { pub id: ModlogCombinedId, - pub published: DateTime, + pub published_at: DateTime, pub admin_allow_instance_id: Option, pub admin_block_instance_id: Option, pub admin_purge_comment_id: Option, diff --git a/crates/db_schema/src/source/combined/person_content.rs b/crates/db_schema/src/source/combined/person_content.rs index ab688ca9f..cdd5b34a1 100644 --- a/crates/db_schema/src/source/combined/person_content.rs +++ b/crates/db_schema/src/source/combined/person_content.rs @@ -19,7 +19,7 @@ use serde_with::skip_serializing_none; /// A combined table for a persons contents (posts and comments) pub struct PersonContentCombined { pub id: PersonContentCombinedId, - pub published: DateTime, + pub published_at: DateTime, pub post_id: Option, pub comment_id: Option, } diff --git a/crates/db_schema/src/source/combined/person_liked.rs b/crates/db_schema/src/source/combined/person_liked.rs index e4d64cbbc..17d75ca47 100644 --- a/crates/db_schema/src/source/combined/person_liked.rs +++ b/crates/db_schema/src/source/combined/person_liked.rs @@ -19,7 +19,7 @@ use serde_with::skip_serializing_none; /// A combined person_liked table. pub struct PersonLikedCombined { pub id: PersonLikedCombinedId, - pub liked: DateTime, + pub liked_at: DateTime, pub like_score: i16, pub person_id: PersonId, pub post_id: Option, diff --git a/crates/db_schema/src/source/combined/person_saved.rs b/crates/db_schema/src/source/combined/person_saved.rs index 8bc84fabd..a681c2580 100644 --- a/crates/db_schema/src/source/combined/person_saved.rs +++ b/crates/db_schema/src/source/combined/person_saved.rs @@ -19,7 +19,7 @@ use serde_with::skip_serializing_none; /// A combined person_saved table. pub struct PersonSavedCombined { pub id: PersonSavedCombinedId, - pub saved: DateTime, + pub saved_at: DateTime, pub person_id: PersonId, pub post_id: Option, pub comment_id: Option, diff --git a/crates/db_schema/src/source/combined/report.rs b/crates/db_schema/src/source/combined/report.rs index 249190cd7..615fe06b7 100644 --- a/crates/db_schema/src/source/combined/report.rs +++ b/crates/db_schema/src/source/combined/report.rs @@ -25,7 +25,7 @@ use serde_with::skip_serializing_none; /// A combined reports table. pub struct ReportCombined { pub id: ReportCombinedId, - pub published: DateTime, + pub published_at: DateTime, pub post_report_id: Option, pub comment_report_id: Option, pub private_message_report_id: Option, diff --git a/crates/db_schema/src/source/combined/search.rs b/crates/db_schema/src/source/combined/search.rs index 9db8abe31..505ba00a6 100644 --- a/crates/db_schema/src/source/combined/search.rs +++ b/crates/db_schema/src/source/combined/search.rs @@ -19,7 +19,7 @@ use serde_with::skip_serializing_none; /// A combined table for a search (posts, comments, communities, persons) pub struct SearchCombined { pub id: SearchCombinedId, - pub published: DateTime, + pub published_at: DateTime, pub score: i64, pub post_id: Option, pub comment_id: Option, diff --git a/crates/db_schema/src/source/comment.rs b/crates/db_schema/src/source/comment.rs index 85c53c306..103959c0a 100644 --- a/crates/db_schema/src/source/comment.rs +++ b/crates/db_schema/src/source/comment.rs @@ -37,9 +37,9 @@ pub struct Comment { pub content: String, /// Whether the comment has been removed. pub removed: bool, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, /// Whether the comment has been deleted by its creator. pub deleted: bool, /// The federated activity id / ap_id. @@ -86,9 +86,9 @@ pub struct CommentInsertForm { #[new(default)] pub removed: Option, #[new(default)] - pub published: Option>, + pub published_at: Option>, #[new(default)] - pub updated: Option>, + pub updated_at: Option>, #[new(default)] pub deleted: Option, #[new(default)] @@ -110,7 +110,7 @@ pub struct CommentUpdateForm { pub content: Option, pub removed: Option, // Don't use a default Utc::now here, because the create function does a lot of comment updates - pub updated: Option>>, + pub updated_at: Option>>, pub deleted: Option, pub ap_id: Option, pub local: Option, @@ -148,10 +148,10 @@ pub struct CommentActions { pub like_score: Option, #[cfg_attr(feature = "full", ts(optional))] /// When the comment was liked. - pub liked: Option>, + pub liked_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When the comment was saved. - pub saved: Option>, + pub saved_at: Option>, } #[derive(Clone, derive_new::new)] @@ -165,7 +165,7 @@ pub struct CommentLikeForm { pub comment_id: CommentId, pub like_score: i16, #[new(value = "Utc::now()")] - pub liked: DateTime, + pub liked_at: DateTime, } #[derive(derive_new::new)] @@ -175,5 +175,5 @@ pub struct CommentSavedForm { pub person_id: PersonId, pub comment_id: CommentId, #[new(value = "Utc::now()")] - pub saved: DateTime, + pub saved_at: DateTime, } diff --git a/crates/db_schema/src/source/comment_reply.rs b/crates/db_schema/src/source/comment_reply.rs index 07300418f..e19618dd7 100644 --- a/crates/db_schema/src/source/comment_reply.rs +++ b/crates/db_schema/src/source/comment_reply.rs @@ -21,7 +21,7 @@ pub struct CommentReply { pub recipient_id: PersonId, pub comment_id: CommentId, pub read: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] diff --git a/crates/db_schema/src/source/comment_report.rs b/crates/db_schema/src/source/comment_report.rs index 61de99a9f..23fd50df0 100644 --- a/crates/db_schema/src/source/comment_report.rs +++ b/crates/db_schema/src/source/comment_report.rs @@ -27,9 +27,9 @@ pub struct CommentReport { pub resolved: bool, #[cfg_attr(feature = "full", ts(optional))] pub resolver_id: Option, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, pub violates_instance_rules: bool, } diff --git a/crates/db_schema/src/source/community.rs b/crates/db_schema/src/source/community.rs index 6d865fed3..37088082b 100644 --- a/crates/db_schema/src/source/community.rs +++ b/crates/db_schema/src/source/community.rs @@ -35,9 +35,9 @@ pub struct Community { pub sidebar: Option, /// Whether the community is removed by a mod. pub removed: bool, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, /// Whether the community has been deleted by its creator. pub deleted: bool, /// Whether its an NSFW community. @@ -114,9 +114,9 @@ pub struct CommunityInsertForm { #[new(default)] pub removed: Option, #[new(default)] - pub published: Option>, + pub published_at: Option>, #[new(default)] - pub updated: Option>, + pub updated_at: Option>, #[new(default)] pub deleted: Option, #[new(default)] @@ -158,8 +158,8 @@ pub struct CommunityUpdateForm { pub title: Option, pub sidebar: Option>, pub removed: Option, - pub published: Option>, - pub updated: Option>>, + pub published_at: Option>, + pub updated_at: Option>>, pub deleted: Option, pub nsfw: Option, pub ap_id: Option, @@ -208,7 +208,7 @@ pub struct CommunityActions { pub person_id: PersonId, #[cfg_attr(feature = "full", ts(optional))] /// When the community was followed. - pub followed: Option>, + pub followed_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// The state of the community follow. pub follow_state: Option, @@ -217,16 +217,16 @@ pub struct CommunityActions { pub follow_approver_id: Option, #[cfg_attr(feature = "full", ts(optional))] /// When the community was blocked. - pub blocked: Option>, + pub blocked_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When this user became a moderator. - pub became_moderator: Option>, + pub became_moderator_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When this user received a ban. - pub received_ban: Option>, + pub received_ban_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When their ban expires. - pub ban_expires: Option>, + pub ban_expires_at: Option>, } #[derive(Clone, derive_new::new)] @@ -236,7 +236,7 @@ pub struct CommunityModeratorForm { pub community_id: CommunityId, pub person_id: PersonId, #[new(value = "Utc::now()")] - pub became_moderator: DateTime, + pub became_moderator_at: DateTime, } #[derive(Clone, derive_new::new)] @@ -246,9 +246,9 @@ pub struct CommunityPersonBanForm { pub community_id: CommunityId, pub person_id: PersonId, #[new(default)] - pub ban_expires: Option>>, + pub ban_expires_at: Option>>, #[new(value = "Utc::now()")] - pub received_ban: DateTime, + pub received_ban_at: DateTime, } #[derive(Clone, derive_new::new)] @@ -261,7 +261,7 @@ pub struct CommunityFollowerForm { #[new(default)] pub follow_approver_id: Option, #[new(value = "Utc::now()")] - pub followed: DateTime, + pub followed_at: DateTime, } #[derive(derive_new::new)] @@ -271,5 +271,5 @@ pub struct CommunityBlockForm { pub community_id: CommunityId, pub person_id: PersonId, #[new(value = "Utc::now()")] - pub blocked: DateTime, + pub blocked_at: DateTime, } diff --git a/crates/db_schema/src/source/community_report.rs b/crates/db_schema/src/source/community_report.rs index 0ec2d07cb..3b33e0473 100644 --- a/crates/db_schema/src/source/community_report.rs +++ b/crates/db_schema/src/source/community_report.rs @@ -39,9 +39,9 @@ pub struct CommunityReport { pub resolved: bool, #[cfg_attr(feature = "full", ts(optional))] pub resolver_id: Option, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, } #[derive(Clone)] diff --git a/crates/db_schema/src/source/custom_emoji.rs b/crates/db_schema/src/source/custom_emoji.rs index 8e1038962..b56f2bd4c 100644 --- a/crates/db_schema/src/source/custom_emoji.rs +++ b/crates/db_schema/src/source/custom_emoji.rs @@ -20,9 +20,9 @@ pub struct CustomEmoji { pub image_url: DbUrl, pub alt_text: String, pub category: String, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, } #[derive(Debug, Clone, derive_new::new)] diff --git a/crates/db_schema/src/source/email_verification.rs b/crates/db_schema/src/source/email_verification.rs index 343340353..d4fc57352 100644 --- a/crates/db_schema/src/source/email_verification.rs +++ b/crates/db_schema/src/source/email_verification.rs @@ -12,7 +12,7 @@ pub struct EmailVerification { pub local_user_id: LocalUserId, pub email: String, pub verification_token: String, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] diff --git a/crates/db_schema/src/source/federation_allowlist.rs b/crates/db_schema/src/source/federation_allowlist.rs index ae4de58e8..3ee000eb2 100644 --- a/crates/db_schema/src/source/federation_allowlist.rs +++ b/crates/db_schema/src/source/federation_allowlist.rs @@ -19,8 +19,8 @@ use std::fmt::Debug; #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] pub struct FederationAllowList { pub instance_id: InstanceId, - pub published: DateTime, - pub updated: Option>, + pub published_at: DateTime, + pub updated_at: Option>, } #[derive(Clone, Default)] @@ -28,5 +28,5 @@ pub struct FederationAllowList { #[cfg_attr(feature = "full", diesel(table_name = federation_allowlist))] pub struct FederationAllowListForm { pub instance_id: InstanceId, - pub updated: Option>, + pub updated_at: Option>, } diff --git a/crates/db_schema/src/source/federation_blocklist.rs b/crates/db_schema/src/source/federation_blocklist.rs index dc7b81adc..215a8a45e 100644 --- a/crates/db_schema/src/source/federation_blocklist.rs +++ b/crates/db_schema/src/source/federation_blocklist.rs @@ -20,11 +20,11 @@ use {lemmy_db_schema_file::schema::federation_blocklist, ts_rs::TS}; #[cfg_attr(feature = "full", ts(export))] pub struct FederationBlockList { pub instance_id: InstanceId, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, #[cfg_attr(feature = "full", ts(optional))] - pub expires: Option>, + pub expires_at: Option>, } #[derive(Clone, Default)] @@ -32,6 +32,6 @@ pub struct FederationBlockList { #[cfg_attr(feature = "full", diesel(table_name = federation_blocklist))] pub struct FederationBlockListForm { pub instance_id: InstanceId, - pub updated: Option>, - pub expires: Option>, + pub updated_at: Option>, + pub expires_at: Option>, } diff --git a/crates/db_schema/src/source/federation_queue_state.rs b/crates/db_schema/src/source/federation_queue_state.rs index cb0c8ab12..2b27b3309 100644 --- a/crates/db_schema/src/source/federation_queue_state.rs +++ b/crates/db_schema/src/source/federation_queue_state.rs @@ -22,10 +22,10 @@ pub struct FederationQueueState { #[cfg_attr(feature = "full", ts(optional))] pub last_successful_id: Option, #[cfg_attr(feature = "full", ts(optional))] - pub last_successful_published_time: Option>, + pub last_successful_published_time_at: Option>, /// how many failed attempts have been made to send the next activity pub fail_count: i32, /// timestamp of the last retry attempt (when the last failing activity was resent) #[cfg_attr(feature = "full", ts(optional))] - pub last_retry: Option>, + pub last_retry_at: Option>, } diff --git a/crates/db_schema/src/source/images.rs b/crates/db_schema/src/source/images.rs index 4ccb4c378..2ed844ba2 100644 --- a/crates/db_schema/src/source/images.rs +++ b/crates/db_schema/src/source/images.rs @@ -31,7 +31,7 @@ use { #[cfg_attr(feature = "full", cursor_keys_module(name = local_image_keys))] pub struct LocalImage { pub pictrs_alias: String, - pub published: DateTime, + pub published_at: DateTime, pub person_id: PersonId, #[cfg_attr(feature = "full", ts(optional))] /// This means the image is an auto-generated thumbnail, for a post. @@ -57,7 +57,7 @@ pub struct LocalImageForm { #[cfg_attr(feature = "full", diesel(primary_key(link)))] pub struct RemoteImage { pub link: DbUrl, - pub published: DateTime, + pub published_at: DateTime, } #[skip_serializing_none] diff --git a/crates/db_schema/src/source/instance.rs b/crates/db_schema/src/source/instance.rs index f73132f04..08904274d 100644 --- a/crates/db_schema/src/source/instance.rs +++ b/crates/db_schema/src/source/instance.rs @@ -19,10 +19,10 @@ use ts_rs::TS; pub struct Instance { pub id: InstanceId, pub domain: String, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] /// When the instance was updated. - pub updated: Option>, + pub updated_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// The software of the instance. pub software: Option, @@ -41,7 +41,7 @@ pub struct InstanceForm { #[new(default)] pub version: Option, #[new(default)] - pub updated: Option>, + pub updated_at: Option>, } #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] @@ -64,13 +64,13 @@ pub struct InstanceActions { pub instance_id: InstanceId, #[cfg_attr(feature = "full", ts(optional))] /// When the instance was blocked. - pub blocked: Option>, + pub blocked_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When this user received a site ban. - pub received_ban: Option>, + pub received_ban_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When their ban expires. - pub ban_expires: Option>, + pub ban_expires_at: Option>, } #[derive(derive_new::new)] @@ -80,7 +80,7 @@ pub struct InstanceBlockForm { pub person_id: PersonId, pub instance_id: InstanceId, #[new(value = "Utc::now()")] - pub blocked: DateTime, + pub blocked_at: DateTime, } #[derive(derive_new::new)] @@ -90,6 +90,6 @@ pub struct InstanceBanForm { pub person_id: PersonId, pub instance_id: InstanceId, #[new(value = "Utc::now()")] - pub received_ban: DateTime, - pub ban_expires: Option>, + pub received_ban_at: DateTime, + pub ban_expires_at: Option>, } diff --git a/crates/db_schema/src/source/local_site.rs b/crates/db_schema/src/source/local_site.rs index 13518fd1d..15c58fdbd 100644 --- a/crates/db_schema/src/source/local_site.rs +++ b/crates/db_schema/src/source/local_site.rs @@ -56,9 +56,9 @@ pub struct LocalSite { pub captcha_enabled: bool, /// The captcha difficulty. pub captcha_difficulty: String, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, pub registration_mode: RegistrationMode, /// Whether to email admins on new reports. pub reports_email_admins: bool, @@ -185,7 +185,7 @@ pub struct LocalSiteUpdateForm { pub captcha_difficulty: Option, pub registration_mode: Option, pub reports_email_admins: Option, - pub updated: Option>>, + pub updated_at: Option>>, pub federation_signed_fetch: Option, pub default_post_listing_mode: Option, pub default_post_sort_type: Option, diff --git a/crates/db_schema/src/source/local_site_rate_limit.rs b/crates/db_schema/src/source/local_site_rate_limit.rs index 50e4af489..fc573c648 100644 --- a/crates/db_schema/src/source/local_site_rate_limit.rs +++ b/crates/db_schema/src/source/local_site_rate_limit.rs @@ -33,9 +33,9 @@ pub struct LocalSiteRateLimit { pub comment_per_second: i32, pub search: i32, pub search_per_second: i32, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, pub import_user_settings: i32, pub import_user_settings_per_second: i32, } @@ -93,5 +93,5 @@ pub struct LocalSiteRateLimitUpdateForm { pub search_per_second: Option, pub import_user_settings: Option, pub import_user_settings_per_second: Option, - pub updated: Option>>, + pub updated_at: Option>>, } diff --git a/crates/db_schema/src/source/local_site_url_blocklist.rs b/crates/db_schema/src/source/local_site_url_blocklist.rs index 41c6ddd88..c9ad5332e 100644 --- a/crates/db_schema/src/source/local_site_url_blocklist.rs +++ b/crates/db_schema/src/source/local_site_url_blocklist.rs @@ -15,9 +15,9 @@ use ts_rs::TS; pub struct LocalSiteUrlBlocklist { pub id: i32, pub url: String, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, } #[derive(Default, Clone)] @@ -25,5 +25,5 @@ pub struct LocalSiteUrlBlocklist { #[cfg_attr(feature = "full", diesel(table_name = local_site_url_blocklist))] pub struct LocalSiteUrlBlocklistForm { pub url: String, - pub updated: Option>, + pub updated_at: Option>, } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index d9675bffc..bb2f064e2 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -76,7 +76,7 @@ pub struct LocalUser { pub auto_mark_fetched_posts_as_read: bool, /// The last time a donation request was shown to this user. If this is more than a year ago, /// a new notification request should be shown. - pub last_donation_notification: DateTime, + pub last_donation_notification_at: DateTime, /// Whether to hide posts containing images/videos pub hide_media: bool, #[cfg_attr(feature = "full", ts(optional))] @@ -145,7 +145,7 @@ pub struct LocalUserInsertForm { #[new(default)] pub auto_mark_fetched_posts_as_read: Option, #[new(default)] - pub last_donation_notification: Option>, + pub last_donation_notification_at: Option>, #[new(default)] pub hide_media: Option, #[new(default)] @@ -190,7 +190,7 @@ pub struct LocalUserUpdateForm { pub collapse_bot_comments: Option, pub default_comment_sort_type: Option, pub auto_mark_fetched_posts_as_read: Option, - pub last_donation_notification: Option>, + pub last_donation_notification_at: Option>, pub hide_media: Option, pub default_post_time_range_seconds: Option>, pub show_score: Option, diff --git a/crates/db_schema/src/source/login_token.rs b/crates/db_schema/src/source/login_token.rs index 8eca505d8..ba3dadb39 100644 --- a/crates/db_schema/src/source/login_token.rs +++ b/crates/db_schema/src/source/login_token.rs @@ -21,7 +21,7 @@ pub struct LoginToken { pub token: SensitiveString, pub user_id: LocalUserId, /// Time of login - pub published: DateTime, + pub published_at: DateTime, /// IP address where login was made from, allows invalidating logins by IP address. /// Could be stored in truncated format, or store derived information for better privacy. #[cfg_attr(feature = "full", ts(optional))] diff --git a/crates/db_schema/src/source/mod_log/admin.rs b/crates/db_schema/src/source/mod_log/admin.rs index 0c5635638..da4784cf6 100644 --- a/crates/db_schema/src/source/mod_log/admin.rs +++ b/crates/db_schema/src/source/mod_log/admin.rs @@ -37,7 +37,7 @@ pub struct AdminPurgePerson { pub admin_person_id: PersonId, #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -59,7 +59,7 @@ pub struct AdminPurgeCommunity { pub admin_person_id: PersonId, #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -82,7 +82,7 @@ pub struct AdminPurgePost { pub community_id: CommunityId, #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -106,7 +106,7 @@ pub struct AdminPurgeComment { pub post_id: PostId, #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -137,7 +137,7 @@ pub struct AdminAllowInstance { pub allowed: bool, #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, - pub published: DateTime, + pub published_at: DateTime, } #[derive(Clone, Default)] @@ -171,8 +171,8 @@ pub struct AdminBlockInstance { #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, #[cfg_attr(feature = "full", ts(optional))] - pub expires: Option>, - pub published: DateTime, + pub expires_at: Option>, + pub published_at: DateTime, } #[derive(Clone, Default)] diff --git a/crates/db_schema/src/source/mod_log/moderator.rs b/crates/db_schema/src/source/mod_log/moderator.rs index dd2e9c86d..c90ea92d4 100644 --- a/crates/db_schema/src/source/mod_log/moderator.rs +++ b/crates/db_schema/src/source/mod_log/moderator.rs @@ -51,7 +51,7 @@ pub struct ModRemovePost { #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, pub removed: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -74,7 +74,7 @@ pub struct ModLockPost { pub mod_person_id: PersonId, pub post_id: PostId, pub locked: bool, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, } @@ -99,7 +99,7 @@ pub struct ModFeaturePost { pub mod_person_id: PersonId, pub post_id: PostId, pub featured: bool, - pub published: DateTime, + pub published_at: DateTime, pub is_featured_community: bool, } @@ -126,7 +126,7 @@ pub struct ModRemoveComment { #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, pub removed: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -152,7 +152,7 @@ pub struct ModRemoveCommunity { #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, pub removed: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -180,8 +180,8 @@ pub struct ModBanFromCommunity { pub reason: Option, pub banned: bool, #[cfg_attr(feature = "full", ts(optional))] - pub expires: Option>, - pub published: DateTime, + pub expires_at: Option>, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -192,7 +192,7 @@ pub struct ModBanFromCommunityForm { pub community_id: CommunityId, pub reason: Option, pub banned: Option, - pub expires: Option>, + pub expires_at: Option>, } #[skip_serializing_none] @@ -210,8 +210,8 @@ pub struct ModBan { pub reason: Option, pub banned: bool, #[cfg_attr(feature = "full", ts(optional))] - pub expires: Option>, - pub published: DateTime, + pub expires_at: Option>, + pub published_at: DateTime, pub instance_id: InstanceId, } @@ -233,7 +233,7 @@ pub struct ModChangeCommunityVisibility { pub id: ModChangeCommunityVisibilityId, pub community_id: CommunityId, pub mod_person_id: PersonId, - pub published: DateTime, + pub published_at: DateTime, pub visibility: CommunityVisibility, } @@ -244,7 +244,7 @@ pub struct ModBanForm { pub other_person_id: PersonId, pub reason: Option, pub banned: Option, - pub expires: Option>, + pub expires_at: Option>, pub instance_id: InstanceId, } @@ -260,7 +260,7 @@ pub struct ModAddCommunity { pub other_person_id: PersonId, pub community_id: CommunityId, pub removed: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -283,7 +283,7 @@ pub struct ModTransferCommunity { pub mod_person_id: PersonId, pub other_person_id: PersonId, pub community_id: CommunityId, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] @@ -305,7 +305,7 @@ pub struct ModAdd { pub mod_person_id: PersonId, pub other_person_id: PersonId, pub removed: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] diff --git a/crates/db_schema/src/source/oauth_account.rs b/crates/db_schema/src/source/oauth_account.rs index 314065583..fa78136c9 100644 --- a/crates/db_schema/src/source/oauth_account.rs +++ b/crates/db_schema/src/source/oauth_account.rs @@ -18,9 +18,9 @@ pub struct OAuthAccount { pub local_user_id: LocalUserId, pub oauth_provider_id: OAuthProviderId, pub oauth_user_id: String, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, } #[derive(Debug, Clone, derive_new::new)] diff --git a/crates/db_schema/src/source/oauth_provider.rs b/crates/db_schema/src/source/oauth_provider.rs index 20f520842..deb815874 100644 --- a/crates/db_schema/src/source/oauth_provider.rs +++ b/crates/db_schema/src/source/oauth_provider.rs @@ -59,9 +59,9 @@ pub struct OAuthProvider { pub account_linking_enabled: bool, /// switch to enable or disable an oauth provider pub enabled: bool, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, /// switch to enable or disable PKCE pub use_pkce: bool, } @@ -124,5 +124,5 @@ pub struct OAuthProviderUpdateForm { pub account_linking_enabled: Option, pub use_pkce: Option, pub enabled: Option, - pub updated: Option>>, + pub updated_at: Option>>, } diff --git a/crates/db_schema/src/source/password_reset_request.rs b/crates/db_schema/src/source/password_reset_request.rs index 6430197af..7a7effdfa 100644 --- a/crates/db_schema/src/source/password_reset_request.rs +++ b/crates/db_schema/src/source/password_reset_request.rs @@ -10,7 +10,7 @@ use lemmy_db_schema_file::schema::password_reset_request; pub struct PasswordResetRequest { pub id: i32, pub token: SensitiveString, - pub published: DateTime, + pub published_at: DateTime, pub local_user_id: LocalUserId, } diff --git a/crates/db_schema/src/source/person.rs b/crates/db_schema/src/source/person.rs index 4f5b4f931..fec48d069 100644 --- a/crates/db_schema/src/source/person.rs +++ b/crates/db_schema/src/source/person.rs @@ -33,9 +33,9 @@ pub struct Person { /// A URL for an avatar. #[cfg_attr(feature = "full", ts(optional))] pub avatar: Option, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, /// The federated ap_id. pub ap_id: DbUrl, /// An optional bio, in markdown. @@ -83,9 +83,9 @@ pub struct PersonInsertForm { #[new(default)] pub avatar: Option, #[new(default)] - pub published: Option>, + pub published_at: Option>, #[new(default)] - pub updated: Option>, + pub updated_at: Option>, #[new(default)] pub ap_id: Option, #[new(default)] @@ -114,7 +114,7 @@ pub struct PersonInsertForm { pub struct PersonUpdateForm { pub display_name: Option>, pub avatar: Option>, - pub updated: Option>>, + pub updated_at: Option>>, pub ap_id: Option, pub bio: Option>, pub local: Option, @@ -145,12 +145,12 @@ pub struct PersonActions { #[serde(skip)] pub person_id: PersonId, #[serde(skip)] - pub followed: Option>, + pub followed_at: Option>, #[serde(skip)] pub follow_pending: Option, #[cfg_attr(feature = "full", ts(optional))] /// When the person was blocked. - pub blocked: Option>, + pub blocked_at: Option>, } #[derive(Clone, derive_new::new)] @@ -161,7 +161,7 @@ pub struct PersonFollowerForm { pub person_id: PersonId, pub follow_pending: bool, #[new(value = "Utc::now()")] - pub followed: DateTime, + pub followed_at: DateTime, } #[derive(derive_new::new)] @@ -172,5 +172,5 @@ pub struct PersonBlockForm { pub person_id: PersonId, pub target_id: PersonId, #[new(value = "Utc::now()")] - pub blocked: DateTime, + pub blocked_at: DateTime, } diff --git a/crates/db_schema/src/source/person_comment_mention.rs b/crates/db_schema/src/source/person_comment_mention.rs index 173beb4b3..fb09bf60b 100644 --- a/crates/db_schema/src/source/person_comment_mention.rs +++ b/crates/db_schema/src/source/person_comment_mention.rs @@ -21,7 +21,7 @@ pub struct PersonCommentMention { pub recipient_id: PersonId, pub comment_id: CommentId, pub read: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] diff --git a/crates/db_schema/src/source/person_post_mention.rs b/crates/db_schema/src/source/person_post_mention.rs index dea6e109a..5bfb77fb0 100644 --- a/crates/db_schema/src/source/person_post_mention.rs +++ b/crates/db_schema/src/source/person_post_mention.rs @@ -21,7 +21,7 @@ pub struct PersonPostMention { pub recipient_id: PersonId, pub post_id: PostId, pub read: bool, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] diff --git a/crates/db_schema/src/source/post.rs b/crates/db_schema/src/source/post.rs index 7b8c067f2..0ec4489fd 100644 --- a/crates/db_schema/src/source/post.rs +++ b/crates/db_schema/src/source/post.rs @@ -35,9 +35,9 @@ pub struct Post { pub removed: bool, /// Whether the post is locked. pub locked: bool, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, /// Whether the post is deleted. pub deleted: bool, /// Whether the post is NSFW. @@ -70,16 +70,16 @@ pub struct Post { pub alt_text: Option, /// Time at which the post will be published. None means publish immediately. #[cfg_attr(feature = "full", ts(optional))] - pub scheduled_publish_time: Option>, + pub scheduled_publish_time_at: Option>, pub comments: i64, pub score: i64, pub upvotes: i64, pub downvotes: i64, #[serde(skip)] /// A newest comment time, limited to 2 days, to prevent necrobumping - pub newest_comment_time_necro: DateTime, + pub newest_comment_time_necro_at: DateTime, /// The time of the newest comment in the post. - pub newest_comment_time: DateTime, + pub newest_comment_time_at: DateTime, #[serde(skip)] pub hot_rank: f64, #[serde(skip)] @@ -118,9 +118,9 @@ pub struct PostInsertForm { #[new(default)] pub locked: Option, #[new(default)] - pub updated: Option>, + pub updated_at: Option>, #[new(default)] - pub published: Option>, + pub published_at: Option>, #[new(default)] pub deleted: Option, #[new(default)] @@ -146,7 +146,7 @@ pub struct PostInsertForm { #[new(default)] pub alt_text: Option, #[new(default)] - pub scheduled_publish_time: Option>, + pub scheduled_publish_time_at: Option>, #[new(default)] pub federation_pending: Option, } @@ -161,8 +161,8 @@ pub struct PostUpdateForm { pub body: Option>, pub removed: Option, pub locked: Option, - pub published: Option>, - pub updated: Option>>, + pub published_at: Option>, + pub updated_at: Option>>, pub deleted: Option, pub embed_title: Option>, pub embed_description: Option>, @@ -175,7 +175,7 @@ pub struct PostUpdateForm { pub featured_local: Option, pub url_content_type: Option>, pub alt_text: Option>, - pub scheduled_publish_time: Option>>, + pub scheduled_publish_time_at: Option>>, pub federation_pending: Option, } @@ -204,26 +204,26 @@ pub struct PostActions { pub person_id: PersonId, #[cfg_attr(feature = "full", ts(optional))] /// When the post was read. - pub read: Option>, + pub read_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When was the last time you read the comments. - pub read_comments: Option>, + pub read_comments_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// The number of comments you read last. Subtract this from total comments to get an unread /// count. pub read_comments_amount: Option, #[cfg_attr(feature = "full", ts(optional))] /// When the post was saved. - pub saved: Option>, + pub saved_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// When the post was liked. - pub liked: Option>, + pub liked_at: Option>, #[cfg_attr(feature = "full", ts(optional))] /// The like / score of the post. pub like_score: Option, #[cfg_attr(feature = "full", ts(optional))] /// When the post was hidden. - pub hidden: Option>, + pub hidden_at: Option>, } #[derive(Clone, derive_new::new)] @@ -237,7 +237,7 @@ pub struct PostLikeForm { pub person_id: PersonId, pub like_score: i16, #[new(value = "Utc::now()")] - pub liked: DateTime, + pub liked_at: DateTime, } #[derive(derive_new::new)] @@ -247,7 +247,7 @@ pub struct PostSavedForm { pub post_id: PostId, pub person_id: PersonId, #[new(value = "Utc::now()")] - pub saved: DateTime, + pub saved_at: DateTime, } #[derive(derive_new::new, Clone)] @@ -257,7 +257,7 @@ pub struct PostReadForm { pub post_id: PostId, pub person_id: PersonId, #[new(value = "Utc::now()")] - pub read: DateTime, + pub read_at: DateTime, } #[derive(derive_new::new)] @@ -268,7 +268,7 @@ pub struct PostReadCommentsForm { pub person_id: PersonId, pub read_comments_amount: i64, #[new(value = "Utc::now()")] - pub read_comments: DateTime, + pub read_comments_at: DateTime, } #[derive(derive_new::new)] @@ -278,5 +278,5 @@ pub struct PostHideForm { pub post_id: PostId, pub person_id: PersonId, #[new(value = "Utc::now()")] - pub hidden: DateTime, + pub hidden_at: DateTime, } diff --git a/crates/db_schema/src/source/post_report.rs b/crates/db_schema/src/source/post_report.rs index d04ea4d86..3236a550a 100644 --- a/crates/db_schema/src/source/post_report.rs +++ b/crates/db_schema/src/source/post_report.rs @@ -34,9 +34,9 @@ pub struct PostReport { pub resolved: bool, #[cfg_attr(feature = "full", ts(optional))] pub resolver_id: Option, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, pub violates_instance_rules: bool, } diff --git a/crates/db_schema/src/source/post_tag.rs b/crates/db_schema/src/source/post_tag.rs index bdf392a89..a80485420 100644 --- a/crates/db_schema/src/source/post_tag.rs +++ b/crates/db_schema/src/source/post_tag.rs @@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize}; pub struct PostTag { pub post_id: PostId, pub tag_id: TagId, - pub published: DateTime, + pub published_at: DateTime, } #[derive(Clone, Debug)] diff --git a/crates/db_schema/src/source/private_message.rs b/crates/db_schema/src/source/private_message.rs index 822ea60bb..3bfb853ac 100644 --- a/crates/db_schema/src/source/private_message.rs +++ b/crates/db_schema/src/source/private_message.rs @@ -28,9 +28,9 @@ pub struct PrivateMessage { pub content: String, pub deleted: bool, pub read: bool, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, pub ap_id: DbUrl, pub local: bool, pub removed: bool, @@ -51,9 +51,9 @@ pub struct PrivateMessageInsertForm { #[new(default)] pub read: Option, #[new(default)] - pub published: Option>, + pub published_at: Option>, #[new(default)] - pub updated: Option>, + pub updated_at: Option>, #[new(default)] pub ap_id: Option, #[new(default)] @@ -67,8 +67,8 @@ pub struct PrivateMessageUpdateForm { pub content: Option, pub deleted: Option, pub read: Option, - pub published: Option>, - pub updated: Option>>, + pub published_at: Option>, + pub updated_at: Option>>, pub ap_id: Option, pub local: Option, pub removed: Option, diff --git a/crates/db_schema/src/source/private_message_report.rs b/crates/db_schema/src/source/private_message_report.rs index 744d27242..73db6f114 100644 --- a/crates/db_schema/src/source/private_message_report.rs +++ b/crates/db_schema/src/source/private_message_report.rs @@ -31,9 +31,9 @@ pub struct PrivateMessageReport { pub resolved: bool, #[cfg_attr(feature = "full", ts(optional))] pub resolver_id: Option, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, } #[derive(Clone)] diff --git a/crates/db_schema/src/source/registration_application.rs b/crates/db_schema/src/source/registration_application.rs index c3234baf6..4cbc34f9f 100644 --- a/crates/db_schema/src/source/registration_application.rs +++ b/crates/db_schema/src/source/registration_application.rs @@ -22,7 +22,7 @@ pub struct RegistrationApplication { pub admin_id: Option, #[cfg_attr(feature = "full", ts(optional))] pub deny_reason: Option, - pub published: DateTime, + pub published_at: DateTime, } #[cfg_attr(feature = "full", derive(Insertable))] diff --git a/crates/db_schema/src/source/site.rs b/crates/db_schema/src/source/site.rs index 29d2cb5bc..fa6f1c272 100644 --- a/crates/db_schema/src/source/site.rs +++ b/crates/db_schema/src/source/site.rs @@ -24,9 +24,9 @@ pub struct Site { /// A sidebar for the site in markdown. #[cfg_attr(feature = "full", ts(optional))] pub sidebar: Option, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, /// An icon URL. #[cfg_attr(feature = "full", ts(optional))] pub icon: Option, @@ -62,7 +62,7 @@ pub struct SiteInsertForm { #[new(default)] pub sidebar: Option, #[new(default)] - pub updated: Option>, + pub updated_at: Option>, #[new(default)] pub icon: Option, #[new(default)] @@ -89,7 +89,7 @@ pub struct SiteInsertForm { pub struct SiteUpdateForm { pub name: Option, pub sidebar: Option>, - pub updated: Option>>, + pub updated_at: Option>>, // when you want to null out a column, you have to send Some(None)), since sending None means you // just don't want to update that column. pub icon: Option>, diff --git a/crates/db_schema/src/source/tag.rs b/crates/db_schema/src/source/tag.rs index 1a9273ba0..d5b086338 100644 --- a/crates/db_schema/src/source/tag.rs +++ b/crates/db_schema/src/source/tag.rs @@ -33,9 +33,9 @@ pub struct Tag { pub display_name: String, /// the community that owns this tag pub community_id: CommunityId, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, pub deleted: bool, } @@ -55,8 +55,8 @@ pub struct TagUpdateForm { pub ap_id: Option, pub display_name: Option, pub community_id: Option, - pub published: Option>, - pub updated: Option>>, + pub published_at: Option>, + pub updated_at: Option>>, pub deleted: Option, } diff --git a/crates/db_schema/src/source/tagline.rs b/crates/db_schema/src/source/tagline.rs index c75bbf18a..9359f53bd 100644 --- a/crates/db_schema/src/source/tagline.rs +++ b/crates/db_schema/src/source/tagline.rs @@ -19,9 +19,9 @@ use {i_love_jesus::CursorKeysModule, lemmy_db_schema_file::schema::tagline, ts_r pub struct Tagline { pub id: TaglineId, pub content: String, - pub published: DateTime, + pub published_at: DateTime, #[cfg_attr(feature = "full", ts(optional))] - pub updated: Option>, + pub updated_at: Option>, } #[derive(Clone, Default)] @@ -36,5 +36,5 @@ pub struct TaglineInsertForm { #[cfg_attr(feature = "full", diesel(table_name = tagline))] pub struct TaglineUpdateForm { pub content: String, - pub updated: Option>>, + pub updated_at: Option>>, } diff --git a/crates/db_schema/src/utils/queries.rs b/crates/db_schema/src/utils/queries.rs index 75e786704..7bc6d344f 100644 --- a/crates/db_schema/src/utils/queries.rs +++ b/crates/db_schema/src/utils/queries.rs @@ -49,11 +49,11 @@ use lemmy_db_schema_file::{ /// hidden, unless the user followed the community explicitly. #[diesel::dsl::auto_type] pub fn filter_blocked() -> _ { - instance_actions::blocked + instance_actions::blocked_at .is_null() - .or(community_actions::followed.is_not_null()) - .and(community_actions::blocked.is_null()) - .and(person_actions::blocked.is_null()) + .or(community_actions::followed_at.is_not_null()) + .and(community_actions::blocked_at.is_null()) + .and(person_actions::blocked_at.is_null()) } /// Checks that the creator_local_user is an admin. @@ -100,11 +100,11 @@ pub fn post_creator_is_admin() -> _ { /// - The local instance pub fn creator_banned() -> _ { let local_ban = creator_local_instance_actions - .field(instance_actions::received_ban) + .field(instance_actions::received_ban_at) .nullable() .is_not_null(); let home_ban = creator_home_instance_actions - .field(instance_actions::received_ban) + .field(instance_actions::received_ban_at) .nullable() .is_not_null(); local_ban.or(home_ban) @@ -121,10 +121,10 @@ pub fn creator_local_user_admin_join() -> _ { #[diesel::dsl::auto_type] fn am_higher_mod() -> _ { - let i_became_moderator = community_actions::became_moderator.nullable(); + let i_became_moderator = community_actions::became_moderator_at.nullable(); let creator_became_moderator = creator_community_actions - .field(community_actions::became_moderator) + .field(community_actions::became_moderator_at) .nullable(); i_became_moderator.is_not_null().and( @@ -161,7 +161,9 @@ pub fn local_user_can_mod_comment() -> _ { #[diesel::dsl::auto_type] pub fn local_user_community_can_mod() -> _ { let am_admin = local_user::admin.nullable(); - let am_moderator = community_actions::became_moderator.nullable().is_not_null(); + let am_moderator = community_actions::became_moderator_at + .nullable() + .is_not_null(); am_admin.or(am_moderator).is_not_distinct_from(true) } @@ -181,8 +183,8 @@ pub fn comment_select_remove_deletes() -> _ { comment::post_id, content, comment::removed, - comment::published, - comment::updated, + comment::published_at, + comment::updated_at, comment::deleted, comment::ap_id, comment::local, diff --git a/crates/db_schema_file/diesel_ltree.patch b/crates/db_schema_file/diesel_ltree.patch index 05ccf6324..e18e5278a 100644 --- a/crates/db_schema_file/diesel_ltree.patch +++ b/crates/db_schema_file/diesel_ltree.patch @@ -3,7 +3,7 @@ index 255c6422..f2ccf5e2 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -76,13 +76,13 @@ diesel::table! { - published -> Timestamptz, + published_at -> Timestamptz, } } diff --git a/crates/db_schema_file/replaceable_schema/triggers.sql b/crates/db_schema_file/replaceable_schema/triggers.sql index deaed653b..b00ff4be1 100644 --- a/crates/db_schema_file/replaceable_schema/triggers.sql +++ b/crates/db_schema_file/replaceable_schema/triggers.sql @@ -142,19 +142,19 @@ UPDATE post AS a SET comments = a.comments + diff.comments, - newest_comment_time = GREATEST (a.newest_comment_time, diff.newest_comment_time), - newest_comment_time_necro = GREATEST (a.newest_comment_time_necro, diff.newest_comment_time_necro) + newest_comment_time_at = GREATEST (a.newest_comment_time_at, diff.newest_comment_time_at), + newest_comment_time_necro_at = GREATEST (a.newest_comment_time_necro_at, diff.newest_comment_time_necro_at) FROM ( SELECT post.id AS post_id, coalesce(sum(count_diff), 0) AS comments, -- Old rows are excluded using `count_diff = 1` - max((comment).published) FILTER (WHERE count_diff = 1) AS newest_comment_time, - max((comment).published) FILTER (WHERE count_diff = 1 + max((comment).published_at) FILTER (WHERE count_diff = 1) AS newest_comment_time_at, + max((comment).published_at) FILTER (WHERE count_diff = 1 -- Ignore comments from the post's creator AND post.creator_id != (comment).creator_id -- Ignore comments on old posts - AND post.published > ((comment).published - '2 days'::interval)) AS newest_comment_time_necro + AND post.published_at > ((comment).published_at - '2 days'::interval)) AS newest_comment_time_necro_at FROM select_old_and_new_rows AS old_and_new_rows LEFT JOIN post ON post.id = (comment).post_id @@ -165,10 +165,10 @@ GROUP BY WHERE a.id = diff.post_id AND (diff.comments, - GREATEST (a.newest_comment_time, diff.newest_comment_time), - GREATEST (a.newest_comment_time_necro, diff.newest_comment_time_necro)) != (0, - a.newest_comment_time, - a.newest_comment_time_necro); + GREATEST (a.newest_comment_time_at, diff.newest_comment_time_at), + GREATEST (a.newest_comment_time_necro_at, diff.newest_comment_time_necro_at)) != (0, + a.newest_comment_time_at, + a.newest_comment_time_necro_at); UPDATE local_site AS a SET @@ -289,7 +289,7 @@ BEGIN FROM select_old_and_new_rows AS old_and_new_rows LEFT JOIN community ON community.id = (community_actions).community_id LEFT JOIN person ON person.id = (community_actions).person_id - WHERE (community_actions).followed IS NOT NULL GROUP BY (community_actions).community_id) AS diff + WHERE (community_actions).followed_at IS NOT NULL GROUP BY (community_actions).community_id) AS diff WHERE a.id = diff.community_id AND (diff.subscribers, diff.subscribers_local) != (0, 0); @@ -391,8 +391,8 @@ BEGIN NEW.ap_id = coalesce(NEW.ap_id, r.local_url ('/post/' || NEW.id::text)); END IF; -- Set aggregates - NEW.newest_comment_time = NEW.published; - NEW.newest_comment_time_necro = NEW.published; + NEW.newest_comment_time_at = NEW.published_at; + NEW.newest_comment_time_necro_at = NEW.published_at; RETURN NEW; END $$; @@ -417,7 +417,7 @@ CREATE TRIGGER change_values FOR EACH ROW EXECUTE FUNCTION r.private_message_change_values (); -- Combined tables triggers --- These insert (published, item_id) into X_combined tables +-- These insert (published_at, item_id) into X_combined tables -- Reports (comment_report, post_report, private_message_report) CREATE PROCEDURE r.create_report_combined_trigger (table_name text) LANGUAGE plpgsql @@ -428,8 +428,8 @@ BEGIN LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO report_combined (published, thing_id) - VALUES (NEW.published, NEW.id); + INSERT INTO report_combined (published_at, thing_id) + VALUES (NEW.published_at, NEW.id); RETURN NEW; END $$; CREATE TRIGGER report_combined @@ -455,8 +455,8 @@ BEGIN LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO person_content_combined (published, thing_id) - VALUES (NEW.published, NEW.id); + INSERT INTO person_content_combined (published_at, thing_id) + VALUES (NEW.published_at, NEW.id); RETURN NEW; END $$; CREATE TRIGGER person_content_combined @@ -489,14 +489,14 @@ BEGIN WHERE p.person_id = OLD.person_id AND p.thing_id = OLD.thing_id; ELSIF (TG_OP = 'INSERT') THEN - IF NEW.saved IS NOT NULL THEN - INSERT INTO person_saved_combined (saved, person_id, thing_id) - VALUES (NEW.saved, NEW.person_id, NEW.thing_id); + IF NEW.saved_at IS NOT NULL THEN + INSERT INTO person_saved_combined (saved_at, person_id, thing_id) + VALUES (NEW.saved_at, NEW.person_id, NEW.thing_id); END IF; ELSIF (TG_OP = 'UPDATE') THEN - IF NEW.saved IS NOT NULL THEN - INSERT INTO person_saved_combined (saved, person_id, thing_id) - VALUES (NEW.saved, NEW.person_id, NEW.thing_id); + IF NEW.saved_at IS NOT NULL THEN + INSERT INTO person_saved_combined (saved_at, person_id, thing_id) + VALUES (NEW.saved_at, NEW.person_id, NEW.thing_id); -- If saved gets set as null, delete the row ELSE DELETE FROM person_saved_combined AS p @@ -507,7 +507,7 @@ BEGIN RETURN NULL; END $$; CREATE TRIGGER person_saved_combined - AFTER INSERT OR DELETE OR UPDATE OF saved ON thing_actions + AFTER INSERT OR DELETE OR UPDATE OF saved_at ON thing_actions FOR EACH ROW EXECUTE FUNCTION r.person_saved_combined_change_values_thing ( ); $b$, @@ -536,26 +536,26 @@ BEGIN WHERE p.person_id = OLD.person_id AND p.thing_id = OLD.thing_id; ELSIF (TG_OP = 'INSERT') THEN - IF NEW.liked IS NOT NULL AND ( + IF NEW.liked_at IS NOT NULL AND ( SELECT local FROM person WHERE id = NEW.person_id) = TRUE THEN - INSERT INTO person_liked_combined (liked, like_score, person_id, thing_id) - VALUES (NEW.liked, NEW.like_score, NEW.person_id, NEW.thing_id); + INSERT INTO person_liked_combined (liked_at, like_score, person_id, thing_id) + VALUES (NEW.liked_at, NEW.like_score, NEW.person_id, NEW.thing_id); END IF; ELSIF (TG_OP = 'UPDATE') THEN - IF NEW.liked IS NOT NULL AND ( + IF NEW.liked_at IS NOT NULL AND ( SELECT local FROM person WHERE id = NEW.person_id) = TRUE THEN - INSERT INTO person_liked_combined (liked, like_score, person_id, thing_id) - VALUES (NEW.liked, NEW.like_score, NEW.person_id, NEW.thing_id); + INSERT INTO person_liked_combined (liked_at, like_score, person_id, thing_id) + VALUES (NEW.liked_at, NEW.like_score, NEW.person_id, NEW.thing_id); -- If liked gets set as null, delete the row ELSE DELETE FROM person_liked_combined AS p @@ -566,7 +566,7 @@ BEGIN RETURN NULL; END $$; CREATE TRIGGER person_liked_combined - AFTER INSERT OR DELETE OR UPDATE OF liked ON thing_actions + AFTER INSERT OR DELETE OR UPDATE OF liked_at ON thing_actions FOR EACH ROW EXECUTE FUNCTION r.person_liked_combined_change_values_thing ( ); $b$, @@ -603,8 +603,8 @@ BEGIN LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO modlog_combined (published, thing_id) - VALUES (NEW.published, NEW.id); + INSERT INTO modlog_combined (published_at, thing_id) + VALUES (NEW.published_at, NEW.id); RETURN NEW; END $$; CREATE TRIGGER modlog_combined @@ -643,8 +643,8 @@ BEGIN LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO inbox_combined (published, thing_id) - VALUES (NEW.published, NEW.id); + INSERT INTO inbox_combined (published_at, thing_id) + VALUES (NEW.published_at, NEW.id); RETURN NEW; END $$; CREATE TRIGGER inbox_combined @@ -703,8 +703,8 @@ BEGIN AS $$ BEGIN -- TODO need to figure out how to do the other columns here - INSERT INTO search_combined (published, thing_id) - VALUES (NEW.published, NEW.id); + INSERT INTO search_combined (published_at, thing_id) + VALUES (NEW.published_at, NEW.id); RETURN NEW; END $$; CREATE TRIGGER search_combined diff --git a/crates/db_schema_file/replaceable_schema/utils.sql b/crates/db_schema_file/replaceable_schema/utils.sql index a951f1a20..cd37c9bbf 100644 --- a/crates/db_schema_file/replaceable_schema/utils.sql +++ b/crates/db_schema_file/replaceable_schema/utils.sql @@ -15,25 +15,25 @@ CREATE FUNCTION r.controversy_rank (upvotes numeric, downvotes numeric) END END; -CREATE FUNCTION r.hot_rank (score numeric, published timestamp with time zone) +CREATE FUNCTION r.hot_rank (score numeric, published_at timestamp with time zone) RETURNS double precision LANGUAGE sql IMMUTABLE PARALLEL SAFE RETURN -- after a week, it will default to 0. CASE WHEN ( -now() - published) > '0 days' +now() - published_at) > '0 days' AND ( -now() - published) < '7 days' THEN +now() - published_at) < '7 days' THEN -- Use greatest(2,score), so that the hot_rank will be positive and not ignored. log ( - greatest (2, score + 2)) / power (((EXTRACT(EPOCH FROM (now() - published)) / 3600) + 2), 1.8) + greatest (2, score + 2)) / power (((EXTRACT(EPOCH FROM (now() - published_at)) / 3600) + 2), 1.8) ELSE -- if the post is from the future, set hot score to 0. otherwise you can game the post to -- always be on top even with only 1 vote by setting it to the future 0.0 END; -CREATE FUNCTION r.scaled_rank (score numeric, published timestamp with time zone, interactions_month numeric) +CREATE FUNCTION r.scaled_rank (score numeric, published_at timestamp with time zone, interactions_month numeric) RETURNS double precision LANGUAGE sql IMMUTABLE PARALLEL SAFE @@ -42,7 +42,7 @@ CREATE FUNCTION r.scaled_rank (score numeric, published timestamp with time zone -- There may need to be a scale factor multiplied to interactions_month, to make -- the log curve less pronounced. This can be tuned in the future. RETURN ( - r.hot_rank (score, published) / log(2 + interactions_month) + r.hot_rank (score, published_at) / log(2 + interactions_month) ); -- For tables with `deleted` and `removed` columns, this function determines which rows to include in a count. @@ -172,7 +172,7 @@ BEGIN INNER JOIN post p ON c.post_id = p.id INNER JOIN person pe ON c.creator_id = pe.id WHERE - c.published > ('now'::timestamp - i::interval) + c.published_at > ('now'::timestamp - i::interval) AND pe.bot_account = FALSE UNION SELECT @@ -182,7 +182,7 @@ BEGIN post p INNER JOIN person pe ON p.creator_id = pe.id WHERE - p.published > ('now'::timestamp - i::interval) + p.published_at > ('now'::timestamp - i::interval) AND pe.bot_account = FALSE UNION SELECT @@ -193,7 +193,7 @@ BEGIN INNER JOIN post p ON pa.post_id = p.id INNER JOIN person pe ON pa.person_id = pe.id WHERE - pa.liked > ('now'::timestamp - i::interval) + pa.liked_at > ('now'::timestamp - i::interval) AND pe.bot_account = FALSE UNION SELECT @@ -205,7 +205,7 @@ BEGIN INNER JOIN post p ON c.post_id = p.id INNER JOIN person pe ON ca.person_id = pe.id WHERE - ca.liked > ('now'::timestamp - i::interval) + ca.liked_at > ('now'::timestamp - i::interval) AND pe.bot_account = FALSE) a GROUP BY community_id; @@ -227,7 +227,7 @@ BEGIN FROM post WHERE - published >= (CURRENT_TIMESTAMP - i::interval) + published_at >= (CURRENT_TIMESTAMP - i::interval) GROUP BY community_id; END; @@ -250,7 +250,7 @@ BEGIN comment c INNER JOIN person pe ON c.creator_id = pe.id WHERE - c.published > ('now'::timestamp - i::interval) + c.published_at > ('now'::timestamp - i::interval) AND pe.local = TRUE AND pe.bot_account = FALSE UNION @@ -260,7 +260,7 @@ BEGIN post p INNER JOIN person pe ON p.creator_id = pe.id WHERE - p.published > ('now'::timestamp - i::interval) + p.published_at > ('now'::timestamp - i::interval) AND pe.local = TRUE AND pe.bot_account = FALSE UNION @@ -270,7 +270,7 @@ BEGIN post_actions pa INNER JOIN person pe ON pa.person_id = pe.id WHERE - pa.liked > ('now'::timestamp - i::interval) + pa.liked_at > ('now'::timestamp - i::interval) AND pe.local = TRUE AND pe.bot_account = FALSE UNION @@ -280,7 +280,7 @@ BEGIN comment_actions ca INNER JOIN person pe ON ca.person_id = pe.id WHERE - ca.liked > ('now'::timestamp - i::interval) + ca.liked_at > ('now'::timestamp - i::interval) AND pe.local = TRUE AND pe.bot_account = FALSE) a; RETURN count_; diff --git a/crates/db_schema_file/src/schema.rs b/crates/db_schema_file/src/schema.rs index 16be94387..29c6ba459 100644 --- a/crates/db_schema_file/src/schema.rs +++ b/crates/db_schema_file/src/schema.rs @@ -53,7 +53,7 @@ diesel::table! { admin_person_id -> Int4, allowed -> Bool, reason -> Nullable, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -64,8 +64,8 @@ diesel::table! { admin_person_id -> Int4, blocked -> Bool, reason -> Nullable, - expires -> Nullable, - published -> Timestamptz, + expires_at -> Nullable, + published_at -> Timestamptz, } } @@ -75,7 +75,7 @@ diesel::table! { admin_person_id -> Int4, post_id -> Int4, reason -> Nullable, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -84,7 +84,7 @@ diesel::table! { id -> Int4, admin_person_id -> Int4, reason -> Nullable, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -93,7 +93,7 @@ diesel::table! { id -> Int4, admin_person_id -> Int4, reason -> Nullable, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -103,7 +103,7 @@ diesel::table! { admin_person_id -> Int4, community_id -> Int4, reason -> Nullable, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -111,7 +111,7 @@ diesel::table! { captcha_answer (uuid) { uuid -> Uuid, answer -> Text, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -125,8 +125,8 @@ diesel::table! { post_id -> Int4, content -> Text, removed -> Bool, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, deleted -> Bool, #[max_length = 255] ap_id -> Varchar, @@ -151,8 +151,8 @@ diesel::table! { person_id -> Int4, comment_id -> Int4, like_score -> Nullable, - liked -> Nullable, - saved -> Nullable, + liked_at -> Nullable, + saved_at -> Nullable, } } @@ -162,7 +162,7 @@ diesel::table! { recipient_id -> Int4, comment_id -> Int4, read -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -175,8 +175,8 @@ diesel::table! { reason -> Text, resolved -> Bool, resolver_id -> Nullable, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, violates_instance_rules -> Bool, } } @@ -193,8 +193,8 @@ diesel::table! { title -> Varchar, sidebar -> Nullable, removed -> Bool, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, deleted -> Bool, nsfw -> Bool, #[max_length = 255] @@ -242,13 +242,13 @@ diesel::table! { community_actions (person_id, community_id) { community_id -> Int4, person_id -> Int4, - followed -> Nullable, + followed_at -> Nullable, follow_state -> Nullable, follow_approver_id -> Nullable, - blocked -> Nullable, - became_moderator -> Nullable, - received_ban -> Nullable, - ban_expires -> Nullable, + blocked_at -> Nullable, + became_moderator_at -> Nullable, + received_ban_at -> Nullable, + ban_expires_at -> Nullable, } } @@ -273,8 +273,8 @@ diesel::table! { reason -> Text, resolved -> Bool, resolver_id -> Nullable, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, } } @@ -286,8 +286,8 @@ diesel::table! { image_url -> Text, alt_text -> Text, category -> Text, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, } } @@ -305,24 +305,24 @@ diesel::table! { local_user_id -> Int4, email -> Text, verification_token -> Text, - published -> Timestamptz, + published_at -> Timestamptz, } } diesel::table! { federation_allowlist (instance_id) { instance_id -> Int4, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, } } diesel::table! { federation_blocklist (instance_id) { instance_id -> Int4, - published -> Timestamptz, - updated -> Nullable, - expires -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, + expires_at -> Nullable, } } @@ -331,8 +331,8 @@ diesel::table! { instance_id -> Int4, last_successful_id -> Nullable, fail_count -> Int4, - last_retry -> Nullable, - last_successful_published_time -> Nullable, + last_retry_at -> Nullable, + last_successful_published_time_at -> Nullable, } } @@ -350,7 +350,7 @@ diesel::table! { diesel::table! { inbox_combined (id) { id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, comment_reply_id -> Nullable, person_comment_mention_id -> Nullable, person_post_mention_id -> Nullable, @@ -363,8 +363,8 @@ diesel::table! { id -> Int4, #[max_length = 255] domain -> Varchar, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, #[max_length = 255] software -> Nullable, #[max_length = 255] @@ -376,9 +376,9 @@ diesel::table! { instance_actions (person_id, instance_id) { person_id -> Int4, instance_id -> Int4, - blocked -> Nullable, - received_ban -> Nullable, - ban_expires -> Nullable, + blocked_at -> Nullable, + received_ban_at -> Nullable, + ban_expires_at -> Nullable, } } @@ -394,7 +394,7 @@ diesel::table! { diesel::table! { local_image (pictrs_alias) { pictrs_alias -> Text, - published -> Timestamptz, + published_at -> Timestamptz, person_id -> Int4, thumbnail_for_post_id -> Nullable, } @@ -427,8 +427,8 @@ diesel::table! { captcha_enabled -> Bool, #[max_length = 255] captcha_difficulty -> Varchar, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, registration_mode -> RegistrationModeEnum, reports_email_admins -> Bool, federation_signed_fetch -> Bool, @@ -469,8 +469,8 @@ diesel::table! { comment_per_second -> Int4, search -> Int4, search_per_second -> Int4, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, import_user_settings -> Int4, import_user_settings_per_second -> Int4, } @@ -480,8 +480,8 @@ diesel::table! { local_site_url_blocklist (id) { id -> Int4, url -> Text, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, } } @@ -523,7 +523,7 @@ diesel::table! { collapse_bot_comments -> Bool, default_comment_sort_type -> CommentSortTypeEnum, auto_mark_fetched_posts_as_read -> Bool, - last_donation_notification -> Timestamptz, + last_donation_notification_at -> Timestamptz, hide_media -> Bool, default_post_time_range_seconds -> Nullable, show_score -> Bool, @@ -552,7 +552,7 @@ diesel::table! { login_token (token) { token -> Text, user_id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, ip -> Nullable, user_agent -> Nullable, } @@ -564,7 +564,7 @@ diesel::table! { mod_person_id -> Int4, other_person_id -> Int4, removed -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -575,7 +575,7 @@ diesel::table! { other_person_id -> Int4, community_id -> Int4, removed -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -586,8 +586,8 @@ diesel::table! { other_person_id -> Int4, reason -> Nullable, banned -> Bool, - expires -> Nullable, - published -> Timestamptz, + expires_at -> Nullable, + published_at -> Timestamptz, instance_id -> Int4, } } @@ -600,8 +600,8 @@ diesel::table! { community_id -> Int4, reason -> Nullable, banned -> Bool, - expires -> Nullable, - published -> Timestamptz, + expires_at -> Nullable, + published_at -> Timestamptz, } } @@ -613,7 +613,7 @@ diesel::table! { id -> Int4, community_id -> Int4, mod_person_id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, visibility -> CommunityVisibility, } } @@ -624,7 +624,7 @@ diesel::table! { mod_person_id -> Int4, post_id -> Int4, featured -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, is_featured_community -> Bool, } } @@ -635,7 +635,7 @@ diesel::table! { mod_person_id -> Int4, post_id -> Int4, locked -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, reason -> Nullable, } } @@ -647,7 +647,7 @@ diesel::table! { comment_id -> Int4, reason -> Nullable, removed -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -658,7 +658,7 @@ diesel::table! { community_id -> Int4, reason -> Nullable, removed -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -669,7 +669,7 @@ diesel::table! { post_id -> Int4, reason -> Nullable, removed -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -679,14 +679,14 @@ diesel::table! { mod_person_id -> Int4, other_person_id -> Int4, community_id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, } } diesel::table! { modlog_combined (id) { id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, admin_allow_instance_id -> Nullable, admin_block_instance_id -> Nullable, admin_purge_comment_id -> Nullable, @@ -712,8 +712,8 @@ diesel::table! { local_user_id -> Int4, oauth_provider_id -> Int4, oauth_user_id -> Text, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, } } @@ -732,8 +732,8 @@ diesel::table! { auto_verify_email -> Bool, account_linking_enabled -> Bool, enabled -> Bool, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, use_pkce -> Bool, } } @@ -742,7 +742,7 @@ diesel::table! { password_reset_request (id) { id -> Int4, token -> Text, - published -> Timestamptz, + published_at -> Timestamptz, local_user_id -> Int4, } } @@ -755,8 +755,8 @@ diesel::table! { #[max_length = 255] display_name -> Nullable, avatar -> Nullable, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, #[max_length = 255] ap_id -> Varchar, bio -> Nullable, @@ -782,16 +782,16 @@ diesel::table! { person_actions (person_id, target_id) { target_id -> Int4, person_id -> Int4, - followed -> Nullable, + followed_at -> Nullable, follow_pending -> Nullable, - blocked -> Nullable, + blocked_at -> Nullable, } } diesel::table! { person_ban (person_id) { person_id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -801,14 +801,14 @@ diesel::table! { recipient_id -> Int4, comment_id -> Int4, read -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } diesel::table! { person_content_combined (id) { id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, post_id -> Nullable, comment_id -> Nullable, } @@ -817,7 +817,7 @@ diesel::table! { diesel::table! { person_liked_combined (id) { id -> Int4, - liked -> Timestamptz, + liked_at -> Timestamptz, like_score -> Int2, person_id -> Int4, post_id -> Nullable, @@ -831,14 +831,14 @@ diesel::table! { recipient_id -> Int4, post_id -> Int4, read -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, } } diesel::table! { person_saved_combined (id) { id -> Int4, - saved -> Timestamptz, + saved_at -> Timestamptz, person_id -> Int4, post_id -> Nullable, comment_id -> Nullable, @@ -857,8 +857,8 @@ diesel::table! { community_id -> Int4, removed -> Bool, locked -> Bool, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, deleted -> Bool, nsfw -> Bool, embed_title -> Nullable, @@ -873,13 +873,13 @@ diesel::table! { featured_local -> Bool, url_content_type -> Nullable, alt_text -> Nullable, - scheduled_publish_time -> Nullable, + scheduled_publish_time_at -> Nullable, comments -> Int8, score -> Int8, upvotes -> Int8, downvotes -> Int8, - newest_comment_time_necro -> Timestamptz, - newest_comment_time -> Timestamptz, + newest_comment_time_necro_at -> Timestamptz, + newest_comment_time_at -> Timestamptz, hot_rank -> Float8, hot_rank_active -> Float8, controversy_rank -> Float8, @@ -894,13 +894,13 @@ diesel::table! { post_actions (person_id, post_id) { post_id -> Int4, person_id -> Int4, - read -> Nullable, - read_comments -> Nullable, + read_at -> Nullable, + read_comments_at -> Nullable, read_comments_amount -> Nullable, - saved -> Nullable, - liked -> Nullable, + saved_at -> Nullable, + liked_at -> Nullable, like_score -> Nullable, - hidden -> Nullable, + hidden_at -> Nullable, } } @@ -916,8 +916,8 @@ diesel::table! { reason -> Text, resolved -> Bool, resolver_id -> Nullable, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, violates_instance_rules -> Bool, } } @@ -926,7 +926,7 @@ diesel::table! { post_tag (post_id, tag_id) { post_id -> Int4, tag_id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -945,8 +945,8 @@ diesel::table! { content -> Text, deleted -> Bool, read -> Bool, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, #[max_length = 255] ap_id -> Varchar, local -> Bool, @@ -963,15 +963,15 @@ diesel::table! { reason -> Text, resolved -> Bool, resolver_id -> Nullable, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, } } diesel::table! { received_activity (ap_id) { ap_id -> Text, - published -> Timestamptz, + published_at -> Timestamptz, } } @@ -982,21 +982,21 @@ diesel::table! { answer -> Text, admin_id -> Nullable, deny_reason -> Nullable, - published -> Timestamptz, + published_at -> Timestamptz, } } diesel::table! { remote_image (link) { link -> Text, - published -> Timestamptz, + published_at -> Timestamptz, } } diesel::table! { report_combined (id) { id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, post_report_id -> Nullable, comment_report_id -> Nullable, private_message_report_id -> Nullable, @@ -1007,7 +1007,7 @@ diesel::table! { diesel::table! { search_combined (id) { id -> Int4, - published -> Timestamptz, + published_at -> Timestamptz, score -> Int8, post_id -> Nullable, comment_id -> Nullable, @@ -1032,7 +1032,7 @@ diesel::table! { ap_id -> Text, data -> Json, sensitive -> Bool, - published -> Timestamptz, + published_at -> Timestamptz, send_inboxes -> Array>, send_community_followers_of -> Nullable, send_all_instances -> Bool, @@ -1047,8 +1047,8 @@ diesel::table! { #[max_length = 20] name -> Varchar, sidebar -> Nullable, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, icon -> Nullable, banner -> Nullable, #[max_length = 150] @@ -1078,8 +1078,8 @@ diesel::table! { ap_id -> Text, display_name -> Text, community_id -> Int4, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, deleted -> Bool, } } @@ -1088,8 +1088,8 @@ diesel::table! { tagline (id) { id -> Int4, content -> Text, - published -> Timestamptz, - updated -> Nullable, + published_at -> Timestamptz, + updated_at -> Nullable, } } diff --git a/crates/db_views/api_misc/Cargo.toml b/crates/db_views/api_misc/Cargo.toml index 518c3fa30..a7ded3c88 100644 --- a/crates/db_views/api_misc/Cargo.toml +++ b/crates/db_views/api_misc/Cargo.toml @@ -18,12 +18,9 @@ workspace = true full = [ "lemmy_db_schema/full", "lemmy_db_schema_file/full", - "lemmy_db_views_comment/full", - "lemmy_db_views_community/full", "lemmy_db_views_community_follower/full", "lemmy_db_views_community_moderator/full", "lemmy_db_views_local_user/full", - "lemmy_db_views_person/full", "lemmy_db_views_post/full", "lemmy_db_views_post/full", "extism", @@ -34,12 +31,9 @@ full = [ [dependencies] lemmy_db_schema.workspace = true lemmy_db_schema_file.workspace = true -lemmy_db_views_comment.workspace = true -lemmy_db_views_community.workspace = true lemmy_db_views_community_follower.workspace = true lemmy_db_views_community_moderator.workspace = true lemmy_db_views_local_user.workspace = true -lemmy_db_views_person.workspace = true lemmy_db_views_post.workspace = true serde.workspace = true serde_with.workspace = true diff --git a/crates/db_views/api_misc/src/lib.rs b/crates/db_views/api_misc/src/lib.rs index b91294d83..dfb7f859e 100644 --- a/crates/db_views/api_misc/src/lib.rs +++ b/crates/db_views/api_misc/src/lib.rs @@ -10,12 +10,9 @@ use lemmy_db_schema_file::enums::{ PostSortType, VoteShow, }; -use lemmy_db_views_comment::CommentView; -use lemmy_db_views_community::CommunityView; use lemmy_db_views_community_follower::CommunityFollowerView; use lemmy_db_views_community_moderator::CommunityModeratorView; use lemmy_db_views_local_user::LocalUserView; -use lemmy_db_views_person::PersonView; use lemmy_db_views_post::PostView; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; @@ -240,23 +237,6 @@ pub struct ResolveObject { pub q: String, } -#[skip_serializing_none] -#[derive(Debug, Serialize, Deserialize, Default)] -#[cfg_attr(feature = "full", derive(TS))] -#[cfg_attr(feature = "full", ts(export))] -// TODO Change this to an enum -/// The response of an apub object fetch. -pub struct ResolveObjectResponse { - #[cfg_attr(feature = "full", ts(optional))] - pub comment: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub post: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub community: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub person: Option, -} - #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "full", derive(TS))] diff --git a/crates/db_views/comment/src/impls.rs b/crates/db_views/comment/src/impls.rs index 81a836232..80adce21b 100644 --- a/crates/db_views/comment/src/impls.rs +++ b/crates/db_views/comment/src/impls.rs @@ -186,7 +186,7 @@ impl CommentQuery<'_> { query = query.filter(post::community_id.eq(community_id)); } - let is_subscribed = community_actions::followed.is_not_null(); + let is_subscribed = community_actions::followed_at.is_not_null(); // For posts, we only show hidden if its subscribed, but for comments, // we ignore hidden. @@ -194,7 +194,9 @@ impl CommentQuery<'_> { ListingType::Subscribed => query.filter(is_subscribed), ListingType::Local => query.filter(community::local.eq(true)), ListingType::All => query, - ListingType::ModeratorView => query.filter(community_actions::became_moderator.is_not_null()), + ListingType::ModeratorView => { + query.filter(community_actions::became_moderator_at.is_not_null()) + } }; if !o.local_user.show_bot_accounts() { @@ -242,7 +244,7 @@ impl CommentQuery<'_> { // Filter by the time range if let Some(time_range_seconds) = o.time_range_seconds { query = - query.filter(comment::published.gt(now() - seconds_to_pg_interval(time_range_seconds))); + query.filter(comment::published_at.gt(now() - seconds_to_pg_interval(time_range_seconds))); } // A Max depth given means its a tree fetch @@ -296,7 +298,7 @@ impl CommentQuery<'_> { pq = match sort { Hot => pq.then_order_by(key::hot_rank).then_order_by(key::score), Controversial => pq.then_order_by(key::controversy_rank), - Old | New => pq.then_order_by(key::published), + Old | New => pq.then_order_by(key::published_at), Top => pq.then_order_by(key::score), }; @@ -443,7 +445,7 @@ mod tests { ( inserted_block.person_id, inserted_block.target_id, - inserted_block.blocked.is_some() + inserted_block.blocked_at.is_some() ) ); @@ -519,7 +521,7 @@ mod tests { // Make sure block set the creator blocked assert!(read_comment_from_blocked_person .person_actions - .is_some_and(|x| x.blocked.is_some())); + .is_some_and(|x| x.blocked_at.is_some())); cleanup(data, pool).await } @@ -710,7 +712,7 @@ mod tests { assert!(comments[1] .creator_community_actions .as_ref() - .is_some_and(|x| x.became_moderator.is_some())); + .is_some_and(|x| x.became_moderator_at.is_some())); assert!(comments[0].creator_community_actions.is_none()); @@ -845,7 +847,7 @@ mod tests { assert!(comment_view .community_actions - .is_some_and(|x| x.received_ban.is_some())); + .is_some_and(|x| x.received_ban_at.is_some())); Person::delete(pool, inserted_banned_from_comm_person.id).await?; cleanup(data, pool).await diff --git a/crates/db_views/community/src/api.rs b/crates/db_views/community/src/api.rs index 8d69118f4..6d36b5cf3 100644 --- a/crates/db_views/community/src/api.rs +++ b/crates/db_views/community/src/api.rs @@ -58,7 +58,7 @@ pub struct BanFromCommunity { /// /// An i64 unix timestamp is used for a simpler API client implementation. #[cfg_attr(feature = "full", ts(optional))] - pub expires: Option, + pub expires_at: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/crates/db_views/community/src/impls.rs b/crates/db_views/community/src/impls.rs index 10cf03c4f..51d34bf69 100644 --- a/crates/db_views/community/src/impls.rs +++ b/crates/db_views/community/src/impls.rs @@ -132,15 +132,15 @@ impl CommunityQuery<'_> { .filter(community::local.eq(true)) .filter(filter_not_unlisted_or_is_subscribed()), ListingType::ModeratorView => { - query.filter(community_actions::became_moderator.is_not_null()) + query.filter(community_actions::became_moderator_at.is_not_null()) } }; } // Don't show blocked communities and communities on blocked instances. nsfw communities are // also hidden (based on profile setting) - query = query.filter(instance_actions::blocked.is_null()); - query = query.filter(community_actions::blocked.is_null()); + query = query.filter(instance_actions::blocked_at.is_null()); + query = query.filter(community_actions::blocked_at.is_null()); if !(o.local_user.show_nsfw(site) || o.show_nsfw.unwrap_or_default()) { query = query.filter(community::nsfw.eq(false)); } @@ -149,8 +149,8 @@ impl CommunityQuery<'_> { // Filter by the time range if let Some(time_range_seconds) = o.time_range_seconds { - query = - query.filter(community::published.gt(now() - seconds_to_pg_interval(time_range_seconds))); + query = query + .filter(community::published_at.gt(now() - seconds_to_pg_interval(time_range_seconds))); } // Only sort by ascending for Old or NameAsc sorts. @@ -163,8 +163,8 @@ impl CommunityQuery<'_> { Hot => pq.then_order_by(key::hot_rank), Comments => pq.then_order_by(key::comments), Posts => pq.then_order_by(key::posts), - New => pq.then_order_by(key::published), - Old => pq.then_order_by(key::published), + New => pq.then_order_by(key::published_at), + Old => pq.then_order_by(key::published_at), Subscribers => pq.then_order_by(key::subscribers), SubscribersLocal => pq.then_order_by(key::subscribers_local), ActiveSixMonths => pq.then_order_by(key::users_active_half_year), @@ -270,8 +270,8 @@ mod tests { id: Default::default(), name: String::new(), sidebar: None, - published: Default::default(), - updated: None, + published_at: Default::default(), + updated_at: None, icon: None, banner: None, description: None, diff --git a/crates/db_views/community_follower/src/impls.rs b/crates/db_views/community_follower/src/impls.rs index 3073eaa08..840f1729a 100644 --- a/crates/db_views/community_follower/src/impls.rs +++ b/crates/db_views/community_follower/src/impls.rs @@ -31,7 +31,7 @@ impl CommunityFollowerView { #[diesel::dsl::auto_type(no_type_alias)] fn joins() -> _ { community_actions::table - .filter(community_actions::followed.is_not_null()) + .filter(community_actions::followed_at.is_not_null()) .inner_join(community::table) .inner_join(person::table.on(community_actions::person_id.eq(person::id))) } @@ -55,7 +55,7 @@ impl CommunityFollowerView { .filter(community::local) // this should be a no-op since community_followers table only has // local-person+remote-community or remote-person+local-community .filter(not(person::local)) - .filter(community_actions::followed.gt(published_since.naive_utc())) + .filter(community_actions::followed_at.gt(published_since.naive_utc())) .select((community::id, person::inbox_url)) .distinct() // only need each community_id, inbox combination once .load::<(CommunityId, DbUrl)>(conn) @@ -162,7 +162,7 @@ impl CommunityFollowerView { if all_communities { // if param is false, only return items for communities where user is a mod query = query - .filter(community_actions::became_moderator.is_not_null()) + .filter(community_actions::became_moderator_at.is_not_null()) .filter(community_actions::person_id.eq(person_id)); } if pending_only { @@ -172,7 +172,7 @@ impl CommunityFollowerView { // Sorting by published let paginated_query = paginate(query, SortDirection::Asc, cursor_data, None, page_back) - .then_order_by(key::followed); + .then_order_by(key::followed_at); let res = paginated_query .load::<(Person, Community, bool, Option)>(conn) diff --git a/crates/db_views/community_moderator/src/impls.rs b/crates/db_views/community_moderator/src/impls.rs index bb96bade9..594980435 100644 --- a/crates/db_views/community_moderator/src/impls.rs +++ b/crates/db_views/community_moderator/src/impls.rs @@ -14,7 +14,7 @@ impl CommunityModeratorView { #[diesel::dsl::auto_type(no_type_alias)] fn joins() -> _ { community_actions::table - .filter(community_actions::became_moderator.is_not_null()) + .filter(community_actions::became_moderator_at.is_not_null()) .inner_join(community::table) .inner_join(person::table.on(person::id.eq(community_actions::person_id))) } @@ -58,7 +58,7 @@ impl CommunityModeratorView { Self::joins() .filter(community_actions::community_id.eq(community_id)) .select(Self::as_select()) - .order_by(community_actions::became_moderator) + .order_by(community_actions::became_moderator_at) .load::(conn) .await .with_lemmy_type(LemmyErrorType::NotFound) @@ -106,7 +106,7 @@ impl CommunityModeratorView { .distinct_on(community_actions::community_id) .order_by(( community_actions::community_id, - community_actions::became_moderator, + community_actions::became_moderator_at, )) .load::(conn) .await diff --git a/crates/db_views/community_person_ban/src/impls.rs b/crates/db_views/community_person_ban/src/impls.rs index 7b63c7ede..1abaf3c2e 100644 --- a/crates/db_views/community_person_ban/src/impls.rs +++ b/crates/db_views/community_person_ban/src/impls.rs @@ -22,7 +22,7 @@ impl CommunityPersonBanView { let conn = &mut get_conn(pool).await?; let find_action = community_actions::table .find((from_person_id, from_community_id)) - .filter(community_actions::received_ban.is_not_null()); + .filter(community_actions::received_ban_at.is_not_null()); select(not(exists(find_action))) .get_result::(conn) .await? diff --git a/crates/db_views/inbox_combined/src/impls.rs b/crates/db_views/inbox_combined/src/impls.rs index 02f285ea1..a0676e97d 100644 --- a/crates/db_views/inbox_combined/src/impls.rs +++ b/crates/db_views/inbox_combined/src/impls.rs @@ -174,8 +174,8 @@ impl InboxCombinedViewInternal { // Filter unreads .filter(unread_filter) // Don't count replies from blocked users - .filter(person_actions::blocked.is_null()) - .filter(instance_actions::blocked.is_null()) + .filter(person_actions::blocked_at.is_null()) + .filter(instance_actions::blocked_at.is_null()) .select(count(inbox_combined::id)) .into_boxed(); @@ -306,8 +306,8 @@ impl InboxCombinedQuery { // Dont show replies from blocked users or instances query = query - .filter(person_actions::blocked.is_null()) - .filter(instance_actions::blocked.is_null()); + .filter(person_actions::blocked_at.is_null()) + .filter(instance_actions::blocked_at.is_null()); if let Some(type_) = self.type_ { query = match type_ { @@ -333,7 +333,7 @@ impl InboxCombinedQuery { None, self.page_back, ) - .then_order_by(key::published) + .then_order_by(key::published_at) // Tie breaker .then_order_by(key::id); @@ -830,7 +830,7 @@ mod tests { ( inserted_block.person_id, inserted_block.target_id, - inserted_block.blocked.is_some() + inserted_block.blocked_at.is_some() ) ); @@ -873,7 +873,7 @@ mod tests { ( inserted_instance_block.person_id, inserted_instance_block.instance_id, - inserted_instance_block.blocked.is_some() + inserted_instance_block.blocked_at.is_some() ) ); diff --git a/crates/db_views/local_user/src/impls.rs b/crates/db_views/local_user/src/impls.rs index 7849e0e16..3781a07a8 100644 --- a/crates/db_views/local_user/src/impls.rs +++ b/crates/db_views/local_user/src/impls.rs @@ -152,7 +152,7 @@ impl LocalUserView { self .instance_actions .as_ref() - .is_some_and(|i| i.received_ban.is_some()) + .is_some_and(|i| i.received_ban_at.is_some()) } } @@ -178,14 +178,17 @@ impl LocalUserQuery { query = query.filter( actions - .field(instance_actions::received_ban) + .field(instance_actions::received_ban_at) .is_not_null() .and( - actions.field(instance_actions::ban_expires).is_null().or( - actions - .field(instance_actions::ban_expires) - .gt(now().nullable()), - ), + actions + .field(instance_actions::ban_expires_at) + .is_null() + .or( + actions + .field(instance_actions::ban_expires_at) + .gt(now().nullable()), + ), ), ); } @@ -197,7 +200,7 @@ impl LocalUserQuery { None, self.page_back, ) - .then_order_by(person_keys::published) + .then_order_by(person_keys::published_at) // Tie breaker .then_order_by(person_keys::id); diff --git a/crates/db_views/modlog_combined/src/impls.rs b/crates/db_views/modlog_combined/src/impls.rs index 7f4476ba9..8c81c46de 100644 --- a/crates/db_views/modlog_combined/src/impls.rs +++ b/crates/db_views/modlog_combined/src/impls.rs @@ -379,7 +379,9 @@ impl ModlogCombinedQuery<'_> { ListingType::Local => query .filter(community::local.eq(true)) .filter(filter_not_unlisted_or_is_subscribed()), - ListingType::ModeratorView => query.filter(community_actions::became_moderator.is_not_null()), + ListingType::ModeratorView => { + query.filter(community_actions::became_moderator_at.is_not_null()) + } }; // Sorting by published @@ -390,7 +392,7 @@ impl ModlogCombinedQuery<'_> { None, self.page_back, ) - .then_order_by(key::published) + .then_order_by(key::published_at) // Tie breaker .then_order_by(key::id); @@ -1005,7 +1007,7 @@ mod tests { other_person_id: data.jessica.id, banned: Some(true), reason: None, - expires: None, + expires_at: None, instance_id: data.instance.id, }; ModBan::create(pool, &form).await?; @@ -1016,7 +1018,7 @@ mod tests { community_id: data.community.id, banned: Some(true), reason: None, - expires: None, + expires_at: None, }; ModBanFromCommunity::create(pool, &form).await?; diff --git a/crates/db_views/person/src/api.rs b/crates/db_views/person/src/api.rs index 5ffa45a18..c37a1b612 100644 --- a/crates/db_views/person/src/api.rs +++ b/crates/db_views/person/src/api.rs @@ -41,7 +41,7 @@ pub struct BanPerson { /// /// An i64 unix timestamp is used for a simpler API client implementation. #[cfg_attr(feature = "full", ts(optional))] - pub expires: Option, + pub expires_at: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/crates/db_views/person/src/impls.rs b/crates/db_views/person/src/impls.rs index feaaf77a2..1f505f682 100644 --- a/crates/db_views/person/src/impls.rs +++ b/crates/db_views/person/src/impls.rs @@ -105,7 +105,7 @@ impl PersonQuery { None, self.page_back, ) - .then_order_by(key::published) + .then_order_by(key::published_at) // Tie breaker .then_order_by(key::id); diff --git a/crates/db_views/person_content_combined/src/impls.rs b/crates/db_views/person_content_combined/src/impls.rs index db1f9abeb..306c595e8 100644 --- a/crates/db_views/person_content_combined/src/impls.rs +++ b/crates/db_views/person_content_combined/src/impls.rs @@ -205,7 +205,7 @@ impl PersonContentCombinedQuery { None, self.page_back, ) - .then_order_by(key::published) + .then_order_by(key::published_at) // Tie breaker .then_order_by(key::id); diff --git a/crates/db_views/person_liked_combined/src/impls.rs b/crates/db_views/person_liked_combined/src/impls.rs index 2e62547ba..063d26cdc 100644 --- a/crates/db_views/person_liked_combined/src/impls.rs +++ b/crates/db_views/person_liked_combined/src/impls.rs @@ -193,7 +193,7 @@ impl PersonLikedCombinedQuery { None, self.page_back, ) - .then_order_by(key::liked) + .then_order_by(key::liked_at) // Tie breaker .then_order_by(key::id); diff --git a/crates/db_views/person_saved_combined/src/impls.rs b/crates/db_views/person_saved_combined/src/impls.rs index 82b8da4a4..4224ac6dc 100644 --- a/crates/db_views/person_saved_combined/src/impls.rs +++ b/crates/db_views/person_saved_combined/src/impls.rs @@ -183,7 +183,7 @@ impl PersonSavedCombinedQuery { None, self.page_back, ) - .then_order_by(key::saved) + .then_order_by(key::saved_at) // Tie breaker .then_order_by(key::id); diff --git a/crates/db_views/post/src/api.rs b/crates/db_views/post/src/api.rs index e4bdb03b7..f4e2d1b1f 100644 --- a/crates/db_views/post/src/api.rs +++ b/crates/db_views/post/src/api.rs @@ -41,7 +41,7 @@ pub struct CreatePost { pub tags: Option>, /// Time when this post should be scheduled. Null means publish immediately. #[cfg_attr(feature = "full", ts(optional))] - pub scheduled_publish_time: Option, + pub scheduled_publish_time_at: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)] @@ -89,7 +89,7 @@ pub struct EditPost { pub custom_thumbnail: Option, /// Time when this post should be scheduled. Null means publish immediately. #[cfg_attr(feature = "full", ts(optional))] - pub scheduled_publish_time: Option, + pub scheduled_publish_time_at: Option, #[cfg_attr(feature = "full", ts(optional))] pub tags: Option>, } diff --git a/crates/db_views/post/src/impls.rs b/crates/db_views/post/src/impls.rs index ed746668c..e124e803f 100644 --- a/crates/db_views/post/src/impls.rs +++ b/crates/db_views/post/src/impls.rs @@ -177,7 +177,7 @@ impl PostView { let query = PostView::joins(Some(my_person.id), my_person.instance_id) .filter(post_actions::person_id.eq(my_person.id)) - .filter(post_actions::read.is_not_null()) + .filter(post_actions::read_at.is_not_null()) .filter(filter_blocked()) .select(PostView::as_select()) .limit(limit) @@ -185,7 +185,7 @@ impl PostView { // Sorting by the read date let paginated_query = paginate(query, SortDirection::Desc, cursor_data, None, page_back) - .then_order_by(pa_key::read) + .then_order_by(pa_key::read_at) // Tie breaker .then_order_by(pa_key::post_id); @@ -208,7 +208,7 @@ impl PostView { let query = PostView::joins(Some(my_person.id), my_person.instance_id) .filter(post_actions::person_id.eq(my_person.id)) - .filter(post_actions::hidden.is_not_null()) + .filter(post_actions::hidden_at.is_not_null()) .filter(filter_blocked()) .select(PostView::as_select()) .limit(limit) @@ -216,7 +216,7 @@ impl PostView { // Sorting by the hidden date let paginated_query = paginate(query, SortDirection::Desc, cursor_data, None, page_back) - .then_order_by(pa_key::hidden) + .then_order_by(pa_key::hidden_at) // Tie breaker .then_order_by(pa_key::post_id); @@ -333,14 +333,14 @@ impl PostQuery<'_> { if let Some(person_id) = my_person_id { query = query.filter(post::deleted.eq(false).or(post::creator_id.eq(person_id))); query = query.filter( - post::scheduled_publish_time + post::scheduled_publish_time_at .is_null() .or(post::creator_id.eq(person_id)), ); } else { query = query .filter(post::deleted.eq(false)) - .filter(post::scheduled_publish_time.is_null()); + .filter(post::scheduled_publish_time_at.is_null()); } if let Some(community_id) = o.community_id.or(largest_subscribed_for_prefetch) { @@ -356,7 +356,7 @@ impl PostQuery<'_> { } ListingType::All => query = query.filter(filter_not_unlisted_or_is_subscribed()), ListingType::ModeratorView => { - query = query.filter(community_actions::became_moderator.is_not_null()); + query = query.filter(community_actions::became_moderator_at.is_not_null()); } } @@ -376,12 +376,12 @@ impl PostQuery<'_> { }; if !o.show_read.unwrap_or(o.local_user.show_read_posts()) { - query = query.filter(post_actions::read.is_null()); + query = query.filter(post_actions::read_at.is_null()); } // Hide the hidden posts if !o.show_hidden.unwrap_or_default() { - query = query.filter(post_actions::hidden.is_null()); + query = query.filter(post_actions::hidden_at.is_null()); } if o.hide_media.unwrap_or(o.local_user.hide_media()) { @@ -447,7 +447,8 @@ impl PostQuery<'_> { // Filter by the time range if let Some(time_range_seconds) = o.time_range_seconds { - query = query.filter(post::published.gt(now() - seconds_to_pg_interval(time_range_seconds))); + query = + query.filter(post::published_at.gt(now() - seconds_to_pg_interval(time_range_seconds))); } // Only sort by ascending for Old @@ -478,8 +479,8 @@ impl PostQuery<'_> { Hot => pq.then_order_by(key::hot_rank), Scaled => pq.then_order_by(key::scaled_rank), Controversial => pq.then_order_by(key::controversy_rank), - New | Old => pq.then_order_by(key::published), - NewComments => pq.then_order_by(key::newest_comment_time), + New | Old => pq.then_order_by(key::published_at), + NewComments => pq.then_order_by(key::newest_comment_time_at), MostComments => pq.then_order_by(key::comments), Top => pq.then_order_by(key::score), }; @@ -489,7 +490,7 @@ impl PostQuery<'_> { pq = match sort { // A second time-based sort would not be very useful New | Old | NewComments => pq, - _ => pq.then_order_by(key::published), + _ => pq.then_order_by(key::published_at), }; // finally use unique post id as tie breaker @@ -756,8 +757,8 @@ mod tests { id: Default::default(), name: String::new(), sidebar: None, - published: Default::default(), - updated: None, + published_at: Default::default(), + updated_at: None, icon: None, banner: None, description: None, @@ -1050,7 +1051,7 @@ mod tests { ( p.creator.name, p.creator_community_actions - .map(|x| x.became_moderator.is_some()) + .map(|x| x.became_moderator_at.is_some()) .unwrap_or(false), p.can_mod, ) @@ -1086,7 +1087,7 @@ mod tests { ( p.creator.name, p.creator_community_actions - .map(|x| x.became_moderator.is_some()) + .map(|x| x.became_moderator_at.is_some()) .unwrap_or(false), p.can_mod, ) @@ -1115,7 +1116,7 @@ mod tests { ( p.creator.name, p.creator_community_actions - .map(|x| x.became_moderator.is_some()) + .map(|x| x.became_moderator_at.is_some()) .unwrap_or(false), p.can_mod, ) @@ -1145,7 +1146,7 @@ mod tests { ( p.creator.name, p.creator_community_actions - .map(|x| x.became_moderator.is_some()) + .map(|x| x.became_moderator_at.is_some()) .unwrap_or(false), p.can_mod, ) @@ -1177,7 +1178,7 @@ mod tests { ( p.creator.name, p.creator_community_actions - .map(|x| x.became_moderator.is_some()) + .map(|x| x.became_moderator_at.is_some()) .unwrap_or(false), p.can_mod, ) @@ -1483,7 +1484,7 @@ mod tests { let post_form = PostInsertForm { featured_local: Some((comments % 2) == 0), featured_community: Some((comments % 2) == 0), - published: Some(Utc::now() - Duration::from_secs(comments % 3)), + published_at: Some(Utc::now() - Duration::from_secs(comments % 3)), ..PostInsertForm::new( "keep Christ in Christmas".to_owned(), data.tegan_local_user_view.person.id, @@ -1655,9 +1656,10 @@ mod tests { ); // Make sure that hidden field is true. - assert!(&post_listings_show_hidden - .get(1) - .is_some_and(|p| p.post_actions.as_ref().is_some_and(|a| a.hidden.is_some()))); + assert!(&post_listings_show_hidden.get(1).is_some_and(|p| p + .post_actions + .as_ref() + .is_some_and(|a| a.hidden_at.is_some()))); // Make sure only that one comes back for list_hidden let list_hidden = @@ -1797,7 +1799,7 @@ mod tests { assert!(post_view .community_actions - .is_some_and(|x| x.received_ban.is_some())); + .is_some_and(|x| x.received_ban_at.is_some())); Person::delete(pool, inserted_banned_from_comm_person.id).await?; Ok(()) @@ -1863,11 +1865,11 @@ mod tests { assert!(post_view .creator_local_instance_actions - .is_some_and(|x| x.received_ban.is_some())); + .is_some_and(|x| x.received_ban_at.is_some())); assert!(post_view .creator_home_instance_actions - .is_some_and(|x| x.received_ban.is_some())); + .is_some_and(|x| x.received_ban_at.is_some())); // This should be none, since john wasn't banned, only the creator. assert!(post_view.instance_actions.is_none()); diff --git a/crates/db_views/readable_federation_state/src/impls.rs b/crates/db_views/readable_federation_state/src/impls.rs index 2689ac6a1..1cad78aff 100644 --- a/crates/db_views/readable_federation_state/src/impls.rs +++ b/crates/db_views/readable_federation_state/src/impls.rs @@ -6,7 +6,7 @@ use lemmy_utils::federate_retry_sleep_duration; impl From for ReadableFederationState { fn from(internal_state: FederationQueueState) -> Self { ReadableFederationState { - next_retry: internal_state.last_retry.map(|r| { + next_retry: internal_state.last_retry_at.map(|r| { r + chrono::Duration::from_std(federate_retry_sleep_duration(internal_state.fail_count)) .expect("sleep duration longer than 2**63 ms (262 million years)") }), diff --git a/crates/db_views/registration_applications/src/impls.rs b/crates/db_views/registration_applications/src/impls.rs index de7335cef..f67737be2 100644 --- a/crates/db_views/registration_applications/src/impls.rs +++ b/crates/db_views/registration_applications/src/impls.rs @@ -116,9 +116,9 @@ impl RegistrationApplicationQuery { if o.unread_only.unwrap_or_default() { query = query .filter(RegistrationApplication::is_unread()) - .order_by(registration_application::published.asc()); + .order_by(registration_application::published_at.asc()); } else { - query = query.order_by(registration_application::published.desc()); + query = query.order_by(registration_application::published_at.desc()); } if o.verified_email_only.unwrap_or_default() { @@ -239,7 +239,7 @@ mod tests { enable_animated_images: sara_local_user.enable_animated_images, enable_private_messages: sara_local_user.enable_private_messages, collapse_bot_comments: sara_local_user.collapse_bot_comments, - last_donation_notification: sara_local_user.last_donation_notification, + last_donation_notification_at: sara_local_user.last_donation_notification_at, show_upvotes: sara_local_user.show_upvotes, show_downvotes: sara_local_user.show_downvotes, ..Default::default() @@ -248,7 +248,7 @@ mod tests { id: sara_person.id, name: sara_person.name.clone(), display_name: None, - published: sara_person.published, + published_at: sara_person.published_at, avatar: None, ap_id: sara_person.ap_id.clone(), local: true, @@ -256,7 +256,7 @@ mod tests { bot_account: false, bio: None, banner: None, - updated: None, + updated_at: None, inbox_url: sara_person.inbox_url.clone(), matrix_user_id: None, instance_id: instance.id, @@ -319,7 +319,7 @@ mod tests { id: timmy_person.id, name: timmy_person.name.clone(), display_name: None, - published: timmy_person.published, + published_at: timmy_person.published_at, avatar: None, ap_id: timmy_person.ap_id.clone(), local: true, @@ -327,7 +327,7 @@ mod tests { bot_account: false, bio: None, banner: None, - updated: None, + updated_at: None, inbox_url: timmy_person.inbox_url.clone(), matrix_user_id: None, instance_id: instance.id, diff --git a/crates/db_views/report_combined/src/impls.rs b/crates/db_views/report_combined/src/impls.rs index 3a4bad362..def3e03a5 100644 --- a/crates/db_views/report_combined/src/impls.rs +++ b/crates/db_views/report_combined/src/impls.rs @@ -314,7 +314,7 @@ impl ReportCombinedQuery { None, self.page_back, ) - .then_order_by(key::published) + .then_order_by(key::published_at) // Tie breaker .then_order_by(key::id); @@ -336,7 +336,7 @@ impl ReportCombinedQuery { /// and which have `violates_instance_rules == false`. #[diesel::dsl::auto_type] fn filter_mod_reports() -> _ { - community_actions::became_moderator + community_actions::became_moderator_at .is_not_null() // Reporting a community or private message must go to admins .and(report_combined::community_report_id.is_null()) @@ -349,9 +349,9 @@ fn filter_mod_reports() -> _ { #[diesel::dsl::auto_type] fn filter_admin_reports(interval: DateTime) -> _ { filter_violates_instance_rules() - .or(report_combined::published.lt(interval)) + .or(report_combined::published_at.lt(interval)) // Also show community reports where the admin is a community mod - .or(community_actions::became_moderator.is_not_null()) + .or(community_actions::became_moderator_at.is_not_null()) } /// Filter reports which are only for admins (either post/comment report with @@ -1219,7 +1219,7 @@ mod tests { update( report_combined::table.filter(report_combined::dsl::comment_report_id.eq(comment_report.id)), ) - .set(report_combined::published.eq(Utc::now() - Days::new(3))) + .set(report_combined::published_at.eq(Utc::now() - Days::new(3))) .execute(&mut get_conn(pool).await?) .await?; let admin_reports = ReportCombinedQuery::default() diff --git a/crates/db_views/search_combined/src/impls.rs b/crates/db_views/search_combined/src/impls.rs index 260a28913..6b80a95cd 100644 --- a/crates/db_views/search_combined/src/impls.rs +++ b/crates/db_views/search_combined/src/impls.rs @@ -323,14 +323,15 @@ impl SearchCombinedQuery { ) } ListingType::ModeratorView => { - query = query.filter(community_actions::became_moderator.is_not_null()); + query = query.filter(community_actions::became_moderator_at.is_not_null()); } } // Filter by the time range if let Some(time_range_seconds) = self.time_range_seconds { - query = query - .filter(search_combined::published.gt(now() - seconds_to_pg_interval(time_range_seconds))); + query = query.filter( + search_combined::published_at.gt(now() - seconds_to_pg_interval(time_range_seconds)), + ); } // NSFW @@ -370,7 +371,7 @@ impl SearchCombinedQuery { ); paginated_query = match sort { - New | Old => paginated_query.then_order_by(key::published), + New | Old => paginated_query.then_order_by(key::published_at), Top => paginated_query.then_order_by(key::score), } // finally use unique id as tie breaker diff --git a/crates/db_views/site/src/api.rs b/crates/db_views/site/src/api.rs index ef2e6b02e..eed9378ed 100644 --- a/crates/db_views/site/src/api.rs +++ b/crates/db_views/site/src/api.rs @@ -46,7 +46,7 @@ pub struct AdminBlockInstanceParams { #[cfg_attr(feature = "full", ts(optional))] pub reason: Option, #[cfg_attr(feature = "full", ts(optional))] - pub expires: Option>, + pub expires_at: Option>, } #[skip_serializing_none] @@ -132,8 +132,6 @@ pub struct CreateSite { #[cfg_attr(feature = "full", ts(optional))] pub application_email_admins: Option, #[cfg_attr(feature = "full", ts(optional))] - pub hide_modlog_mod_names: Option, - #[cfg_attr(feature = "full", ts(optional))] pub discussion_languages: Option>, #[cfg_attr(feature = "full", ts(optional))] pub slur_filter_regex: Option, @@ -286,9 +284,6 @@ pub struct EditSite { /// Whether to email admins when receiving a new application. #[cfg_attr(feature = "full", ts(optional))] pub application_email_admins: Option, - /// Whether to hide moderator names from the modlog. - #[cfg_attr(feature = "full", ts(optional))] - pub hide_modlog_mod_names: Option, /// A list of allowed discussion languages. #[cfg_attr(feature = "full", ts(optional))] pub discussion_languages: Option>, diff --git a/crates/db_views/vote/src/impls.rs b/crates/db_views/vote/src/impls.rs index f0f433d71..70645e963 100644 --- a/crates/db_views/vote/src/impls.rs +++ b/crates/db_views/vote/src/impls.rs @@ -81,7 +81,7 @@ impl VoteView { .select(( person::all_columns, creator_community_actions - .field(community_actions::received_ban) + .field(community_actions::received_ban_at) .nullable() .is_not_null(), post_actions::like_score.assume_not_null(), @@ -93,7 +93,7 @@ impl VoteView { let paginated_query = paginate(query, SortDirection::Asc, cursor_data, None, page_back) .then_order_by(key::like_score) // Tie breaker - .then_order_by(key::liked); + .then_order_by(key::liked_at); paginated_query .load::(conn) @@ -155,7 +155,7 @@ impl VoteView { .select(( person::all_columns, creator_community_actions - .field(community_actions::received_ban) + .field(community_actions::received_ban_at) .nullable() .is_not_null(), comment_actions::like_score.assume_not_null(), @@ -167,7 +167,7 @@ impl VoteView { let paginated_query = paginate(query, SortDirection::Asc, cursor_data, None, page_back) .then_order_by(key::like_score) // Tie breaker - .then_order_by(key::liked); + .then_order_by(key::liked_at); paginated_query .load::(conn) diff --git a/crates/email/src/notifications.rs b/crates/email/src/notifications.rs index 040d57c6e..1b3424414 100644 --- a/crates/email/src/notifications.rs +++ b/crates/email/src/notifications.rs @@ -112,7 +112,7 @@ async fn send_email_to_user( let banned = local_user_view .instance_actions .as_ref() - .and_then(|i| i.received_ban) + .and_then(|i| i.received_ban_at) .is_some(); if banned || !local_user_view.local_user.send_notifications_to_email { return; diff --git a/crates/federate/src/inboxes.rs b/crates/federate/src/inboxes.rs index 205bab941..9e00f161a 100644 --- a/crates/federate/src/inboxes.rs +++ b/crates/federate/src/inboxes.rs @@ -254,7 +254,7 @@ mod tests { ap_id: Url::parse("https://example.com/activities/1")?.into(), data: json!({}), sensitive: false, - published: Utc::now(), + published_at: Utc::now(), send_inboxes: vec![], send_community_followers_of: None, send_all_instances: false, @@ -276,8 +276,8 @@ mod tests { id: SiteId(1), name: "Test Site".to_string(), sidebar: None, - published: Utc::now(), - updated: None, + published_at: Utc::now(), + updated_at: None, icon: None, banner: None, description: None, @@ -300,7 +300,7 @@ mod tests { ap_id: Url::parse("https://example.com/activities/1")?.into(), data: json!({}), sensitive: false, - published: Utc::now(), + published_at: Utc::now(), send_inboxes: vec![], send_community_followers_of: None, send_all_instances: true, @@ -339,7 +339,7 @@ mod tests { ap_id: Url::parse("https://example.com/activities/1")?.into(), data: json!({}), sensitive: false, - published: Utc::now(), + published_at: Utc::now(), send_inboxes: vec![], send_community_followers_of: Some(community_id), send_all_instances: false, @@ -367,7 +367,7 @@ mod tests { ap_id: Url::parse("https://example.com/activities/1")?.into(), data: json!({}), sensitive: false, - published: Utc::now(), + published_at: Utc::now(), send_inboxes: vec![ Some(inbox_user_1.clone().into()), Some(inbox_user_2.clone().into()), @@ -399,8 +399,8 @@ mod tests { id: SiteId(1), name: "Test Site".to_string(), sidebar: None, - published: Utc::now(), - updated: None, + published_at: Utc::now(), + updated_at: None, icon: None, banner: None, description: None, @@ -432,7 +432,7 @@ mod tests { ap_id: Url::parse("https://example.com/activities/1")?.into(), data: json!({}), sensitive: false, - published: Utc::now(), + published_at: Utc::now(), send_inboxes: vec![ Some(user1_inbox.clone().into()), Some(user2_inbox.clone().into()), @@ -516,8 +516,8 @@ mod tests { id: SiteId(1), name: "Test Site".to_string(), sidebar: None, - published: Utc::now(), - updated: None, + published_at: Utc::now(), + updated_at: None, icon: None, banner: None, description: None, @@ -547,7 +547,7 @@ mod tests { ap_id: Url::parse("https://example.com/activities/1")?.into(), data: json!({}), sensitive: false, - published: Utc::now(), + published_at: Utc::now(), send_inboxes: vec![Some(site_inbox.into())], send_community_followers_of: Some(community_id), send_all_instances: true, diff --git a/crates/federate/src/lib.rs b/crates/federate/src/lib.rs index 86d021ef6..ec57ff236 100644 --- a/crates/federate/src/lib.rs +++ b/crates/federate/src/lib.rs @@ -324,8 +324,8 @@ mod test { let person = Person::create(&mut data.context.pool(), &form).await?; let form = FederationBlockListForm { instance_id, - updated: None, - expires: None, + updated_at: None, + expires_at: None, }; FederationBlockList::block(&mut data.context.pool(), &form).await?; data.run().await?; @@ -350,7 +350,7 @@ mod test { let person = Person::create(&mut data.context.pool(), &form).await?; let form = FederationAllowListForm { instance_id: data.instances[0].id, - updated: None, + updated_at: None, }; FederationAllowList::allow(&mut data.context.pool(), &form).await?; data.run().await?; @@ -371,7 +371,7 @@ mod test { let instance = &data.instances[0]; let form = InstanceForm { - updated: DateTime::from_timestamp(0, 0), + updated_at: DateTime::from_timestamp(0, 0), ..InstanceForm::new(instance.domain.clone()) }; Instance::update(&mut data.context.pool(), instance.id, form).await?; diff --git a/crates/federate/src/send.rs b/crates/federate/src/send.rs index 3a4bbcc78..73815d6fc 100644 --- a/crates/federate/src/send.rs +++ b/crates/federate/src/send.rs @@ -24,7 +24,7 @@ use tokio_util::sync::CancellationToken; #[derive(Debug, Eq)] pub(crate) struct SendSuccessInfo { pub activity_id: ActivityId, - pub published: Option>, + pub published_at: Option>, // true if the activity was skipped because the target instance is not interested in this // activity pub was_skipped: bool, @@ -150,7 +150,7 @@ impl SendRetryTask<'_> { } report.send(SendActivityResult::Success(SendSuccessInfo { activity_id: activity.id, - published: Some(activity.published), + published_at: Some(activity.published_at), was_skipped: false, }))?; Ok(()) diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index f2ba32d76..f95e9788b 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -201,7 +201,7 @@ impl InstanceWorker { if self.state.fail_count > 0 { let last_retry = self .state - .last_retry + .last_retry_at .context("impossible: if fail count set last retry also set")?; let elapsed = (Utc::now() - last_retry).to_std()?; let required = federate_retry_sleep_duration(self.state.fail_count); @@ -280,7 +280,7 @@ impl InstanceWorker { // only count as one failure. self.state.fail_count = fail_count; - self.state.last_retry = Some(Utc::now()); + self.state.last_retry_at = Some(Utc::now()); force_write = true; } } @@ -291,12 +291,15 @@ impl InstanceWorker { } async fn mark_instance_alive(&mut self) -> Result<()> { // Activity send successful, mark instance as alive if it hasn't been updated in a while. - let updated = self.instance.updated.unwrap_or(self.instance.published); + let updated = self + .instance + .updated_at + .unwrap_or(self.instance.published_at); if updated.add(Days::new(1)) < Utc::now() { - self.instance.updated = Some(Utc::now()); + self.instance.updated_at = Some(Utc::now()); let form = InstanceForm { - updated: Some(Utc::now()), + updated_at: Some(Utc::now()), ..InstanceForm::new(self.instance.domain.clone()) }; Instance::update(&mut self.pool(), self.instance.id, form) @@ -335,7 +338,7 @@ impl InstanceWorker { .context("peek above ensures pop has value")?; last_id = next.activity_id; self.state.last_successful_id = Some(next.activity_id); - self.state.last_successful_published_time = next.published; + self.state.last_successful_published_time_at = next.published_at; } let save_state_every = chrono::Duration::from_std(SAVE_STATE_EVERY_TIME)?; @@ -358,7 +361,7 @@ impl InstanceWorker { .report_send_result .send(SendActivityResult::Success(SendSuccessInfo { activity_id, - published: None, + published_at: None, was_skipped: true, }))?; return Ok(()); @@ -379,7 +382,7 @@ impl InstanceWorker { // large to a small instance that's only subscribed to a few small communities, // then it will show the last published time as a days ago even though // federation is up to date. - published: Some(activity.published), + published_at: Some(activity.published_at), was_skipped: true, }))?; return Ok(()); @@ -416,7 +419,7 @@ impl InstanceWorker { report .send(SendActivityResult::Success(SendSuccessInfo { activity_id, - published: None, + published_at: None, was_skipped: true, })) .ok(); @@ -676,7 +679,7 @@ mod test { let instance = Instance::read_or_create(&mut data.context.pool(), data.instance.domain.clone()).await?; - assert!(instance.updated.is_some()); + assert!(instance.updated_at.is_some()); Ok(()) } diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index dcd647a55..801f52078 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -396,7 +396,7 @@ fn create_reply_and_mention_items( let reply_url = v.comment.local_url(context.settings())?; build_item( &v.creator, - &v.comment.published, + &v.comment.published_at, reply_url.as_str(), &v.comment.content, context.settings(), @@ -406,7 +406,7 @@ fn create_reply_and_mention_items( let mention_url = v.comment.local_url(context.settings())?; build_item( &v.creator, - &v.comment.published, + &v.comment.published_at, mention_url.as_str(), &v.comment.content, context.settings(), @@ -416,7 +416,7 @@ fn create_reply_and_mention_items( let mention_url = v.post.local_url(context.settings())?; build_item( &v.creator, - &v.post.published, + &v.post.published_at, mention_url.as_str(), &v.post.body.clone().unwrap_or_default(), context.settings(), @@ -426,7 +426,7 @@ fn create_reply_and_mention_items( let inbox_url = format!("{}/inbox", context.settings().get_protocol_and_hostname()); build_item( &v.creator, - &v.private_message.published, + &v.private_message.published_at, &inbox_url, &v.private_message.content, context.settings(), @@ -453,7 +453,7 @@ fn create_modlog_items( .map(|r| match r { ModlogCombinedView::AdminAllowInstance(v) => build_modlog_item( &v.admin, - &v.admin_allow_instance.published, + &v.admin_allow_instance.published_at, &modlog_url, &format!( "Admin {} instance - {}", @@ -469,7 +469,7 @@ fn create_modlog_items( ), ModlogCombinedView::AdminBlockInstance(v) => build_modlog_item( &v.admin, - &v.admin_block_instance.published, + &v.admin_block_instance.published_at, &modlog_url, &format!( "Admin {} instance - {}", @@ -485,7 +485,7 @@ fn create_modlog_items( ), ModlogCombinedView::AdminPurgeComment(v) => build_modlog_item( &v.admin, - &v.admin_purge_comment.published, + &v.admin_purge_comment.published_at, &modlog_url, "Admin purged comment", &v.admin_purge_comment.reason, @@ -493,7 +493,7 @@ fn create_modlog_items( ), ModlogCombinedView::AdminPurgeCommunity(v) => build_modlog_item( &v.admin, - &v.admin_purge_community.published, + &v.admin_purge_community.published_at, &modlog_url, "Admin purged community", &v.admin_purge_community.reason, @@ -501,7 +501,7 @@ fn create_modlog_items( ), ModlogCombinedView::AdminPurgePerson(v) => build_modlog_item( &v.admin, - &v.admin_purge_person.published, + &v.admin_purge_person.published_at, &modlog_url, "Admin purged person", &v.admin_purge_person.reason, @@ -509,7 +509,7 @@ fn create_modlog_items( ), ModlogCombinedView::AdminPurgePost(v) => build_modlog_item( &v.admin, - &v.admin_purge_post.published, + &v.admin_purge_post.published_at, &modlog_url, "Admin purged post", &v.admin_purge_post.reason, @@ -517,7 +517,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModAdd(v) => build_modlog_item( &v.moderator, - &v.mod_add.published, + &v.mod_add.published_at, &modlog_url, &format!( "{} admin {}", @@ -529,7 +529,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModAddCommunity(v) => build_modlog_item( &v.moderator, - &v.mod_add_community.published, + &v.mod_add_community.published_at, &modlog_url, &format!( "{} mod {} to /c/{}", @@ -542,7 +542,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModBan(v) => build_modlog_item( &v.moderator, - &v.mod_ban.published, + &v.mod_ban.published_at, &modlog_url, &format!( "{} {}", @@ -554,7 +554,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModBanFromCommunity(v) => build_modlog_item( &v.moderator, - &v.mod_ban_from_community.published, + &v.mod_ban_from_community.published_at, &modlog_url, &format!( "{} {} from /c/{}", @@ -567,7 +567,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModFeaturePost(v) => build_modlog_item( &v.moderator, - &v.mod_feature_post.published, + &v.mod_feature_post.published_at, &modlog_url, &format!( "{} post {}", @@ -583,7 +583,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModChangeCommunityVisibility(v) => build_modlog_item( &v.moderator, - &v.mod_change_community_visibility.published, + &v.mod_change_community_visibility.published_at, &modlog_url, &format!( "Changed /c/{} visibility to {}", @@ -594,7 +594,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModLockPost(v) => build_modlog_item( &v.moderator, - &v.mod_lock_post.published, + &v.mod_lock_post.published_at, &modlog_url, &format!( "{} post {}", @@ -610,7 +610,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModRemoveComment(v) => build_modlog_item( &v.moderator, - &v.mod_remove_comment.published, + &v.mod_remove_comment.published_at, &modlog_url, &format!( "{} comment {}", @@ -622,7 +622,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModRemoveCommunity(v) => build_modlog_item( &v.moderator, - &v.mod_remove_community.published, + &v.mod_remove_community.published_at, &modlog_url, &format!( "{} community /c/{}", @@ -634,7 +634,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModRemovePost(v) => build_modlog_item( &v.moderator, - &v.mod_remove_post.published, + &v.mod_remove_post.published_at, &modlog_url, &format!( "{} post {}", @@ -646,7 +646,7 @@ fn create_modlog_items( ), ModlogCombinedView::ModTransferCommunity(v) => build_modlog_item( &v.moderator, - &v.mod_transfer_community.published, + &v.mod_transfer_community.published_at, &modlog_url, &format!( "Tranferred /c/{} to /u/{}", @@ -823,7 +823,7 @@ fn create_post_items(posts: Vec, settings: &Settings) -> LemmyResult) -> LemmyResult<()> { &mut conn, "comment", "a.hot_rank != 0", - "SET hot_rank = r.hot_rank(a.score, a.published)", + "SET hot_rank = r.hot_rank(a.score, a.published_at)", ) .await?; @@ -152,7 +152,7 @@ async fn update_hot_ranks(pool: &mut DbPool<'_>) -> LemmyResult<()> { &mut conn, "community", "a.hot_rank != 0", - "SET hot_rank = r.hot_rank(a.subscribers, a.published)", + "SET hot_rank = r.hot_rank(a.subscribers, a.published_at)", ) .await?; @@ -163,7 +163,7 @@ async fn update_hot_ranks(pool: &mut DbPool<'_>) -> LemmyResult<()> { #[derive(QueryableByName)] struct HotRanksUpdateResult { #[diesel(sql_type = Timestamptz)] - published: DateTime, + published_at: DateTime, } /// Runs the hot rank update query in batches until all rows have been processed. @@ -187,12 +187,12 @@ async fn process_ranks_in_batches( let updated_rows = sql_query(format!( r#"WITH batch AS (SELECT a.id FROM {table_name} a - WHERE a.published > $1 AND ({where_clause}) - ORDER BY a.published + WHERE a.published_at > $1 AND ({where_clause}) + ORDER BY a.published_at LIMIT $2 FOR UPDATE SKIP LOCKED) UPDATE {table_name} a {set_clause} - FROM batch WHERE a.id = batch.id RETURNING a.published; + FROM batch WHERE a.id = batch.id RETURNING a.published_at; "#, )) .bind::(previous_batch_last_published) @@ -204,7 +204,7 @@ async fn process_ranks_in_batches( })?; processed_rows_count += updated_rows.len(); - previous_batch_result = updated_rows.last().map(|row| row.published); + previous_batch_result = updated_rows.last().map(|row| row.published_at); } info!( "Finished process_hot_ranks_in_batches execution for {} (processed {} rows)", @@ -225,19 +225,19 @@ async fn process_post_aggregates_ranks_in_batches(conn: &mut AsyncPgConnection) let updated_rows = sql_query( r#"WITH batch AS (SELECT pa.id FROM post pa - WHERE pa.published > $1 + WHERE pa.published_at > $1 AND (pa.hot_rank != 0 OR pa.hot_rank_active != 0) - ORDER BY pa.published + ORDER BY pa.published_at LIMIT $2 FOR UPDATE SKIP LOCKED) UPDATE post pa - SET hot_rank = r.hot_rank(pa.score, pa.published), - hot_rank_active = r.hot_rank(pa.score, pa.newest_comment_time_necro), - scaled_rank = r.scaled_rank(pa.score, pa.published, ca.interactions_month) + SET hot_rank = r.hot_rank(pa.score, pa.published_at), + hot_rank_active = r.hot_rank(pa.score, pa.newest_comment_time_necro_at), + scaled_rank = r.scaled_rank(pa.score, pa.published_at, ca.interactions_month) FROM batch, community ca WHERE pa.id = batch.id AND pa.community_id = ca.id - RETURNING pa.published; + RETURNING pa.published_at; "#, ) .bind::(previous_batch_last_published) @@ -249,7 +249,7 @@ async fn process_post_aggregates_ranks_in_batches(conn: &mut AsyncPgConnection) })?; processed_rows_count += updated_rows.len(); - previous_batch_result = updated_rows.last().map(|row| row.published); + previous_batch_result = updated_rows.last().map(|row| row.published_at); } info!( "Finished process_hot_ranks_in_batches execution for {} (processed {} rows)", @@ -262,7 +262,7 @@ async fn delete_expired_captcha_answers(pool: &mut DbPool<'_>) -> LemmyResult<() let mut conn = get_conn(pool).await?; diesel::delete( - captcha_answer::table.filter(captcha_answer::published.lt(now() - IntervalDsl::minutes(10))), + captcha_answer::table.filter(captcha_answer::published_at.lt(now() - IntervalDsl::minutes(10))), ) .execute(&mut conn) .await?; @@ -277,13 +277,14 @@ async fn clear_old_activities(pool: &mut DbPool<'_>) -> LemmyResult<()> { let mut conn = get_conn(pool).await?; diesel::delete( - sent_activity::table.filter(sent_activity::published.lt(now() - IntervalDsl::days(7))), + sent_activity::table.filter(sent_activity::published_at.lt(now() - IntervalDsl::days(7))), ) .execute(&mut conn) .await?; diesel::delete( - received_activity::table.filter(received_activity::published.lt(now() - IntervalDsl::days(7))), + received_activity::table + .filter(received_activity::published_at.lt(now() - IntervalDsl::days(7))), ) .execute(&mut conn) .await?; @@ -305,7 +306,7 @@ async fn overwrite_deleted_posts_and_comments(pool: &mut DbPool<'_>) -> LemmyRes diesel::update( post::table .filter(post::deleted.eq(true)) - .filter(post::updated.lt(now().nullable() - 1.months())) + .filter(post::updated_at.lt(now().nullable() - 1.months())) .filter(post::body.ne(DELETED_REPLACEMENT_TEXT)), ) .set(( @@ -319,7 +320,7 @@ async fn overwrite_deleted_posts_and_comments(pool: &mut DbPool<'_>) -> LemmyRes diesel::update( comment::table .filter(comment::deleted.eq(true)) - .filter(comment::updated.lt(now().nullable() - 1.months())) + .filter(comment::updated_at.lt(now().nullable() - 1.months())) .filter(comment::content.ne(DELETED_REPLACEMENT_TEXT)), ) .set(comment::content.eq(DELETED_REPLACEMENT_TEXT)) @@ -367,19 +368,23 @@ async fn update_banned_when_expired(pool: &mut DbPool<'_>) -> LemmyResult<()> { info!("Updating banned column if it expires ..."); let mut conn = get_conn(pool).await?; - uplete::new(community_actions::table.filter(community_actions::ban_expires.lt(now().nullable()))) - .set_null(community_actions::received_ban) - .set_null(community_actions::ban_expires) - .as_query() - .execute(&mut conn) - .await?; + uplete::new( + community_actions::table.filter(community_actions::ban_expires_at.lt(now().nullable())), + ) + .set_null(community_actions::received_ban_at) + .set_null(community_actions::ban_expires_at) + .as_query() + .execute(&mut conn) + .await?; - uplete::new(instance_actions::table.filter(instance_actions::ban_expires.lt(now().nullable()))) - .set_null(instance_actions::received_ban) - .set_null(instance_actions::ban_expires) - .as_query() - .execute(&mut conn) - .await?; + uplete::new( + instance_actions::table.filter(instance_actions::ban_expires_at.lt(now().nullable())), + ) + .set_null(instance_actions::received_ban_at) + .set_null(instance_actions::ban_expires_at) + .as_query() + .execute(&mut conn) + .await?; Ok(()) } @@ -389,7 +394,7 @@ async fn delete_instance_block_when_expired(pool: &mut DbPool<'_>) -> LemmyResul let mut conn = get_conn(pool).await?; diesel::delete( - federation_blocklist::table.filter(federation_blocklist::expires.lt(now().nullable())), + federation_blocklist::table.filter(federation_blocklist::expires_at.lt(now().nullable())), ) .execute(&mut conn) .await?; @@ -404,18 +409,18 @@ async fn publish_scheduled_posts(context: &Data) -> LemmyResult<() let not_community_banned_action = community_actions::table .find((person::id, community::id)) - .filter(community_actions::received_ban.is_not_null()); + .filter(community_actions::received_ban_at.is_not_null()); let not_local_banned_action = instance_actions::table .find((person::id, local_instance_id)) - .filter(instance_actions::received_ban.is_not_null()); + .filter(instance_actions::received_ban_at.is_not_null()); let scheduled_posts: Vec<_> = post::table .inner_join(community::table) .inner_join(person::table) // find all posts which have scheduled_publish_time that is in the past - .filter(post::scheduled_publish_time.is_not_null()) - .filter(coalesce(post::scheduled_publish_time, now()).lt(now())) + .filter(post::scheduled_publish_time_at.is_not_null()) + .filter(coalesce(post::scheduled_publish_time_at, now()).lt(now())) // make sure the post, person and community are still around .filter(not(post::deleted.or(post::removed))) .filter(not(person::deleted)) @@ -431,7 +436,7 @@ async fn publish_scheduled_posts(context: &Data) -> LemmyResult<() for (post, community) in scheduled_posts { // mark post as published in db let form = PostUpdateForm { - scheduled_publish_time: Some(None), + scheduled_publish_time_at: Some(None), ..Default::default() }; Post::update(&mut context.pool(), post.id, &form).await?; @@ -481,7 +486,7 @@ async fn build_update_instance_form( // Activitypub). That's why we always need to mark instances as updated if they are // alive. let mut instance_form = InstanceForm { - updated: Some(Utc::now()), + updated_at: Some(Utc::now()), ..InstanceForm::new(domain.to_string()) }; diff --git a/migrations/2025-06-08-084651_rename_timestamp_add_at/down.sql b/migrations/2025-06-08-084651_rename_timestamp_add_at/down.sql new file mode 100644 index 000000000..d185869be --- /dev/null +++ b/migrations/2025-06-08-084651_rename_timestamp_add_at/down.sql @@ -0,0 +1,214 @@ +ALTER TABLE admin_allow_instance RENAME published_at TO published; + +ALTER TABLE admin_block_instance RENAME COLUMN expires_at TO expires; + +ALTER TABLE admin_block_instance RENAME COLUMN published_at TO published; + +ALTER TABLE admin_purge_comment RENAME COLUMN published_at TO published; + +ALTER TABLE admin_purge_community RENAME COLUMN published_at TO published; + +ALTER TABLE admin_purge_person RENAME COLUMN published_at TO published; + +ALTER TABLE admin_purge_post RENAME COLUMN published_at TO published; + +ALTER TABLE captcha_answer RENAME COLUMN published_at TO published; + +ALTER TABLE comment RENAME COLUMN published_at TO published; + +ALTER TABLE comment RENAME COLUMN updated_at TO updated; + +ALTER TABLE comment_actions RENAME COLUMN liked_at TO liked; + +ALTER TABLE comment_actions RENAME COLUMN saved_at TO saved; + +ALTER TABLE comment_reply RENAME COLUMN published_at TO published; + +ALTER TABLE comment_report RENAME COLUMN published_at TO published; + +ALTER TABLE comment_report RENAME COLUMN updated_at TO updated; + +ALTER TABLE community RENAME COLUMN published_at TO published; + +ALTER TABLE community RENAME COLUMN updated_at TO updated; + +ALTER TABLE community_actions RENAME COLUMN followed_at TO followed; + +ALTER TABLE community_actions RENAME COLUMN blocked_at TO blocked; + +ALTER TABLE community_actions RENAME COLUMN became_moderator_at TO became_moderator; + +ALTER TABLE community_actions RENAME COLUMN received_ban_at TO received_ban; + +ALTER TABLE community_actions RENAME COLUMN ban_expires_at TO ban_expires; + +ALTER TABLE community_report RENAME COLUMN published_at TO published; + +ALTER TABLE community_report RENAME COLUMN updated_at TO updated; + +ALTER TABLE custom_emoji RENAME COLUMN published_at TO published; + +ALTER TABLE custom_emoji RENAME COLUMN updated_at TO updated; + +ALTER TABLE email_verification RENAME COLUMN published_at TO published; + +ALTER TABLE federation_allowlist RENAME COLUMN published_at TO published; + +ALTER TABLE federation_allowlist RENAME COLUMN updated_at TO updated; + +ALTER TABLE federation_blocklist RENAME COLUMN published_at TO published; + +ALTER TABLE federation_blocklist RENAME COLUMN updated_at TO updated; + +ALTER TABLE federation_blocklist RENAME COLUMN expires_at TO expires; + +ALTER TABLE federation_queue_state RENAME COLUMN last_retry_at TO last_retry; + +ALTER TABLE federation_queue_state RENAME COLUMN last_successful_published_time_at TO last_successful_published_time; + +ALTER TABLE inbox_combined RENAME COLUMN published_at TO published; + +ALTER TABLE instance RENAME COLUMN published_at TO published; + +ALTER TABLE instance RENAME COLUMN updated_at TO updated; + +ALTER TABLE instance_actions RENAME COLUMN blocked_at TO blocked; + +ALTER TABLE instance_actions RENAME COLUMN received_ban_at TO received_ban; + +ALTER TABLE instance_actions RENAME COLUMN ban_expires_at TO ban_expires; + +ALTER TABLE local_image RENAME COLUMN published_at TO published; + +ALTER TABLE local_site RENAME COLUMN published_at TO published; + +ALTER TABLE local_site RENAME COLUMN updated_at TO updated; + +ALTER TABLE local_site_rate_limit RENAME COLUMN published_at TO published; + +ALTER TABLE local_site_rate_limit RENAME COLUMN updated_at TO updated; + +ALTER TABLE local_site_url_blocklist RENAME COLUMN published_at TO published; + +ALTER TABLE local_site_url_blocklist RENAME COLUMN updated_at TO updated; + +ALTER TABLE local_user RENAME COLUMN last_donation_notification_at TO last_donation_notification; + +ALTER TABLE login_token RENAME COLUMN published_at TO published; + +ALTER TABLE mod_add RENAME COLUMN published_at TO published; + +ALTER TABLE mod_add_community RENAME COLUMN published_at TO published; + +ALTER TABLE mod_ban RENAME COLUMN published_at TO published; + +ALTER TABLE mod_ban RENAME COLUMN expires_at TO expires; + +ALTER TABLE mod_ban_from_community RENAME COLUMN published_at TO published; + +ALTER TABLE mod_ban_from_community RENAME COLUMN expires_at TO expires; + +ALTER TABLE mod_change_community_visibility RENAME COLUMN published_at TO published; + +ALTER TABLE mod_feature_post RENAME COLUMN published_at TO published; + +ALTER TABLE mod_lock_post RENAME COLUMN published_at TO published; + +ALTER TABLE mod_remove_comment RENAME COLUMN published_at TO published; + +ALTER TABLE mod_remove_community RENAME COLUMN published_at TO published; + +ALTER TABLE mod_remove_post RENAME COLUMN published_at TO published; + +ALTER TABLE mod_transfer_community RENAME COLUMN published_at TO published; + +ALTER TABLE modlog_combined RENAME COLUMN published_at TO published; + +ALTER TABLE oauth_account RENAME COLUMN published_at TO published; + +ALTER TABLE oauth_account RENAME COLUMN updated_at TO updated; + +ALTER TABLE oauth_provider RENAME COLUMN published_at TO published; + +ALTER TABLE oauth_provider RENAME COLUMN updated_at TO updated; + +ALTER TABLE password_reset_request RENAME COLUMN published_at TO published; + +ALTER TABLE person RENAME COLUMN published_at TO published; + +ALTER TABLE person RENAME COLUMN updated_at TO updated; + +ALTER TABLE person_actions RENAME COLUMN followed_at TO followed; + +ALTER TABLE person_actions RENAME COLUMN blocked_at TO blocked; + +ALTER TABLE person_ban RENAME COLUMN published_at TO published; + +ALTER TABLE person_comment_mention RENAME COLUMN published_at TO published; + +ALTER TABLE person_content_combined RENAME COLUMN published_at TO published; + +ALTER TABLE person_liked_combined RENAME COLUMN liked_at TO liked; + +ALTER TABLE person_post_mention RENAME COLUMN published_at TO published; + +ALTER TABLE person_saved_combined RENAME COLUMN saved_at TO saved; + +ALTER TABLE post RENAME COLUMN published_at TO published; + +ALTER TABLE post RENAME COLUMN updated_at TO updated; + +ALTER TABLE post RENAME COLUMN scheduled_publish_time_at TO scheduled_publish_time; + +ALTER TABLE post RENAME COLUMN newest_comment_time_at TO newest_comment_time; + +ALTER TABLE post RENAME COLUMN newest_comment_time_necro_at TO newest_comment_time_necro; + +ALTER TABLE post_actions RENAME COLUMN read_at TO read; + +ALTER TABLE post_actions RENAME COLUMN read_comments_at TO read_comments; + +ALTER TABLE post_actions RENAME COLUMN saved_at TO saved; + +ALTER TABLE post_actions RENAME COLUMN liked_at TO liked; + +ALTER TABLE post_actions RENAME COLUMN hidden_at TO hidden; + +ALTER TABLE post_report RENAME COLUMN published_at TO published; + +ALTER TABLE post_report RENAME COLUMN updated_at TO updated; + +ALTER TABLE post_tag RENAME COLUMN published_at TO published; + +ALTER TABLE private_message RENAME COLUMN published_at TO published; + +ALTER TABLE private_message RENAME COLUMN updated_at TO updated; + +ALTER TABLE private_message_report RENAME COLUMN published_at TO published; + +ALTER TABLE private_message_report RENAME COLUMN updated_at TO updated; + +ALTER TABLE received_activity RENAME COLUMN published_at TO published; + +ALTER TABLE registration_application RENAME COLUMN published_at TO published; + +ALTER TABLE remote_image RENAME COLUMN published_at TO published; + +ALTER TABLE report_combined RENAME COLUMN published_at TO published; + +ALTER TABLE search_combined RENAME COLUMN published_at TO published; + +ALTER TABLE sent_activity RENAME COLUMN published_at TO published; + +ALTER TABLE site RENAME COLUMN published_at TO published; + +ALTER TABLE site RENAME COLUMN updated_at TO updated; + +ALTER TABLE tag RENAME COLUMN published_at TO published; + +ALTER TABLE tag RENAME COLUMN updated_at TO updated; + +ALTER TABLE tagline RENAME COLUMN published_at TO published; + +ALTER TABLE tagline RENAME COLUMN updated_at TO updated; + diff --git a/migrations/2025-06-08-084651_rename_timestamp_add_at/up.sql b/migrations/2025-06-08-084651_rename_timestamp_add_at/up.sql new file mode 100644 index 000000000..2361967fc --- /dev/null +++ b/migrations/2025-06-08-084651_rename_timestamp_add_at/up.sql @@ -0,0 +1,214 @@ +ALTER TABLE admin_allow_instance RENAME COLUMN published TO published_at; + +ALTER TABLE admin_block_instance RENAME COLUMN expires TO expires_at; + +ALTER TABLE admin_block_instance RENAME COLUMN published TO published_at; + +ALTER TABLE admin_purge_comment RENAME COLUMN published TO published_at; + +ALTER TABLE admin_purge_community RENAME COLUMN published TO published_at; + +ALTER TABLE admin_purge_person RENAME COLUMN published TO published_at; + +ALTER TABLE admin_purge_post RENAME COLUMN published TO published_at; + +ALTER TABLE captcha_answer RENAME COLUMN published TO published_at; + +ALTER TABLE comment RENAME COLUMN published TO published_at; + +ALTER TABLE comment RENAME COLUMN updated TO updated_at; + +ALTER TABLE comment_actions RENAME COLUMN liked TO liked_at; + +ALTER TABLE comment_actions RENAME COLUMN saved TO saved_at; + +ALTER TABLE comment_reply RENAME COLUMN published TO published_at; + +ALTER TABLE comment_report RENAME COLUMN published TO published_at; + +ALTER TABLE comment_report RENAME COLUMN updated TO updated_at; + +ALTER TABLE community RENAME COLUMN published TO published_at; + +ALTER TABLE community RENAME COLUMN updated TO updated_at; + +ALTER TABLE community_actions RENAME COLUMN followed TO followed_at; + +ALTER TABLE community_actions RENAME COLUMN blocked TO blocked_at; + +ALTER TABLE community_actions RENAME COLUMN became_moderator TO became_moderator_at; + +ALTER TABLE community_actions RENAME COLUMN received_ban TO received_ban_at; + +ALTER TABLE community_actions RENAME COLUMN ban_expires TO ban_expires_at; + +ALTER TABLE community_report RENAME COLUMN published TO published_at; + +ALTER TABLE community_report RENAME COLUMN updated TO updated_at; + +ALTER TABLE custom_emoji RENAME COLUMN published TO published_at; + +ALTER TABLE custom_emoji RENAME COLUMN updated TO updated_at; + +ALTER TABLE email_verification RENAME COLUMN published TO published_at; + +ALTER TABLE federation_allowlist RENAME COLUMN published TO published_at; + +ALTER TABLE federation_allowlist RENAME COLUMN updated TO updated_at; + +ALTER TABLE federation_blocklist RENAME COLUMN published TO published_at; + +ALTER TABLE federation_blocklist RENAME COLUMN updated TO updated_at; + +ALTER TABLE federation_blocklist RENAME COLUMN expires TO expires_at; + +ALTER TABLE federation_queue_state RENAME COLUMN last_retry TO last_retry_at; + +ALTER TABLE federation_queue_state RENAME COLUMN last_successful_published_time TO last_successful_published_time_at; + +ALTER TABLE inbox_combined RENAME COLUMN published TO published_at; + +ALTER TABLE instance RENAME COLUMN published TO published_at; + +ALTER TABLE instance RENAME COLUMN updated TO updated_at; + +ALTER TABLE instance_actions RENAME COLUMN blocked TO blocked_at; + +ALTER TABLE instance_actions RENAME COLUMN received_ban TO received_ban_at; + +ALTER TABLE instance_actions RENAME COLUMN ban_expires TO ban_expires_at; + +ALTER TABLE local_image RENAME COLUMN published TO published_at; + +ALTER TABLE local_site RENAME COLUMN published TO published_at; + +ALTER TABLE local_site RENAME COLUMN updated TO updated_at; + +ALTER TABLE local_site_rate_limit RENAME COLUMN published TO published_at; + +ALTER TABLE local_site_rate_limit RENAME COLUMN updated TO updated_at; + +ALTER TABLE local_site_url_blocklist RENAME COLUMN published TO published_at; + +ALTER TABLE local_site_url_blocklist RENAME COLUMN updated TO updated_at; + +ALTER TABLE local_user RENAME COLUMN last_donation_notification TO last_donation_notification_at; + +ALTER TABLE login_token RENAME COLUMN published TO published_at; + +ALTER TABLE mod_add RENAME COLUMN published TO published_at; + +ALTER TABLE mod_add_community RENAME COLUMN published TO published_at; + +ALTER TABLE mod_ban RENAME COLUMN published TO published_at; + +ALTER TABLE mod_ban RENAME COLUMN expires TO expires_at; + +ALTER TABLE mod_ban_from_community RENAME COLUMN published TO published_at; + +ALTER TABLE mod_ban_from_community RENAME COLUMN expires TO expires_at; + +ALTER TABLE mod_change_community_visibility RENAME COLUMN published TO published_at; + +ALTER TABLE mod_feature_post RENAME COLUMN published TO published_at; + +ALTER TABLE mod_lock_post RENAME COLUMN published TO published_at; + +ALTER TABLE mod_remove_comment RENAME COLUMN published TO published_at; + +ALTER TABLE mod_remove_community RENAME COLUMN published TO published_at; + +ALTER TABLE mod_remove_post RENAME COLUMN published TO published_at; + +ALTER TABLE mod_transfer_community RENAME COLUMN published TO published_at; + +ALTER TABLE modlog_combined RENAME COLUMN published TO published_at; + +ALTER TABLE oauth_account RENAME COLUMN published TO published_at; + +ALTER TABLE oauth_account RENAME COLUMN updated TO updated_at; + +ALTER TABLE oauth_provider RENAME COLUMN published TO published_at; + +ALTER TABLE oauth_provider RENAME COLUMN updated TO updated_at; + +ALTER TABLE password_reset_request RENAME COLUMN published TO published_at; + +ALTER TABLE person RENAME COLUMN published TO published_at; + +ALTER TABLE person RENAME COLUMN updated TO updated_at; + +ALTER TABLE person_actions RENAME COLUMN followed TO followed_at; + +ALTER TABLE person_actions RENAME COLUMN blocked TO blocked_at; + +ALTER TABLE person_ban RENAME COLUMN published TO published_at; + +ALTER TABLE person_comment_mention RENAME COLUMN published TO published_at; + +ALTER TABLE person_content_combined RENAME COLUMN published TO published_at; + +ALTER TABLE person_liked_combined RENAME COLUMN liked TO liked_at; + +ALTER TABLE person_post_mention RENAME COLUMN published TO published_at; + +ALTER TABLE person_saved_combined RENAME COLUMN saved TO saved_at; + +ALTER TABLE post RENAME COLUMN published TO published_at; + +ALTER TABLE post RENAME COLUMN updated TO updated_at; + +ALTER TABLE post RENAME COLUMN scheduled_publish_time TO scheduled_publish_time_at; + +ALTER TABLE post RENAME COLUMN newest_comment_time TO newest_comment_time_at; + +ALTER TABLE post RENAME COLUMN newest_comment_time_necro TO newest_comment_time_necro_at; + +ALTER TABLE post_actions RENAME COLUMN read TO read_at; + +ALTER TABLE post_actions RENAME COLUMN read_comments TO read_comments_at; + +ALTER TABLE post_actions RENAME COLUMN saved TO saved_at; + +ALTER TABLE post_actions RENAME COLUMN liked TO liked_at; + +ALTER TABLE post_actions RENAME COLUMN hidden TO hidden_at; + +ALTER TABLE post_report RENAME COLUMN published TO published_at; + +ALTER TABLE post_report RENAME COLUMN updated TO updated_at; + +ALTER TABLE post_tag RENAME COLUMN published TO published_at; + +ALTER TABLE private_message RENAME COLUMN published TO published_at; + +ALTER TABLE private_message RENAME COLUMN updated TO updated_at; + +ALTER TABLE private_message_report RENAME COLUMN published TO published_at; + +ALTER TABLE private_message_report RENAME COLUMN updated TO updated_at; + +ALTER TABLE received_activity RENAME COLUMN published TO published_at; + +ALTER TABLE registration_application RENAME COLUMN published TO published_at; + +ALTER TABLE remote_image RENAME COLUMN published TO published_at; + +ALTER TABLE report_combined RENAME COLUMN published TO published_at; + +ALTER TABLE search_combined RENAME COLUMN published TO published_at; + +ALTER TABLE sent_activity RENAME COLUMN published TO published_at; + +ALTER TABLE site RENAME COLUMN published TO published_at; + +ALTER TABLE site RENAME COLUMN updated TO updated_at; + +ALTER TABLE tag RENAME COLUMN published TO published_at; + +ALTER TABLE tag RENAME COLUMN updated TO updated_at; + +ALTER TABLE tagline RENAME COLUMN published TO published_at; + +ALTER TABLE tagline RENAME COLUMN updated TO updated_at; +