From ebb211e7ad385b02049c4f181501cbd8abcd53a9 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Wed, 5 Feb 2025 13:53:40 +0000 Subject: [PATCH] Improve email notification text (by @timothyhay256) (#5383) * Improve email notification text * fix translations * Add markdown-it-footnotes (#5303) * Remove unused param Create/EditSite.enable_nsfw * Remove unnecessary Cargo.toml entry (#5279) * Running cargo-wizard to speed up compilation times. * Fix 1. * Fix 2 * Removing panic abort, and config.toml file. * Add custom migration runner, forbid some `diesel migration` commands, fix old migrations (#4673) * Update schema.rs * rename * stuff * finish new implementation of schema_setup::run (not including revert, test, etc.) * fmt * refactor * fix sql * migriation run command * use trigger on migrations table * add Options with disable_migrations field for test * rename to enable_forbid_diesel_cli_trigger * fix * fix merge * diff_checker (partial) * Revert "diff_checker (partial)" This reverts commit 6709882e148ceff48d6f097895af18d13fbdf4bf. * Revert "Revert "diff_checker (partial)"" This reverts commit d4bdda5d11216f4acd13b9585d2392ca8c252a73. * diff check * improve schema diff * timestamp replacement * ignore column order * remove fedi_name default * stuff * improve diff * stuff * attempt parallel pg_dump * attempt 2 * Revert "attempt 2" This reverts commit a909d2d6438d0b53382f762cf916ee92286a9965. * Revert "attempt parallel pg_dump" This reverts commit 592a12795428000ab15b572f89cbd9c6e25fb76c. * improve diff check * finish fixing migrations * stuff * use advisory lock * stuff * Update lib.rs * fmt * fmt * clippy * Update diff_check.rs * Update .woodpecker.yml * Update lib.rs * Update lib.rs * Update lib.rs * Update .woodpecker.yml * Update .woodpecker.yml * Update lib.rs * re-run ci * fmt * fmt * Update .woodpecker.yml * Update .woodpecker.yml * create separate database in ci * Update .woodpecker.yml * Update .woodpecker.yml * Update .woodpecker.yml * Update .woodpecker.yml * try to fix env var * Update diff_check.rs * Remove condition that's not needed anymore * clippy * exclude views and fast tables * revert some migration changes * fix * fmt * re-attempt checking character after skipped trigger name, and make code less confusing * fmt * fix * rerun ci * rerun ci * fix strip_prefix order * fix weird big Cargo.lock change by running `git checkout upstream/main Cargo.lock` then letting it auto update again * fix * remove installation commands that were removed in main branch * Revert "remove installation commands that were removed in main branch" This reverts commit fd65234a760b8b1bb42bc5b59b0ec972b08ded13. * move create_database_user woodpecker step to make diff less weird * fix clippy * Make diff check work just like before * Move new migrations to the end * Revert changes to old migrations * don't assume that migrations are already sorted * retry CI * fix merge * find migrations dir in debug mode using CARGO_MANIFEST_DIR variable instead of current working directory * always use embedded migrations * improve doc comments for migration subcommand * clippy fix * move cfg(test) attribute to diff_check.rs * copy `o` variable instead of calling `o` function * use chrono::TimeDelta Display implementation to show migration duration * Remove unused params on CreateSite/EditSite (#5311) * Automatically marking posts created in an NSFW community as NSFW. (#5310) * Automatically marking posts created in an NSFW community as NSFW. - Context: https://github.com/LemmyNet/lemmy-ui/issues/2885 * Update crates/api_crud/src/post/create.rs Co-authored-by: Nutomic --------- Co-authored-by: Nutomic * Correct HTTP status for NotFound error (fixes #5309) (#5313) * Fix incorrectly using delete instead of uplete in update_banned_when_expired (#5316) * Remove unused apub audience field (fixes #5278) (#5315) * Remove unused apub audience field (fixes #5278) * fix * fix test * remove comments * Change default image_mode to proxy, remove deprecated option (#5176) * Change default image_mode to proxy, remove deprecated option * fix api test * Add community reports (only the database part) (#4996) * database stuff, not including tests * change migration date * fix community_report_view * update stuff related to report_combined * add db_schema/src/impls/community_report.rs * add report counts to community_aggregates * fix community_report columns and update report_combined_view::tests::test_combined * add column for original sidebar; use None instead of clone; add report_combined_view::tests::test_community_reports * use ts(optional) in CommunityReportView * remove CommunityReportView::read * Correctly paginate PostView when read_only is enabled (#5320) * Image api rework (#5260) * Split image endpoints into API v3 and v4 * Move into subfolders * Upload avatar endpoint and other changes * Various other changes fixes #1772 fixes #4001 * clippy * config options * fix ts bindings * fix api tests * Add option to disable image upload (fixes #1118) * split files into upload, download * move sitemap to top level, not in api * simplify code * add upload user banner * community icon/banner * site icon/banner * update js client * wip * add delete endpoints * change comment * optimization Co-authored-by: dullbananas * move fn * 1024px banner * dont use static client * fix api tests * shear * proxy pictrs in request.rs (fixes #5270) * clippy * try to fix api tests * skip api tests * create user * debug * dbg * test * image * run another * fixed? * clippy * fix * fix health check --------- Co-authored-by: dullbananas * Optimize migrations (#5301) * Optimize migrations * update smoosh migration --------- Co-authored-by: Dessalines * Adding Combined modlog (#5253) * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. --------- Co-authored-by: dullbananas * Fixing person_content_combined migration uniques. (#5324) * Upgrading deps. (#5326) * Upgrading deps. * Upgrading a few more. * A few more * Pictrs delete token (#5317) * Split image endpoints into API v3 and v4 * Move into subfolders * Upload avatar endpoint and other changes * Various other changes fixes #1772 fixes #4001 * clippy * config options * fix ts bindings * fix api tests * Add option to disable image upload (fixes #1118) * split files into upload, download * move sitemap to top level, not in api * simplify code * add upload user banner * community icon/banner * site icon/banner * update js client * wip * add delete endpoints * change comment * optimization Co-authored-by: dullbananas * move fn * 1024px banner * dont use static client * fix api tests * shear * proxy pictrs in request.rs (fixes #5270) * clippy * Get rid of pictrs delete token * remove delete token params * try to fix api tests * fmt * skip api tests * clippy * create user * debug * dbg * ignore test * test * image * run another * fixed? * clippy * fix * migration with column order * drop default * fix health check * update client * remove unused * fix * reuse delete_image_from_pictrs * update lib --------- Co-authored-by: dullbananas * Adding combined inbox (#5257) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. --------- Co-authored-by: dullbananas * Add media filter setting (#5325) * Add hide_media filter * Test media is returned when hide_media is false * Add GIN index * SQL fmt * Drop GIN index in migration * Changes to get_random_community_id: add filters for nsfw and private, use algorthm that doesn't scan the entire table (#5267) * get_random_community_id: add filters for nsfw and private, use algorithm that doesn't scan the entire table * only call random_smallint once for filter * change migration date * make random_smallint function work in postgresql 16 * replace "32768 + 32767 + 1" with "65536" and improve comments --------- Co-authored-by: Dessalines * Add support for donation dialog (fixes #4856) (#5318) * Add support for donation dialog (fixes #4856) * more changes * test * remove files * default value for new user last_donation_notification * move disable_donation_dialog to local_site * restore formatting * Clean up LemmyError::status_code (#5330) * Return correct status code for rate limit error (ref #5332) (#5333) * Upgrading html2text. (#5336) * Prevent incorrectly using delete instead of uplete (#5331) * implement check and test it by modifying PostLike::remove * revert change in PostLike::remove * Implement request idempotency (fixes #4735) (#5329) * Implement request idempotency (fixes #4735) * delete old items * clippy * remove todo * Skip api test for community follower count (fixes #5179) (#5339) * Change federation community restricted check to apply only locally (#5343) * Revert "Fetch community mods synchronously (#5169)" This reverts commit 542e59bcaed256c88a9d974e6c6c3dc59f7ebbc9. * change restricted check (fixes #5337) * Send federated reports to all community mods (#5342) * Move middleware code into api_routes for faster compilation (#5341) * Move middleware code into api_routes for faster compilation * fix wasm * cleanup * Hash check and retry for pictrs binary (#5345) * Hash check and retry for pictrs binary * retry limit * Adding a slim comment_view variant, without post or community. (#5335) * Adding a slim comment_view variant, without post or community. - Fixes #2957 * Alternate version. * Only clone if check. * Revert "Alternate version." This reverts commit 64493959aaaf37f02feb7e021a150409b04aa08e. * Remove trait. * Change println! to debug! (#5346) * Adding post_id and type_ filters to combined reports. (#5348) * Adding post_id and type_ filters to combined reports. - Added tests for these also. - Some additional cleanup of the joins in reports_combined. - Fixes #5265 * Adding period. * Allow setting multiple values for cors_origin (fixes #5198) (#5353) * Allow setting multiple values for cors_origin (fixes #5198) * fmt * mention env var * Search combined (#5271) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Starting to work on search combined. * Fix * Removing serialization * Removing serialization * Moving db_views_actor and _moderator into db_views. - This is necessary because the combined views use both, and that separation was arbitrary to begin with. db_schema has no such crate separation. * Adding search combined view, need to write tests yet. * Filters done, working on tests. * Adding tests for person, post, and community. * Finishing up tests. * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. * Formatting sql. * Formatting sql 2. * Fixing search result, running clippy. * Fixing ts_option. * Adding search_combined.score column, and DB triggers. * Fixing API tests. * Adding an index for score. * Update crates/db_schema/src/newtypes.rs Co-authored-by: dullbananas * Avoiding inner joins for up.sql * Adding person_aggregates.published column. --------- Co-authored-by: dullbananas * Add some url validation (#5338) * Add some url validation * use library fn * manually follow redirects * remove log * avoid infinite redirect/infinite recursion * fix * upgrade lib * check url scheme * Only list local banned users (fixes #2961) (#5364) * Remove instrument macros (#5368) * Remove instrument macros * shear * revert test change * clippy, another unused function * Remove unused files (#5366) * Deny unknown config fields (#5370) * Only print migration output when running migrate command (#5363) * Revert "Change println! to debug! (#5346)" This reverts commit 8ee81a396727018034438e568f74b67d4219ba1a. * Using a custom print command. * Fix missing word in create_triggers comment (#5375) * Adding listing_type.ModeratorView for list communities. (#5377) - Fixes #5352 * Use different counts for denominator in scaled rank for posts (#5261) * Change 'Scaled' sort to use total interactions instead of monthly users * Misc SQL fixes * Fix formatting of error message * Run rustfmt * Using different corepack install method to fix corepack bug. (#5379) - https://github.com/nodejs/corepack/issues/612 * Federate "resolve report" action (#5367) * Federete resolve report action (fixes #4744) * working * clippy and fixes * fix test * verify mod action * add workaround for test --------- Co-authored-by: Dessalines * Use mimalloc as memory allocator (#5378) Co-authored-by: Dessalines * Converting joins, filters, and selects to common functions for DB views. (#5359) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Starting to work on search combined. * Fix * Removing serialization * Removing serialization * Moving db_views_actor and _moderator into db_views. - This is necessary because the combined views use both, and that separation was arbitrary to begin with. db_schema has no such crate separation. * Adding search combined view, need to write tests yet. * Filters done, working on tests. * Adding tests for person, post, and community. * Finishing up tests. * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. * Formatting sql. * Formatting sql 2. * Fixing search result, running clippy. * Fixing ts_option. * Adding search_combined.score column, and DB triggers. * Fixing API tests. * Adding an index for score. * Using next_back instead of last. * Converting local_user_view to use diesel auto_type. * Use AllColumns as suggested by weiznich to simplify Type. * Registration application view. * Person view simplifying. * Community view. * Community moderator view. * Community view. * Community follower view. * Community moderator view. * Person view. * Custom emoji view. * Local image view. * Removing strum from db_views. * Update crates/db_schema/src/newtypes.rs Co-authored-by: dullbananas * Adding an action_utils. * Avoiding inner joins for up.sql * Adding person_aggregates.published column. * Remove unused private message view. * Implementing Selectable for DB views, moving joins inside impl. * Adding a few more. * Fixing imports. * fmt. * Post view. * Comment view. * Inbox combined view. * Modlog combined view. * The rest of the combined tables. * Finishing up. * Fixing shear. * Fixing cargo.toml. * Use 1.81 image. * Fix api common. * Fixing merge issues. --------- Co-authored-by: dullbananas * Version 0.20.0-alpha.0 * lint * fix braces --------- Co-authored-by: James Hoffman Co-authored-by: flamingos-cant <45780476+flamingo-cant-draw@users.noreply.github.com> Co-authored-by: Dessalines Co-authored-by: dullbananas Co-authored-by: Dessalines Co-authored-by: andrewmoise --- crates/api_common/src/build_response.rs | 41 ++++++++++++++++++++----- crates/utils/build.rs | 31 ++++++++++++++----- crates/utils/translations | 2 +- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/crates/api_common/src/build_response.rs b/crates/api_common/src/build_response.rs index 3a73b42f1..66a184284 100644 --- a/crates/api_common/src/build_response.rs +++ b/crates/api_common/src/build_response.rs @@ -101,7 +101,6 @@ pub async fn send_local_notifs( local_user_view: Option<&LocalUserView>, ) -> LemmyResult> { let mut recipient_ids = Vec::new(); - let inbox_link = format!("{}/inbox", context.settings().get_protocol_and_hostname()); let (comment_opt, post, community) = match post_or_comment_id { PostOrCommentId::Post(post_id) => { @@ -141,6 +140,16 @@ pub async fn send_local_notifs( } }; + let inbox_link = format!("{}/inbox", context.settings().get_protocol_and_hostname()); + let comment_link = |comment: &Comment| { + format!( + "{}/post/{}/{}", + context.settings().get_protocol_and_hostname(), + post.id, + comment.id + ) + }; + // Send the local mentions for mention in mentions .iter() @@ -156,7 +165,7 @@ pub async fn send_local_notifs( recipient_ids.push(mention_user_view.local_user.id); // Make the correct reply form depending on whether its a post or comment mention - let comment_content_or_post_body = if let Some(comment) = &comment_opt { + let (link, comment_content_or_post_body) = if let Some(comment) = &comment_opt { let person_comment_mention_form = PersonCommentMentionInsertForm { recipient_id: mention_user_view.person.id, comment_id: comment.id, @@ -168,7 +177,7 @@ pub async fn send_local_notifs( PersonCommentMention::create(&mut context.pool(), &person_comment_mention_form) .await .ok(); - comment.content.clone() + (comment_link(comment), comment.content.clone()) } else { let person_post_mention_form = PersonPostMentionInsertForm { recipient_id: mention_user_view.person.id, @@ -180,7 +189,12 @@ pub async fn send_local_notifs( PersonPostMention::create(&mut context.pool(), &person_post_mention_form) .await .ok(); - post.body.clone().unwrap_or_default() + let post_link = format!( + "{}/post/{}", + context.settings().get_protocol_and_hostname(), + post.id, + ); + (post_link, post.body.clone().unwrap_or_default()) }; // Send an email to those local users that have notifications on @@ -190,7 +204,7 @@ pub async fn send_local_notifs( send_email_to_user( &mention_user_view, &lang.notification_mentioned_by_subject(&person.name), - &lang.notification_mentioned_by_body(&content, &inbox_link, &person.name), + &lang.notification_mentioned_by_body(&link, &content, &inbox_link, &person.name), context.settings(), ) .await @@ -243,7 +257,14 @@ pub async fn send_local_notifs( send_email_to_user( &parent_user_view, &lang.notification_comment_reply_subject(&person.name), - &lang.notification_comment_reply_body(&content, &inbox_link, &person.name), + &lang.notification_comment_reply_body( + comment_link(comment), + &content, + &inbox_link, + &parent_comment.content, + &post.name, + &person.name, + ), context.settings(), ) .await @@ -289,7 +310,13 @@ pub async fn send_local_notifs( send_email_to_user( &parent_user_view, &lang.notification_post_reply_subject(&person.name), - &lang.notification_post_reply_body(&content, &inbox_link, &person.name), + &lang.notification_post_reply_body( + comment_link(comment), + &content, + &inbox_link, + &post.name, + &person.name, + ), context.settings(), ) .await diff --git a/crates/utils/build.rs b/crates/utils/build.rs index b336f8c56..f40ac456a 100644 --- a/crates/utils/build.rs +++ b/crates/utils/build.rs @@ -1,11 +1,28 @@ +use std::fs::read_dir; + fn main() -> Result<(), Box> { - rosetta_build::config() - .source("en", "translations/email/en.json") - .source("fi", "translations/email/fi.json") - .source("ko", "translations/email/ko.json") - .source("pt", "translations/email/pt.json") - .fallback("en") - .generate()?; + let mut config = rosetta_build::config(); + + for path in read_dir("translations/email/")? { + let path = path?.path(); + if let Some(name) = path.file_name() { + let lang = name.to_string_lossy().to_string().replace(".json", ""); + // Rosetta doesnt support these language variants. + if lang.contains('_') { + continue; + } + + let path = path.to_string_lossy(); + rosetta_build::config() + .source(&lang, path.clone()) + .fallback(&lang) + .generate()?; + + config = config.source(lang, path); + } + } + + config.fallback("en").generate()?; Ok(()) } diff --git a/crates/utils/translations b/crates/utils/translations index 70a2384b5..e8a175a0a 160000 --- a/crates/utils/translations +++ b/crates/utils/translations @@ -1 +1 @@ -Subproject commit 70a2384b595c17dfe2096419cd1b381f638ced9a +Subproject commit e8a175a0a79f7bc268874e40b051cc2f036eab75