├── .dockerignore ├── api_tests ├── .npmrc ├── pnpm-workspace.yaml ├── .prettierrc.json ├── jest.config.js ├── tsconfig.json └── run-federation-test.sh ├── rust-toolchain.toml ├── crates ├── api │ ├── api │ │ └── src │ │ │ ├── reports │ │ │ ├── report_combined │ │ │ │ └── mod.rs │ │ │ ├── post_report │ │ │ │ └── mod.rs │ │ │ ├── comment_report │ │ │ │ └── mod.rs │ │ │ ├── community_report │ │ │ │ └── mod.rs │ │ │ ├── private_message_report │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ │ ├── community │ │ │ └── pending_follows │ │ │ │ └── mod.rs │ │ │ ├── site │ │ │ ├── purge │ │ │ │ └── mod.rs │ │ │ ├── registration_applications │ │ │ │ └── mod.rs │ │ │ ├── mod.rs │ │ │ └── federated_instances.rs │ │ │ ├── local_user │ │ │ ├── notifications │ │ │ │ ├── mod.rs │ │ │ │ └── mark_all_read.rs │ │ │ └── list_logins.rs │ │ │ ├── comment │ │ │ └── mod.rs │ │ │ └── post │ │ │ └── mod.rs │ ├── api_common │ │ └── src │ │ │ ├── plugin.rs │ │ │ ├── error.rs │ │ │ ├── language.rs │ │ │ ├── modlog.rs │ │ │ ├── media.rs │ │ │ ├── tagline.rs │ │ │ ├── notification.rs │ │ │ ├── oauth.rs │ │ │ ├── private_message.rs │ │ │ ├── search.rs │ │ │ ├── custom_emoji.rs │ │ │ └── comment.rs │ ├── api_crud │ │ └── src │ │ │ ├── user │ │ │ └── mod.rs │ │ │ ├── oauth_provider │ │ │ └── mod.rs │ │ │ ├── private_message │ │ │ └── mod.rs │ │ │ ├── tagline │ │ │ ├── mod.rs │ │ │ └── list.rs │ │ │ ├── custom_emoji │ │ │ ├── mod.rs │ │ │ └── list.rs │ │ │ ├── comment │ │ │ └── mod.rs │ │ │ └── community │ │ │ └── mod.rs │ ├── api_utils │ │ └── src │ │ │ └── lib.rs │ └── routes │ │ └── Cargo.toml ├── apub │ ├── apub │ │ ├── src │ │ │ └── protocol │ │ │ │ ├── mod.rs │ │ │ │ └── collections │ │ │ │ ├── group_followers.rs │ │ │ │ ├── url_collection.rs │ │ │ │ ├── group_featured.rs │ │ │ │ ├── group_outbox.rs │ │ │ │ └── group_moderators.rs │ │ └── assets │ │ │ ├── lemmy │ │ │ ├── objects │ │ │ │ ├── tombstone.json │ │ │ │ └── private_message.json │ │ │ ├── collections │ │ │ │ ├── group_followers.json │ │ │ │ ├── person_outbox.json │ │ │ │ └── group_moderators.json │ │ │ └── activities │ │ │ │ ├── following │ │ │ │ ├── follow.json │ │ │ │ ├── undo_follow.json │ │ │ │ └── accept.json │ │ │ │ ├── voting │ │ │ │ ├── like_note.json │ │ │ │ ├── dislike_page.json │ │ │ │ ├── undo_like_note.json │ │ │ │ └── undo_dislike_page.json │ │ │ │ ├── deletion │ │ │ │ ├── delete_private_message.json │ │ │ │ ├── delete_user.json │ │ │ │ ├── delete_page.json │ │ │ │ ├── remove_note.json │ │ │ │ └── undo_delete_private_message.json │ │ │ │ ├── community │ │ │ │ ├── report_page.json │ │ │ │ ├── lock_page.json │ │ │ │ ├── add_featured_post.json │ │ │ │ ├── remove_featured_post.json │ │ │ │ ├── add_mod.json │ │ │ │ ├── lock_note.json │ │ │ │ └── remove_mod.json │ │ │ │ └── block │ │ │ │ └── block_user.json │ │ │ ├── lotide │ │ │ ├── objects │ │ │ │ ├── tombstone.json │ │ │ │ └── page.json │ │ │ └── activities │ │ │ │ ├── delete_note.json │ │ │ │ └── follow.json │ │ │ ├── mastodon │ │ │ └── activities │ │ │ │ ├── like_page.json │ │ │ │ ├── follow.json │ │ │ │ ├── undo_like_page.json │ │ │ │ ├── undo_follow.json │ │ │ │ └── flag.json │ │ │ ├── gnusocial │ │ │ └── activities │ │ │ │ └── like_note.json │ │ │ ├── mbin │ │ │ └── activities │ │ │ │ ├── flag.json │ │ │ │ └── accept.json │ │ │ ├── pleroma │ │ │ ├── objects │ │ │ │ └── chat_message.json │ │ │ └── activities │ │ │ │ └── follow.json │ │ │ └── peertube │ │ │ └── activities │ │ │ └── announce_video.json │ ├── objects │ │ └── src │ │ │ ├── lib.rs │ │ │ └── utils │ │ │ └── mod.rs │ └── activities │ │ └── src │ │ ├── create_or_update │ │ └── mod.rs │ │ └── protocol │ │ ├── voting │ │ └── undo_vote.rs │ │ └── block │ │ └── mod.rs ├── db_schema │ └── src │ │ ├── utils │ │ └── queries │ │ │ └── mod.rs │ │ └── source │ │ ├── combined │ │ └── mod.rs │ │ ├── secret.rs │ │ └── community_community_follow.rs ├── routes │ └── src │ │ ├── middleware │ │ └── mod.rs │ │ ├── lib.rs │ │ └── images │ │ └── mod.rs ├── utils │ └── src │ │ ├── utils │ │ └── mod.rs │ │ └── cache_header.rs ├── diesel_utils │ ├── src │ │ ├── lib.rs │ │ └── main.rs │ └── build.rs └── db_views │ ├── notification │ └── src │ │ └── api.rs │ ├── local_user │ └── src │ │ └── api.rs │ ├── report_combined_sql │ └── Cargo.toml │ └── notification_sql │ └── Cargo.toml ├── migrations ├── 2022-11-13-181529_create_taglines │ ├── down.sql │ └── up.sql ├── 2024-02-28-144211_hide_posts │ ├── down.sql │ └── up.sql ├── 2024-05-04-140749_separate_triggers │ ├── down.sql │ └── up.sql ├── 2025-08-01-000061_drop-person-ban │ ├── up.sql │ └── down.sql ├── 2019-04-08-015947_create_user_view │ └── down.sql ├── 2023-06-21-153242_add_captcha │ ├── down.sql │ └── up.sql ├── 2023-08-31-205559_add_image_upload │ ├── down.sql │ └── up.sql ├── 2025-03-07-094522_enable_english_for_all │ └── down.sql ├── 2025-08-01-000031_update-replaceable-schema │ ├── up.sql │ └── down.sql ├── 2020-09-07-231141_add_migration_utils │ └── down.sql ├── 2022-09-07-114618_pm-reports │ └── down.sql ├── 2025-08-01-000002_error_if_code_migrations_needed │ └── down.sql ├── 2024-06-17-160323_fix_post_aggregates_featured_local │ ├── down.sql │ └── up.sql ├── 2025-08-01-000065_group-follow │ ├── down.sql │ └── up.sql ├── 2019-10-15-181630_add_themes │ ├── down.sql │ └── up.sql ├── 2019-12-09-060754_add_lang │ ├── down.sql │ └── up.sql ├── 2023-05-10-095739_force_enable_undetermined_language │ ├── down.sql │ └── up.sql ├── 2025-08-01-000018_custom_migration_runner │ ├── down.sql │ └── up.sql ├── 2025-08-01-000023_add_report_combined_table │ └── down.sql ├── 2025-08-01-000049_add_liked_combined │ └── down.sql ├── 2019-02-26-002946_create_user │ └── down.sql ├── 2019-06-01-222649_remove_admin │ ├── up.sql │ └── down.sql ├── 2020-11-26-134531_delete_user │ ├── down.sql │ └── up.sql ├── 2021-01-31-050334_add_forum_sort_index │ ├── down.sql │ └── up.sql ├── 2022-02-01-154240_add_community_title_index │ ├── down.sql │ └── up.sql ├── 2022-08-05-203502_add_person_post_aggregates │ ├── down.sql │ └── up.sql ├── 2022-09-07-113813_drop_ccnew_indexes_function │ ├── down.sql │ └── up.sql ├── 2025-08-01-000017_forbid_diesel_cli │ └── down.sql ├── 2019-10-24-002614_create_password_reset_request │ ├── down.sql │ └── up.sql ├── 2021-08-17-210508_create_mod_transfer_community │ ├── down.sql │ └── up.sql ├── 2021-09-20-112945_jwt-secret │ ├── down.sql │ └── up.sql ├── 2022-02-18-210946_default_theme │ ├── down.sql │ └── up.sql ├── 2023-09-12-194850_add_federation_worker_index │ ├── down.sql │ └── up.sql ├── 2024-02-27-204628_add_post_alt_text │ ├── down.sql │ └── up.sql ├── 2025-08-01-000029_community-post-tags │ └── down.sql ├── 2025-08-01-000033_add_post_keyword_block_table │ ├── down.sql │ └── up.sql ├── 2025-08-01-000052_lock_reason │ ├── down.sql │ └── up.sql ├── 2019-03-30-212058_create_post_view │ └── down.sql ├── 2020-01-29-030825_create_user_mention_materialized_view │ └── down.sql ├── 2020-10-23-115011_activity_ap_id_column │ ├── down.sql │ └── up.sql ├── 2024-02-12-211114_add_vote_display_mode_setting │ └── down.sql ├── 2025-08-01-000013_comment-vote-remote-postid │ ├── up.sql │ └── down.sql ├── 2025-08-01-000020_oauth_pkce │ ├── down.sql │ └── up.sql ├── 2019-04-03-155309_create_comment_view │ └── down.sql ├── 2020-12-17-030456_create_alias_views │ ├── down.sql │ └── up.sql ├── 2022-05-19-153931_legal-information │ ├── down.sql │ └── up.sql ├── 2022-08-22-193848_comment-language-tags │ ├── down.sql │ └── up.sql ├── 2023-10-27-142514_post_url_content_type │ ├── down.sql │ └── up.sql ├── 2024-01-02-094916_site-name-not-unique │ ├── up.sql │ └── down.sql ├── 2025-08-01-000007_schedule-post │ ├── down.sql │ └── up.sql ├── 2025-08-01-000010_remove_auto_expand │ ├── up.sql │ └── down.sql ├── 2025-08-01-000040_block_nsfw │ ├── down.sql │ └── up.sql ├── 2025-10-08-084508-0000_multi-comm-index-lower │ ├── down.sql │ └── up.sql ├── 2021-03-31-103917_add_show_score_setting │ ├── down.sql │ └── up.sql ├── 2022-08-04-214722_add_distinguished_comment │ ├── down.sql │ └── up.sql ├── 2023-02-11-173347_custom_emojis │ └── down.sql ├── 2025-02-11-131045_ban-remove-content-pm │ ├── down.sql │ └── up.sql ├── 2025-08-01-000003_remove_show_scores_column │ ├── up.sql │ └── down.sql ├── 2025-08-01-000034_no-image-token │ └── up.sql ├── 2025-08-01-000043_community-local-removed │ ├── down.sql │ └── up.sql ├── 2019-10-19-052737_create_user_mention │ └── down.sql ├── 2020-11-10-150835_community_follower_pending │ ├── down.sql │ └── up.sql ├── 2021-04-24-174047_add_show_read_post_setting │ ├── down.sql │ └── up.sql ├── 2022-06-12-012121_add_site_hide_modlog_names │ ├── down.sql │ └── up.sql ├── 2023-02-05-102549_drop-site-federation-debug │ ├── up.sql │ └── down.sql ├── 2023-11-02-120140_apub-signed-fetch │ ├── down.sql │ └── up.sql ├── 2025-01-10-135505_donation-dialog │ ├── down.sql │ └── up.sql ├── 2025-08-01-000021_add_blurhash_to_image_details │ ├── down.sql │ └── up.sql ├── 2021-08-04-223559_create_user_community_block │ └── down.sql ├── 2022-01-20-160328_remove_site_creator │ ├── up.sql │ └── down.sql ├── 2022-04-12-114352_default_post_listing_type │ ├── down.sql │ └── up.sql ├── 2022-04-26-105145_only_mod_can_post │ ├── down.sql │ └── up.sql ├── 2022-08-04-150644_add_application_email_admins │ ├── down.sql │ └── up.sql ├── 2022-09-24-161829_remove_table_aliases │ ├── up.sql │ └── down.sql ├── 2023-02-13-172528_add_report_email_admins │ ├── down.sql │ └── up.sql ├── 2023-06-19-055530_add_retry_worker_setting │ ├── up.sql │ └── down.sql ├── 2023-10-13-175712_allow_animated_avatars │ ├── down.sql │ └── up.sql ├── 2023-10-17-181800_drop_remove_community_expires │ ├── up.sql │ └── down.sql ├── 2023-10-24-183747_autocollapse_bot_comments │ ├── down.sql │ └── up.sql ├── 2024-02-15-171358_default_instance_sort_type │ ├── down.sql │ └── up.sql ├── 2024-11-12-090437_move-triggers │ └── up.sql ├── 2025-08-01-000000_enable_private_messages │ ├── down.sql │ └── up.sql ├── 2025-08-01-000053_remove_hide_modlog_names │ └── up.sql ├── 2025-09-15-090401_remove-keyboard-nav │ ├── up.sql │ └── down.sql ├── 2021-02-28-162616_clean_empty_post_urls │ ├── up.sql │ └── down.sql ├── 2021-03-19-014144_add_col_local_user_validator_time │ ├── down.sql │ └── up.sql ├── 2021-04-01-181826_add_community_agg_active_monthly_index │ ├── down.sql │ └── up.sql ├── 2023-02-15-212546_add_post_comment_saved_indexes │ ├── down.sql │ └── up.sql ├── 2023-07-10-075550_add-infinite-scroll-setting │ ├── down.sql │ └── up.sql ├── 2023-08-02-144930_password-reset-token │ ├── down.sql │ └── up.sql ├── 2023-10-24-131607_proxy_links │ ├── down.sql │ └── up.sql ├── 2024-03-06-104706_local_image_user_opt │ ├── up.sql │ └── down.sql ├── 2025-08-01-000024_add_person_content_combined_table │ └── down.sql ├── 2025-08-01-000054_mod-change-community-vis │ ├── up.sql │ └── down.sql ├── 2025-08-01-000056_person_note │ ├── down.sql │ └── up.sql ├── 2025-08-01-000062_username-instance-unique │ ├── down.sql │ └── up.sql ├── 2021-02-25-112959_remove-categories │ └── up.sql ├── 2021-04-02-021422_remove_community_creator │ └── up.sql ├── 2021-04-20-155001_limit-admins-create-community │ ├── down.sql │ └── up.sql ├── 2021-07-19-130929_add_show_new_post_notifs_setting │ ├── down.sql │ └── up.sql ├── 2021-12-09-225529_add_published_to_email_verification │ ├── down.sql │ └── up.sql ├── 2023-06-24-072904_add_open_links_in_new_tab_setting │ ├── down.sql │ └── up.sql ├── 2023-07-05-000058_person-admin │ ├── down.sql │ └── up.sql ├── 2024-03-06-201637_url_blocklist │ ├── down.sql │ └── up.sql ├── 2025-08-01-000047_disable-email-notifications │ ├── down.sql │ └── up.sql ├── 2019-03-05-233828_create_comment │ └── down.sql ├── 2020-02-02-004806_add_case_insensitive_usernames │ └── down.sql ├── 2022-06-13-124806_post_report_name_length │ ├── down.sql │ └── up.sql ├── 2023-10-06-133405_add_keyboard_navigation_setting │ ├── down.sql │ └── up.sql ├── 2024-04-15-105932_community_followers_url_optional │ ├── down.sql │ └── up.sql ├── 2025-08-01-000015_add_mark_fetched_posts_as_read │ ├── down.sql │ └── up.sql ├── 2025-08-01-000028_add_index_on_person_id_read_for_read_only_post_actions │ ├── down.sql │ └── up.sql ├── 2025-08-01-000036_interactions_per_month_schema │ ├── down.sql │ └── up.sql ├── 2022-01-04-034553_add_hidden_column │ ├── down.sql │ └── up.sql ├── 2025-08-06-170325_add_indexes_for_aggregates_activity_new │ ├── down.sql │ └── up.sql ├── 2021-11-23-031528_add_report_published_index │ ├── down.sql │ └── up.sql ├── 2024-01-15-100133_local-only-community │ ├── down.sql │ └── up.sql ├── 2025-07-29-152743_post-aggregates-creator-community-indexes │ ├── down.sql │ └── up.sql ├── 2025-08-01-000035_media_filter │ ├── down.sql │ └── up.sql ├── 2025-09-08-000001_add-video-dimensions │ ├── down.sql │ └── up.sql ├── 2023-09-20-110614_drop-show-new-post-notifs │ ├── down.sql │ └── up.sql ├── 2024-08-03-155932_increase_post_url_max_length │ ├── down.sql │ └── up.sql ├── 2025-07-29-152742_add_indexes_for_aggregates_activity │ ├── down.sql │ └── up.sql ├── 2019-03-03-163336_create_post │ └── down.sql ├── 2022-05-20-135341_embed-url │ ├── down.sql │ └── up.sql ├── 2022-11-21-204256_user-following │ ├── down.sql │ └── up.sql ├── 2025-08-01-000027_add_search_combined_table │ └── down.sql ├── 2025-08-01-000030_optimize_get_random_community │ └── down.sql ├── 2023-06-22-051755_fix_local_communities_marked_non_local │ ├── down.sql │ └── up.sql ├── 2023-06-24-185942_aggegates_published_indexes │ ├── down.sql │ └── up.sql ├── 2023-08-29-183053_add_listing_type_moderator_view │ └── up.sql ├── 2022-09-08-102358_site-and-community-languages │ └── down.sql ├── 2023-06-27-065106_add_ui_settings │ ├── down.sql │ └── up.sql ├── 2023-08-08-163911_add_post_listing_mode_setting │ ├── down.sql │ └── up.sql ├── 2025-05-15-154113_missing_post_indexes │ ├── down.sql │ └── up.sql ├── 2021-03-31-144349_add_site_short_description │ ├── down.sql │ └── up.sql ├── 2023-02-16-194139_add_totp_secret │ ├── down.sql │ └── up.sql ├── 2023-09-18-141700_login-token │ ├── down.sql │ └── up.sql ├── 2019-10-21-011237_add_default_sorts │ ├── down.sql │ └── up.sql ├── 2023-02-07-030958_community-collections │ ├── down.sql │ └── up.sql ├── 2023-02-13-221303_add_instance_software_and_version │ ├── down.sql │ └── up.sql ├── 2025-08-01-000044_post_comment_pending │ ├── down.sql │ └── up.sql ├── 2025-09-01-141127_local-community-collections │ ├── down.sql │ └── up.sql ├── 2023-09-11-110040_rework-2fa-setup │ ├── down.sql │ └── up.sql ├── 2024-01-22-105746_lemmynsfw-changes │ ├── down.sql │ └── up.sql ├── 2025-08-01-000004_custom_emoji_tagline_changes │ └── up.sql ├── 2025-10-09-101527-0000_community-follower-denied │ ├── up.sql │ └── down.sql ├── 2020-11-05-152724_activity_remove_user_id │ ├── up.sql │ └── down.sql ├── 2021-03-04-040229_clean_icon_urls │ ├── down.sql │ └── up.sql ├── 2025-08-01-000011_add_short_community_description │ ├── down.sql │ └── up.sql ├── 2020-04-21-123957_remove_unique_user_constraints │ ├── up.sql │ └── down.sql ├── 2020-10-13-212240_create_report_tables │ └── down.sql ├── 2023-06-06-104440_index_post_url │ ├── down.sql │ └── up.sql ├── 2025-08-01-000022_instance-block-mod-log │ └── down.sql ├── 2025-08-01-000038_ap_id │ ├── down.sql │ └── up.sql ├── 2022-04-12-185205_change_default_listing_type_to_local │ ├── down.sql │ └── up.sql ├── 2025-02-24-173152_search-alt-text-of-posts │ ├── down.sql │ └── up.sql ├── 2025-08-01-000037_report_to_admins │ ├── down.sql │ └── up.sql ├── 2021-10-01-141650_create_admin_purge │ └── down.sql ├── 2021-11-22-143904_add_required_public_key │ ├── down.sql │ └── up.sql ├── 2025-08-01-000068_local_user_trigger │ ├── down.sql │ └── up.sql ├── 2025-11-05-181519-0000_add_registration_application_updated_at │ ├── down.sql │ └── up.sql ├── 2022-11-21-143249_remove-federation-settings │ ├── up.sql │ └── down.sql ├── 2022-04-19-111004_default_require_application │ ├── down.sql │ └── up.sql ├── 2023-06-22-101245_increase_user_theme_column_size │ ├── up.sql │ └── down.sql ├── 2020-04-03-194936_add_activitypub_for_posts_and_comments │ └── down.sql ├── 2022-01-28-104106_instance-actor │ ├── down.sql │ └── up.sql ├── 2024-05-05-162540_add_image_detail_table │ ├── down.sql │ └── up.sql ├── 2025-08-01-000058_instance_block_communities_persons │ ├── down.sql │ └── up.sql ├── 2025-08-01-000059_person_votes │ └── down.sql ├── 2025-08-01-000067_add_default_items_per_page │ ├── down.sql │ └── up.sql ├── 2023-09-28-084231_import_user_settings_rate_limit │ ├── down.sql │ └── up.sql ├── 2023-11-01-223740_federation-published │ ├── down.sql │ └── up.sql ├── 2025-04-07-100344_registration-rate-limit │ ├── down.sql │ └── up.sql ├── 2019-04-03-155205_create_community_view │ └── down.sql ├── 2021-11-22-135324_add_activity_ap_id_index │ ├── down.sql │ └── up.sql ├── 2022-06-21-123144_language-tags │ └── down.sql ├── 2023-07-24-232635_trigram-index │ ├── down.sql │ └── up.sql ├── 2022-04-11-210137_fix_unique_changeme │ ├── up.sql │ └── down.sql ├── 2024-06-24-000000_ap_id_triggers │ ├── up.sql │ └── down.sql ├── 2025-08-01-000026_add_inbox_combined_table │ └── down.sql ├── 2019-02-27-170003_create_community │ └── down.sql ├── 2020-12-17-031053_remove_fast_tables_and_views │ └── down.sql ├── 2023-07-14-215339_aggregates_nonzero_indexes │ ├── down.sql │ └── up.sql ├── 2025-08-01-000019_add_report_count │ └── down.sql ├── 2025-08-01-000008_create_oauth_provider │ └── down.sql ├── 2023-06-17-175955_add_listingtype_sorttype_hour_enums │ └── up.sql ├── 2025-09-19-132648-0000_theme-instance-default │ ├── up.sql │ └── down.sql ├── 2023-06-20-191145_add_listingtype_sorttype_3_6_9_months_enums │ └── up.sql ├── 2025-09-08-140711_remove-actor-name-max-length │ ├── down.sql │ └── up.sql ├── 2020-12-14-020038_create_comment_aggregates │ └── down.sql ├── 2023-07-19-163511_comment_sort_hot_rank_then_score │ ├── down.sql │ └── up.sql ├── 2023-09-01-112158_auto_resolve_report │ └── down.sql ├── 2024-01-25-151400_remove_auto_resolve_report_trigger │ └── up.sql ├── 2019-04-07-003142_create_moderation_logs │ └── down.sql ├── 2023-12-22-040137_make-mixed-sorting-directions-work-with-tuple-comparison │ └── down.sql ├── 2023-08-01-101826_admin_flag_local_user │ ├── up.sql │ └── down.sql ├── 2021-02-02-153240_apub_columns │ └── down.sql ├── 2019-04-11-144915_create_mod_views │ └── down.sql ├── 2021-01-26-173850_default_actor_id │ ├── down.sql │ └── up.sql ├── 00000000000000_diesel_initial_setup │ └── down.sql ├── 2021-03-31-105915_add_bot_account │ ├── down.sql │ └── up.sql ├── 2021-04-01-173552_rename_preferred_username_to_display_name │ ├── up.sql │ └── down.sql ├── 2021-12-14-181537_add_temporary_bans │ ├── down.sql │ └── up.sql ├── 2023-08-01-115243_persistent-activity-queue │ └── down.sql ├── 2023-11-22-194806_low_rank_defaults │ ├── down.sql │ └── up.sql ├── 2025-08-01-000005_drop-enable-nsfw │ ├── down.sql │ └── up.sql ├── 2021-11-23-153753_add_invite_only_columns │ └── down.sql ├── 2025-08-01-000012_no-individual-inboxes │ └── down.sql ├── 2020-12-10-152350_create_post_aggregates │ └── down.sql ├── 2023-07-26-222023_site-aggregates-one │ └── down.sql ├── 2024-07-01-014711_exponential_controversy │ ├── up.sql │ └── down.sql ├── 2024-04-05-153647_alter_vote_display_mode_defaults │ ├── down.sql │ └── up.sql ├── 2023-07-06-151124_hot-rank-future │ ├── down.sql │ └── up.sql ├── 2020-03-26-192410_add_activitypub_tables │ └── down.sql ├── 2025-11-08-123111-0000_add_multi_community_subscribers_community_count │ └── down.sql ├── 2023-02-01-012747_fix_active_index │ ├── down.sql │ └── up.sql ├── 2021-11-23-132840_email_verification │ └── down.sql ├── 2025-08-01-000032_community_report │ └── down.sql ├── 2025-08-01-000050_show_downvotes_for_others_only │ └── down.sql ├── 2020-01-11-012452_add_indexes │ └── down.sql ├── 2020-12-04-183345_create_community_aggregates │ └── down.sql ├── 2021-01-27-202728_active_users_monthly │ └── down.sql ├── 2020-12-03-035643_create_user_aggregates │ └── down.sql ├── 2021-07-20-102033_actor_name_length │ ├── down.sql │ └── up.sql ├── 2023-06-19-120700_no_double_deletion │ └── down.sql ├── 2025-08-01-000066_modlog-rename │ ├── down.sql │ └── up.sql ├── 2025-08-20-000000_comment-lock │ └── down.sql ├── 2019-08-29-040006_add_community_count │ └── down.sql ├── 2025-08-01-000006_default_comment_sort_type │ └── down.sql ├── 2023-11-07-135409_inbox_unique │ └── down.sql └── 2023-10-02-145002_community_followers_count_federated │ └── down.sql ├── .gitattributes ├── .github ├── FUNDING.yml ├── CODEOWNERS ├── SECURITY.md └── ISSUE_TEMPLATE │ └── QUESTION.yml ├── docker ├── docker_db_backup.sh ├── federation │ ├── start-local-instances.bash │ ├── lemmy_beta.hjson │ ├── lemmy_gamma.hjson │ ├── lemmy_alpha.hjson │ ├── lemmy_delta.hjson │ └── lemmy_epsilon.hjson └── test_deploy.sh ├── scripts ├── clear_db.sh ├── update_config_defaults.sh ├── restore_db.sh ├── clean-workspace.sh ├── upgrade_deps.sh ├── postgres_12_to_15_upgrade.sh ├── postgres_15_to_16_upgrade.sh ├── update_translations.sh ├── alpine_install_pg_formatter.sh ├── update_schema_file.sh ├── dump_schema.sh ├── lint.sh ├── query_testing │ ├── views_to_diesel_migration │ │ └── timings-2021-01-05_21-32-54.out │ └── views_old │ │ └── timings-2021-01-05_21-06-37.out ├── db_perf.sh └── sql_format_check.sh ├── .gitmodules ├── .rustfmt.toml ├── config └── config.hjson ├── diesel.toml └── .gitignore /.dockerignore: -------------------------------------------------------------------------------- 1 | .gitignore -------------------------------------------------------------------------------- /api_tests/.npmrc: -------------------------------------------------------------------------------- 1 | package-manager-strict=false 2 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.91" 3 | -------------------------------------------------------------------------------- /crates/api/api/src/reports/report_combined/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod list; 2 | -------------------------------------------------------------------------------- /crates/apub/apub/src/protocol/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod collections; 2 | -------------------------------------------------------------------------------- /api_tests/pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | onlyBuiltDependencies: 2 | - unrs-resolver 3 | -------------------------------------------------------------------------------- /crates/db_schema/src/utils/queries/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod filters; 2 | pub mod selects; 3 | -------------------------------------------------------------------------------- /crates/routes/src/middleware/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod idempotency; 2 | pub mod session; 3 | -------------------------------------------------------------------------------- /migrations/2022-11-13-181529_create_taglines/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE tagline; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-02-28-144211_hide_posts/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE post_hide; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-05-04-140749_separate_triggers/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000061_drop-person-ban/up.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_ban; 2 | 3 | -------------------------------------------------------------------------------- /api_tests/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "avoid", 3 | "semi": true 4 | } 5 | -------------------------------------------------------------------------------- /crates/api/api/src/reports/post_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /migrations/2019-04-08-015947_create_user_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_view; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2023-06-21-153242_add_captcha/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE captcha_answer; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2023-08-31-205559_add_image_upload/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE image_upload; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-03-07-094522_enable_english_for_all/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000031_update-replaceable-schema/up.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /crates/api/api/src/community/pending_follows/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod approve; 2 | pub mod list; 3 | -------------------------------------------------------------------------------- /crates/api/api/src/reports/comment_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /crates/api/api/src/reports/community_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /crates/api/api_common/src/plugin.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_views_site::api::PluginMetadata; 2 | -------------------------------------------------------------------------------- /crates/apub/objects/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod objects; 2 | pub mod protocol; 3 | pub mod utils; 4 | -------------------------------------------------------------------------------- /migrations/2020-09-07-231141_add_migration_utils/down.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA utils CASCADE; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-09-07-114618_pm-reports/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE private_message_report; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000002_error_if_code_migrations_needed/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000031_update-replaceable-schema/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /crates/api/api/src/reports/private_message_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/user/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod my_user; 4 | -------------------------------------------------------------------------------- /migrations/2024-06-17-160323_fix_post_aggregates_featured_local/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000065_group-follow/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE community_community_follow; 2 | 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Normalize EOL for all files that Git considers text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /crates/api/api_common/src/error.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_utils::error::{LemmyErrorType, UntranslatedError}; 2 | -------------------------------------------------------------------------------- /migrations/2019-10-15-181630_add_themes/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | DROP COLUMN theme; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2019-12-09-060754_add_lang/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | DROP COLUMN lang; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-05-10-095739_force_enable_undetermined_language/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000018_custom_migration_runner/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE previously_run_sql; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000023_add_report_combined_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE report_combined; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000049_add_liked_combined/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_liked_combined; 2 | 3 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/oauth_provider/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod update; 4 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/private_message/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod update; 4 | -------------------------------------------------------------------------------- /migrations/2019-02-26-002946_create_user/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE user_ban; 2 | 3 | DROP TABLE user_; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2019-06-01-222649_remove_admin/up.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM user_ 2 | WHERE name LIKE 'admin'; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2020-11-26-134531_delete_user/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | DROP COLUMN deleted; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-01-31-050334_add_forum_sort_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_aggregates_comments; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-02-01-154240_add_community_title_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_community_title; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-08-05-203502_add_person_post_aggregates/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_post_aggregates; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-09-07-113813_drop_ccnew_indexes_function/down.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION drop_ccnew_indexes; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000017_forbid_diesel_cli/down.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION forbid_diesel_cli CASCADE; 2 | 3 | -------------------------------------------------------------------------------- /api_tests/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: "ts-jest", 3 | testEnvironment: "node", 4 | }; 5 | -------------------------------------------------------------------------------- /migrations/2019-10-24-002614_create_password_reset_request/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE password_reset_request; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2021-08-17-210508_create_mod_transfer_community/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE mod_transfer_community; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2021-09-20-112945_jwt-secret/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE secret; 2 | 3 | DROP EXTENSION pgcrypto; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-02-18-210946_default_theme/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN default_theme; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-09-12-194850_add_federation_worker_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_person_local_instance; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-02-27-204628_add_post_alt_text/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN alt_text; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-02-27-204628_add_post_alt_text/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | ADD COLUMN alt_text text; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000029_community-post-tags/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE post_tag; 2 | 3 | DROP TABLE tag; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000033_add_post_keyword_block_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE local_user_keyword_block; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000052_lock_reason/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_lock_post 2 | DROP COLUMN reason; 3 | 4 | -------------------------------------------------------------------------------- /crates/api/api/src/site/purge/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod comment; 2 | pub mod community; 3 | pub mod person; 4 | pub mod post; 5 | -------------------------------------------------------------------------------- /crates/api/api_common/src/language.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{newtypes::LanguageId, source::language::Language}; 2 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/tagline/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod list; 4 | pub mod update; 5 | -------------------------------------------------------------------------------- /crates/utils/src/utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod markdown; 2 | pub mod mention; 3 | pub mod slurs; 4 | pub mod validation; 5 | -------------------------------------------------------------------------------- /migrations/2019-03-30-212058_create_post_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW post_view; 2 | 3 | DROP FUNCTION hot_rank; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2020-01-29-030825_create_user_mention_materialized_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_mention_mview; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2020-10-23-115011_activity_ap_id_column/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE activity 2 | DROP COLUMN ap_id; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2020-10-23-115011_activity_ap_id_column/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE activity 2 | ADD COLUMN ap_id text; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-02-12-211114_add_vote_display_mode_setting/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE local_user_vote_display_mode; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000013_comment-vote-remote-postid/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment_like 2 | DROP post_id; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000020_oauth_pkce/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE oauth_provider 2 | DROP COLUMN use_pkce; 3 | 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: dessalines 4 | liberapay: Lemmy 5 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/custom_emoji/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod list; 4 | pub mod update; 5 | -------------------------------------------------------------------------------- /migrations/2019-04-03-155309_create_comment_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW reply_view; 2 | 3 | DROP VIEW comment_view; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2020-12-17-030456_create_alias_views/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_alias_1, user_alias_2, comment_alias_1; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-05-19-153931_legal-information/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN legal_information; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-05-19-153931_legal-information/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD COLUMN legal_information text; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-08-22-193848_comment-language-tags/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | DROP COLUMN language_id; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-27-142514_post_url_content_type/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN url_content_type; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-01-02-094916_site-name-not-unique/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP CONSTRAINT site_name_key; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000007_schedule-post/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN scheduled_publish_time; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000010_remove_auto_expand/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN auto_expand; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000040_block_nsfw/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN disallow_nsfw_content; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-10-08-084508-0000_multi-comm-index-lower/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_multi_community_lower_actor_id; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2021-03-31-103917_add_show_score_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN show_scores; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-02-01-154240_add_community_title_index/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_community_title ON community (title); 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-08-04-214722_add_distinguished_comment/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | DROP COLUMN distinguished; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-02-11-173347_custom_emojis/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE custom_emoji_keyword; 2 | 3 | DROP TABLE custom_emoji; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-10-27-142514_post_url_content_type/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | ADD COLUMN url_content_type text; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-02-11-131045_ban-remove-content-pm/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE private_message 2 | DROP COLUMN removed; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000003_remove_show_scores_column/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN show_scores; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000034_no-image-token/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_image 2 | DROP COLUMN pictrs_delete_token; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000043_community-local-removed/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN local_removed; 3 | 4 | -------------------------------------------------------------------------------- /crates/api/api/src/local_user/notifications/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod list; 2 | pub mod mark_all_read; 3 | pub mod mark_notification_read; 4 | -------------------------------------------------------------------------------- /migrations/2019-10-19-052737_create_user_mention/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_mention_view; 2 | 3 | DROP TABLE user_mention; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2020-11-10-150835_community_follower_pending/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community_follower 2 | DROP COLUMN pending; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2020-11-26-134531_delete_user/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | ADD COLUMN deleted boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-04-24-174047_add_show_read_post_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN show_read_posts; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-06-12-012121_add_site_hide_modlog_names/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN hide_modlog_mod_names; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-02-05-102549_drop-site-federation-debug/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN federation_debug; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-11-02-120140_apub-signed-fetch/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN federation_signed_fetch; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-01-10-135505_donation-dialog/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN last_donation_notification; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000021_add_blurhash_to_image_details/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE image_details 2 | DROP COLUMN blurhash; 3 | 4 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/comment/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod read; 4 | pub mod remove; 5 | pub mod update; 6 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/community/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod list; 4 | pub mod remove; 5 | pub mod update; 6 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/objects/tombstone.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "https://lemmy.ml/comment/110273", 3 | "type": "Tombstone" 4 | } 5 | -------------------------------------------------------------------------------- /migrations/2019-10-15-181630_add_themes/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | ADD COLUMN theme varchar(20) DEFAULT 'darkly' NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2019-12-09-060754_add_lang/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | ADD COLUMN lang varchar(20) DEFAULT 'browser' NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-08-04-223559_create_user_community_block/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_block; 2 | 3 | DROP TABLE community_block; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-01-20-160328_remove_site_creator/up.sql: -------------------------------------------------------------------------------- 1 | -- Drop the column 2 | ALTER TABLE site 3 | DROP COLUMN creator_id; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-04-12-114352_default_post_listing_type/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN default_post_listing_type; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-04-26-105145_only_mod_can_post/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN posting_restricted_to_mods; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-08-04-150644_add_application_email_admins/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN application_email_admins; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-09-24-161829_remove_table_aliases/up.sql: -------------------------------------------------------------------------------- 1 | -- Drop the alias views 2 | DROP VIEW person_alias_1, person_alias_2; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-02-13-172528_add_report_email_admins/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN reports_email_admins; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-06-19-055530_add_retry_worker_setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN federation_worker_count; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-13-175712_allow_animated_avatars/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN enable_animated_images; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-17-181800_drop_remove_community_expires/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_remove_community 2 | DROP COLUMN expires; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-24-183747_autocollapse_bot_comments/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN collapse_bot_comments; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-01-02-094916_site-name-not-unique/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD CONSTRAINT site_name_key UNIQUE (name); 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-02-15-171358_default_instance_sort_type/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN default_sort_type; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-11-12-090437_move-triggers/up.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION community_aggregates_activity, site_aggregates_activity CASCADE; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000000_enable_private_messages/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN enable_private_messages; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000053_remove_hide_modlog_names/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN hide_modlog_mod_names; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-09-15-090401_remove-keyboard-nav/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN enable_keyboard_navigation; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-01-31-050334_add_forum_sort_index/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_post_aggregates_comments ON post_aggregates (comments DESC); 2 | 3 | -------------------------------------------------------------------------------- /migrations/2021-02-28-162616_clean_empty_post_urls/up.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | post 3 | SET 4 | url = NULL 5 | WHERE 6 | url = ''; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2021-03-19-014144_add_col_local_user_validator_time/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN validator_time; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_community_aggregates_users_active_month; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-02-18-210946_default_theme/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD COLUMN default_theme text NOT NULL DEFAULT 'browser'; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-02-15-212546_add_post_comment_saved_indexes/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_saved_person_id, idx_comment_saved_person_id; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2023-07-10-075550_add-infinite-scroll-setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN infinite_scroll_enabled; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-08-02-144930_password-reset-token/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE password_reset_request RENAME COLUMN token TO token_encrypted; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2023-08-02-144930_password-reset-token/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE password_reset_request RENAME COLUMN token_encrypted TO token; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2023-10-24-131607_proxy_links/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE remote_image; 2 | 3 | ALTER TABLE local_image RENAME TO image_upload; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2024-03-06-104706_local_image_user_opt/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_image 2 | ALTER COLUMN local_user_id DROP NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000020_oauth_pkce/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE oauth_provider 2 | ADD COLUMN use_pkce boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000024_add_person_content_combined_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_content_combined, person_saved_combined; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000054_mod-change-community-vis/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_change_community_visibility 2 | DROP COLUMN reason; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000056_person_note/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person_actions 2 | DROP COLUMN noted_at, 3 | DROP COLUMN note; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000062_username-instance-unique/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person 2 | DROP CONSTRAINT person_name_instance_unique; 3 | 4 | -------------------------------------------------------------------------------- /crates/api/api/src/comment/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod distinguish; 2 | pub mod like; 3 | pub mod list_comment_likes; 4 | pub mod lock; 5 | pub mod save; 6 | -------------------------------------------------------------------------------- /crates/api/api/src/site/registration_applications/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod approve; 2 | pub mod get; 3 | pub mod list; 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /docker/docker_db_backup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | docker-compose exec postgres pg_dumpall -c -U lemmy >dump_$(date +%Y-%m-%d"_"%H_%M_%S).sql 3 | -------------------------------------------------------------------------------- /migrations/2021-02-25-112959_remove-categories/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN category_id; 3 | 4 | DROP TABLE category; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2021-04-02-021422_remove_community_creator/up.sql: -------------------------------------------------------------------------------- 1 | -- Drop the column 2 | ALTER TABLE community 3 | DROP COLUMN creator_id; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2021-04-20-155001_limit-admins-create-community/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN community_creation_admin_only; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-07-19-130929_add_show_new_post_notifs_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN show_new_post_notifs; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-12-09-225529_add_published_to_email_verification/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE email_verification 2 | DROP COLUMN published; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN open_links_in_new_tab; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-07-05-000058_person-admin/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_person_admin; 2 | 3 | CREATE INDEX idx_person_admin ON person (admin); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-09-12-194850_add_federation_worker_index/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_person_local_instance ON person (local DESC, instance_id); 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-03-06-201637_url_blocklist/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE local_site_url_blocklist; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000047_disable-email-notifications/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN disable_email_notifications; 3 | 4 | -------------------------------------------------------------------------------- /scripts/clear_db.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | psql -U lemmy -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public; DROP SCHEMA utils CASCADE;" 4 | -------------------------------------------------------------------------------- /crates/apub/activities/src/create_or_update/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod comment; 2 | pub(crate) mod note_wrapper; 3 | pub mod post; 4 | pub mod private_message; 5 | -------------------------------------------------------------------------------- /crates/apub/objects/src/utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod functions; 2 | pub mod markdown_links; 3 | pub mod mentions; 4 | pub mod protocol; 5 | pub mod test; 6 | -------------------------------------------------------------------------------- /crates/routes/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod feeds; 2 | pub mod images; 3 | pub mod middleware; 4 | pub mod nodeinfo; 5 | pub mod utils; 6 | pub mod webfinger; 7 | -------------------------------------------------------------------------------- /migrations/2019-03-05-233828_create_comment/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE comment_saved; 2 | 3 | DROP TABLE comment_like; 4 | 5 | DROP TABLE comment; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2020-02-02-004806_add_case_insensitive_usernames/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_user_name_lower; 2 | 3 | DROP INDEX idx_user_email_lower; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2020-11-10-150835_community_follower_pending/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community_follower 2 | ADD COLUMN pending boolean DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-03-31-103917_add_show_score_setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN show_scores boolean DEFAULT TRUE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-04-26-105145_only_mod_can_post/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | ADD COLUMN posting_restricted_to_mods boolean DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-06-13-124806_post_report_name_length/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post_report 2 | ALTER COLUMN original_post_name TYPE varchar(100); 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-06-133405_add_keyboard_navigation_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN enable_keyboard_navigation; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-17-181800_drop_remove_community_expires/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_remove_community 2 | ADD COLUMN expires timestamptz; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-04-15-105932_community_followers_url_optional/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | ALTER COLUMN followers_url SET NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-04-15-105932_community_followers_url_optional/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | ALTER COLUMN followers_url DROP NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-02-11-131045_ban-remove-content-pm/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE private_message 2 | ADD COLUMN removed bool NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000010_remove_auto_expand/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN auto_expand boolean NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000015_add_mark_fetched_posts_as_read/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN auto_mark_fetched_posts_as_read; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000028_add_index_on_person_id_read_for_read_only_post_actions/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_actions_on_read_read_not_null; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000036_interactions_per_month_schema/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community_aggregates 2 | DROP COLUMN interactions_month; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000040_block_nsfw/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN disallow_nsfw_content boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2019-06-01-222649_remove_admin/down.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO user_ (name, fedi_name, password_encrypted) 2 | VALUES ('admin', 'TBD', 'TBD'); 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-01-04-034553_add_hidden_column/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN hidden; 3 | 4 | DROP TABLE mod_hide_community; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2022-08-04-214722_add_distinguished_comment/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | ADD COLUMN distinguished boolean NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-05-04-140749_separate_triggers/up.sql: -------------------------------------------------------------------------------- 1 | -- This migration exists to trigger re-execution of replaceable_schema 2 | SELECT 3 | 1; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000003_remove_show_scores_column/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN show_scores boolean NOT NULL DEFAULT TRUE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000056_person_note/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person_actions 2 | ADD COLUMN noted_at timestamptz, 3 | ADD COLUMN note text; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-06-170325_add_indexes_for_aggregates_activity_new/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_actions_voted_at, idx_comment_actions_voted_at; 2 | 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @Nutomic @dessalines @phiresky @dullbananas @SleeplessOne1917 2 | crates/apub/ @Nutomic 3 | migrations/ @dessalines @phiresky @dullbananas 4 | -------------------------------------------------------------------------------- /crates/api/api_common/src/modlog.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{newtypes::ModlogId, source::modlog::Modlog}; 2 | pub use lemmy_db_views_modlog::api::GetModlog; 3 | -------------------------------------------------------------------------------- /crates/db_schema/src/source/combined/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod person_content; 2 | pub mod person_liked; 3 | pub mod person_saved; 4 | pub mod report; 5 | pub mod search; 6 | -------------------------------------------------------------------------------- /migrations/2021-04-24-174047_add_show_read_post_setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN show_read_posts boolean DEFAULT TRUE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-11-23-031528_add_report_published_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_comment_report_published; 2 | 3 | DROP INDEX idx_post_report_published; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-04-12-114352_default_post_listing_type/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD COLUMN default_post_listing_type text NOT NULL DEFAULT 'Local'; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-06-12-012121_add_site_hide_modlog_names/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD COLUMN hide_modlog_mod_names boolean DEFAULT TRUE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-06-19-055530_add_retry_worker_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN federation_worker_count int DEFAULT 64 NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-13-175712_allow_animated_avatars/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN enable_animated_images boolean DEFAULT TRUE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-11-02-120140_apub-signed-fetch/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN federation_signed_fetch boolean NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-01-15-100133_local-only-community/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN visibility; 3 | 4 | DROP TYPE community_visibility; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-07-29-152743_post-aggregates-creator-community-indexes/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_aggregates_creator, idx_post_aggregates_community; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000035_media_filter/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN hide_media; 3 | 4 | DROP INDEX idx_post_url_content_type; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-09-08-000001_add-video-dimensions/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN embed_video_width, 3 | DROP COLUMN embed_video_height; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-10-08-084508-0000_multi-comm-index-lower/up.sql: -------------------------------------------------------------------------------- 1 | CREATE UNIQUE INDEX idx_multi_community_lower_actor_id ON multi_community (lower(ap_id)); 2 | 3 | -------------------------------------------------------------------------------- /migrations/2023-02-05-102549_drop-site-federation-debug/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN federation_debug boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-09-20-110614_drop-show-new-post-notifs/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN show_new_post_notifs boolean NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-24-183747_autocollapse_bot_comments/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN collapse_bot_comments boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-08-03-155932_increase_post_url_max_length/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | ALTER COLUMN url TYPE varchar(512); 3 | 4 | ANALYZE post (url); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-07-29-152742_add_indexes_for_aggregates_activity/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_published, idx_post_like_published, idx_comment_like_published; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000000_enable_private_messages/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN enable_private_messages boolean DEFAULT TRUE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000052_lock_reason/up.sql: -------------------------------------------------------------------------------- 1 | -- Adding a lock reason field to mod_lock_post 2 | ALTER TABLE mod_lock_post 3 | ADD COLUMN reason text; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-09-15-090401_remove-keyboard-nav/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN enable_keyboard_navigation boolean NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2019-03-03-163336_create_post/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE post_read; 2 | 3 | DROP TABLE post_saved; 4 | 5 | DROP TABLE post_like; 6 | 7 | DROP TABLE post; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2021-03-19-014144_add_col_local_user_validator_time/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN validator_time timestamp NOT NULL DEFAULT now(); 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-04-20-155001_limit-admins-create-community/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD COLUMN community_creation_admin_only bool NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-07-19-130929_add_show_new_post_notifs_setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN show_new_post_notifs boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2022-05-20-135341_embed-url/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN embed_video_url; 3 | 4 | ALTER TABLE post 5 | ADD COLUMN embed_html text; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2022-05-20-135341_embed-url/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN embed_html; 3 | 4 | ALTER TABLE post 5 | ADD COLUMN embed_video_url text; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2022-08-22-193848_comment-language-tags/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | ADD COLUMN language_id integer REFERENCES LANGUAGE NOT 3 | NULL DEFAULT 0; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-11-21-204256_user-following/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_follower; 2 | 3 | ALTER TABLE community_follower 4 | ALTER COLUMN pending DROP NOT NULL; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2023-07-10-075550_add-infinite-scroll-setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN infinite_scroll_enabled boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-02-15-171358_default_instance_sort_type/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN default_sort_type sort_type_enum DEFAULT 'Active' NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000027_add_search_combined_table/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person_aggregates 2 | DROP COLUMN published; 3 | 4 | DROP TABLE search_combined; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000030_optimize_get_random_community/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN random_number; 3 | 4 | DROP FUNCTION random_smallint; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000047_disable-email-notifications/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN disable_email_notifications bool NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-12-09-225529_add_published_to_email_verification/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE email_verification 2 | ADD COLUMN published timestamp NOT NULL DEFAULT now(); 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-06-22-051755_fix_local_communities_marked_non_local/down.sql: -------------------------------------------------------------------------------- 1 | -- Add a no-op statement to prevent `diesel migration redo` errors 2 | SELECT 3 | 1; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN open_links_in_new_tab boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-06-24-185942_aggegates_published_indexes/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_comment_aggregates_published; 2 | 3 | DROP INDEX idx_community_aggregates_published; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-08-29-183053_add_listing_type_moderator_view/up.sql: -------------------------------------------------------------------------------- 1 | -- Update the listing_type_enum 2 | ALTER TYPE listing_type_enum 3 | ADD VALUE 'ModeratorView'; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-10-06-133405_add_keyboard_navigation_setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN enable_keyboard_navigation boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-03-06-104706_local_image_user_opt/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_image 2 | ADD CONSTRAINT image_upload_local_user_id_not_null NOT NULL local_user_id; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-09-08-000001_add-video-dimensions/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | ADD COLUMN embed_video_width integer, 3 | ADD COLUMN embed_video_height integer; 4 | 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "crates/utils/translations"] 2 | path = crates/email/translations 3 | url = https://github.com/LemmyNet/lemmy-translations.git 4 | branch = main 5 | -------------------------------------------------------------------------------- /crates/api/api/src/reports/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod comment_report; 2 | pub mod community_report; 3 | pub mod post_report; 4 | pub mod private_message_report; 5 | pub mod report_combined; 6 | -------------------------------------------------------------------------------- /migrations/2022-09-08-102358_site-and-community-languages/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE site_language; 2 | 3 | DROP TABLE community_language; 4 | 5 | DELETE FROM local_user_language; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-06-27-065106_add_ui_settings/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN blur_nsfw; 3 | 4 | ALTER TABLE local_user 5 | DROP COLUMN auto_expand; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-08-08-163911_add_post_listing_mode_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN post_listing_mode; 3 | 4 | DROP TYPE post_listing_mode_enum; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-05-15-154113_missing_post_indexes/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_read_post; 2 | 3 | DROP INDEX idx_post_hide_post; 4 | 5 | DROP INDEX idx_post_saved_post; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000015_add_mark_fetched_posts_as_read/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN auto_mark_fetched_posts_as_read boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2021-03-31-144349_add_site_short_description/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN description; 3 | 4 | ALTER TABLE site RENAME COLUMN sidebar TO description; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2023-02-16-194139_add_totp_secret/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN totp_2fa_secret; 3 | 4 | ALTER TABLE local_user 5 | DROP COLUMN totp_2fa_url; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-09-18-141700_login-token/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE login_token; 2 | 3 | ALTER TABLE local_user 4 | ADD COLUMN validator_time timestamptz NOT NULL DEFAULT now(); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2023-09-20-110614_drop-show-new-post-notifs/up.sql: -------------------------------------------------------------------------------- 1 | -- this setting is unused with websocket gone 2 | ALTER TABLE local_user 3 | DROP COLUMN show_new_post_notifs; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2019-10-21-011237_add_default_sorts/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | DROP COLUMN default_sort_type; 3 | 4 | ALTER TABLE user_ 5 | DROP COLUMN default_listing_type; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_community_aggregates_users_active_month ON community_aggregates (users_active_month DESC); 2 | 3 | -------------------------------------------------------------------------------- /migrations/2023-02-07-030958_community-collections/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN moderators_url; 3 | 4 | ALTER TABLE community 5 | DROP COLUMN featured_url; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-02-13-221303_add_instance_software_and_version/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE instance 2 | DROP COLUMN software; 3 | 4 | ALTER TABLE instance 5 | DROP COLUMN version; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000044_post_comment_pending/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN federation_pending; 3 | 4 | ALTER TABLE comment 5 | DROP COLUMN federation_pending; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-09-01-141127_local-community-collections/down.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | community 3 | SET 4 | moderators_url = NULL, 5 | featured_url = NULL 6 | WHERE 7 | local; 8 | 9 | -------------------------------------------------------------------------------- /scripts/update_config_defaults.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | dest=${1-config/defaults.hjson} 5 | 6 | cargo run --manifest-path crates/utils/Cargo.toml --features full >"$dest" 7 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Use [Github's security advisory issue system](https://github.com/LemmyNet/lemmy/security/advisories/new). 6 | -------------------------------------------------------------------------------- /migrations/2022-06-13-124806_post_report_name_length/up.sql: -------------------------------------------------------------------------------- 1 | -- adjust length limit to match post.name 2 | ALTER TABLE post_report 3 | ALTER COLUMN original_post_name TYPE varchar(200); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-02-16-194139_add_totp_secret/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN totp_2fa_secret text; 3 | 4 | ALTER TABLE local_user 5 | ADD COLUMN totp_2fa_url text; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-09-11-110040_rework-2fa-setup/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN totp_2fa_url text; 3 | 4 | ALTER TABLE local_user 5 | DROP COLUMN totp_2fa_enabled; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2024-01-22-105746_lemmynsfw-changes/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN content_warning; 3 | 4 | ALTER TABLE local_site 5 | DROP COLUMN default_post_listing_mode; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000004_custom_emoji_tagline_changes/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE custom_emoji 2 | DROP COLUMN local_site_id; 3 | 4 | ALTER TABLE tagline 5 | DROP COLUMN local_site_id; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-10-09-101527-0000_community-follower-denied/up.sql: -------------------------------------------------------------------------------- 1 | -- add follow state denied for private communities 2 | ALTER TYPE community_follower_state 3 | ADD value 'Denied'; 4 | 5 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/collections/group_followers.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://enterprise.lemmy.ml/c/main/followers", 3 | "type": "Collection", 4 | "totalItems": 3, 5 | "items": [] 6 | } 7 | -------------------------------------------------------------------------------- /migrations/2020-11-05-152724_activity_remove_user_id/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE activity 2 | DROP COLUMN user_id; 3 | 4 | ALTER TABLE activity 5 | ADD COLUMN sensitive boolean DEFAULT TRUE; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2021-03-04-040229_clean_icon_urls/down.sql: -------------------------------------------------------------------------------- 1 | -- This is a clean-up migration that cannot be undone, 2 | -- but Diesel requires a non-empty script so run a no-op. 3 | SELECT 4 | 1; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000011_add_short_community_description/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN description; 3 | 4 | ALTER TABLE community RENAME COLUMN sidebar TO description; 5 | 6 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | tab_spaces = 2 2 | edition = "2024" 3 | imports_layout = "HorizontalVertical" 4 | imports_granularity = "Crate" 5 | group_imports = "One" 6 | wrap_comments = true 7 | comment_width = 100 8 | -------------------------------------------------------------------------------- /crates/api/api_utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod build_response; 2 | pub mod claims; 3 | pub mod context; 4 | pub mod notify; 5 | pub mod plugins; 6 | pub mod request; 7 | pub mod send_activity; 8 | pub mod utils; 9 | -------------------------------------------------------------------------------- /migrations/2020-04-21-123957_remove_unique_user_constraints/up.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_user_name_lower; 2 | 3 | CREATE UNIQUE INDEX idx_user_name_lower_actor_id ON user_ (lower(name), lower(actor_id)); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2020-10-13-212240_create_report_tables/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW comment_report_view; 2 | 3 | DROP VIEW post_report_view; 4 | 5 | DROP TABLE comment_report; 6 | 7 | DROP TABLE post_report; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2021-02-28-162616_clean_empty_post_urls/down.sql: -------------------------------------------------------------------------------- 1 | -- This is a clean-up migration that cannot be undone, 2 | -- but Diesel requires a non-empty script so run a no-op. 3 | SELECT 4 | 1; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2023-06-06-104440_index_post_url/down.sql: -------------------------------------------------------------------------------- 1 | -- Change back the column type 2 | ALTER TABLE post 3 | ALTER COLUMN url TYPE text; 4 | 5 | -- Drop the index 6 | DROP INDEX idx_post_url; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000022_instance-block-mod-log/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE federation_blocklist 2 | DROP expires; 3 | 4 | DROP TABLE admin_block_instance; 5 | 6 | DROP TABLE admin_allow_instance; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000038_ap_id/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person RENAME ap_id TO actor_id; 2 | 3 | ALTER TABLE community RENAME ap_id TO actor_id; 4 | 5 | ALTER TABLE site RENAME ap_id TO actor_id; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000038_ap_id/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person RENAME actor_id TO ap_id; 2 | 3 | ALTER TABLE community RENAME actor_id TO ap_id; 4 | 5 | ALTER TABLE site RENAME actor_id TO ap_id; 6 | 7 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/collections/person_outbox.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "OrderedCollection", 3 | "id": "http://ds9.lemmy.ml/u/lemmy_alpha/outbox", 4 | "orderedItems": [], 5 | "totalItems": 0 6 | } 7 | -------------------------------------------------------------------------------- /migrations/2022-04-12-185205_change_default_listing_type_to_local/down.sql: -------------------------------------------------------------------------------- 1 | -- 0 is All, 1 is Local, 2 is Subscribed 2 | ALTER TABLE ONLY local_user 3 | ALTER COLUMN default_listing_type SET DEFAULT 2; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-04-12-185205_change_default_listing_type_to_local/up.sql: -------------------------------------------------------------------------------- 1 | -- 0 is All, 1 is Local, 2 is Subscribed 2 | ALTER TABLE ONLY local_user 3 | ALTER COLUMN default_listing_type SET DEFAULT 1; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-02-24-173152_search-alt-text-of-posts/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_trigram; 2 | 3 | CREATE INDEX IF NOT EXISTS idx_post_trigram ON post USING gin (name gin_trgm_ops, body gin_trgm_ops); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000036_interactions_per_month_schema/up.sql: -------------------------------------------------------------------------------- 1 | -- Add the interactions_month column 2 | ALTER TABLE community_aggregates 3 | ADD COLUMN interactions_month bigint NOT NULL DEFAULT 0; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000037_report_to_admins/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post_report 2 | DROP COLUMN violates_instance_rules; 3 | 4 | ALTER TABLE comment_report 5 | DROP COLUMN violates_instance_rules; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2020-04-21-123957_remove_unique_user_constraints/down.sql: -------------------------------------------------------------------------------- 1 | -- The username index 2 | DROP INDEX idx_user_name_lower_actor_id; 3 | 4 | CREATE UNIQUE INDEX idx_user_name_lower ON user_ (lower(name)); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2021-10-01-141650_create_admin_purge/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE admin_purge_person; 2 | 3 | DROP TABLE admin_purge_community; 4 | 5 | DROP TABLE admin_purge_post; 6 | 7 | DROP TABLE admin_purge_comment; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2021-11-22-143904_add_required_public_key/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | ALTER COLUMN public_key DROP NOT NULL; 3 | 4 | ALTER TABLE person 5 | ALTER COLUMN public_key DROP NOT NULL; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-02-13-172528_add_report_email_admins/up.sql: -------------------------------------------------------------------------------- 1 | -- Adding a field to email admins for new reports 2 | ALTER TABLE local_site 3 | ADD COLUMN reports_email_admins boolean NOT NULL DEFAULT FALSE; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-09-11-110040_rework-2fa-setup/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN totp_2fa_url; 3 | 4 | ALTER TABLE local_user 5 | ADD COLUMN totp_2fa_enabled boolean NOT NULL DEFAULT FALSE; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000007_schedule-post/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | ADD COLUMN scheduled_publish_time timestamptz; 3 | 4 | CREATE INDEX idx_post_scheduled_publish_time ON post (scheduled_publish_time); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000068_local_user_trigger/down.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | local_site 3 | SET 4 | users = ( 5 | SELECT 6 | count(*) 7 | FROM 8 | local_user); 9 | 10 | -------------------------------------------------------------------------------- /migrations/2025-11-05-181519-0000_add_registration_application_updated_at/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_registration_application_updated; 2 | 3 | ALTER TABLE registration_application 4 | DROP COLUMN updated_at; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2023-02-15-212546_add_post_comment_saved_indexes/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_post_saved_person_id ON post_saved (person_id); 2 | 3 | CREATE INDEX idx_comment_saved_person_id ON comment_saved (person_id); 4 | 5 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lotide/objects/tombstone.json: -------------------------------------------------------------------------------- 1 | { 2 | "former_type": "Note", 3 | "@context": "https://www.w3.org/ns/activitystreams", 4 | "id": "https://narwhal.city/posts/12", 5 | "type": "Tombstone" 6 | } 7 | -------------------------------------------------------------------------------- /migrations/2022-08-04-150644_add_application_email_admins/up.sql: -------------------------------------------------------------------------------- 1 | -- Adding a field to email admins for new applications 2 | ALTER TABLE site 3 | ADD COLUMN application_email_admins boolean NOT NULL DEFAULT FALSE; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2023-02-07-030958_community-collections/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | ADD COLUMN moderators_url varchar(255) UNIQUE; 3 | 4 | ALTER TABLE community 5 | ADD COLUMN featured_url varchar(255) UNIQUE; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2021-11-23-031528_add_report_published_index/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_comment_report_published ON comment_report (published DESC); 2 | 3 | CREATE INDEX idx_post_report_published ON post_report (published DESC); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-11-21-143249_remove-federation-settings/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN federation_strict_allowlist; 3 | 4 | ALTER TABLE local_site 5 | DROP COLUMN federation_http_fetch_retry_limit; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-02-24-173152_search-alt-text-of-posts/up.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_trigram; 2 | 3 | CREATE INDEX IF NOT EXISTS idx_post_trigram ON post USING gin (name gin_trgm_ops, body gin_trgm_ops, alt_text gin_trgm_ops); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000028_add_index_on_person_id_read_for_read_only_post_actions/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_post_actions_on_read_read_not_null ON post_actions (person_id, read, post_id) 2 | WHERE 3 | read IS NOT NULL; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2022-04-19-111004_default_require_application/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ALTER COLUMN require_application SET DEFAULT FALSE; 3 | 4 | ALTER TABLE site 5 | ALTER COLUMN application_question SET DEFAULT NULL; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-06-22-101245_increase_user_theme_column_size/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE ONLY local_user 2 | ALTER COLUMN theme TYPE text; 3 | 4 | ALTER TABLE ONLY local_user 5 | ALTER COLUMN theme SET DEFAULT 'browser'::text; 6 | 7 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/collections/group_moderators.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "OrderedCollection", 3 | "id": "https://enterprise.lemmy.ml/c/tenforward/moderators", 4 | "orderedItems": ["https://enterprise.lemmy.ml/u/picard"] 5 | } 6 | -------------------------------------------------------------------------------- /migrations/2019-10-21-011237_add_default_sorts/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | ADD COLUMN default_sort_type smallint DEFAULT 0 NOT NULL; 3 | 4 | ALTER TABLE user_ 5 | ADD COLUMN default_listing_type smallint DEFAULT 1 NOT NULL; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2020-04-03-194936_add_activitypub_for_posts_and_comments/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN ap_id, 3 | DROP COLUMN local; 4 | 5 | ALTER TABLE comment 6 | DROP COLUMN ap_id, 7 | DROP COLUMN local; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2022-01-28-104106_instance-actor/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN actor_id, 3 | DROP COLUMN last_refreshed_at, 4 | DROP COLUMN inbox_url, 5 | DROP COLUMN private_key, 6 | DROP COLUMN public_key; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2022-09-24-161829_remove_table_aliases/down.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW person_alias_1 AS 2 | SELECT 3 | * 4 | FROM 5 | person; 6 | 7 | CREATE VIEW person_alias_2 AS 8 | SELECT 9 | * 10 | FROM 11 | person; 12 | 13 | -------------------------------------------------------------------------------- /migrations/2023-07-05-000058_person-admin/up.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX IF EXISTS idx_person_admin; 2 | 3 | CREATE INDEX idx_person_admin ON person (admin) 4 | WHERE 5 | admin; 6 | 7 | -- allow quickly finding all admins (PersonView::admins) 8 | -------------------------------------------------------------------------------- /migrations/2024-05-05-162540_add_image_detail_table/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE remote_image 2 | ADD UNIQUE (link), 3 | DROP CONSTRAINT remote_image_pkey, 4 | ADD COLUMN id serial PRIMARY KEY; 5 | 6 | DROP TABLE image_details; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000021_add_blurhash_to_image_details/up.sql: -------------------------------------------------------------------------------- 1 | -- Add a blurhash column for image_details 2 | ALTER TABLE image_details 3 | -- Supposed to be 20-30 chars, use 50 to be safe 4 | ADD COLUMN blurhash varchar(50); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000035_media_filter/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN hide_media boolean DEFAULT FALSE NOT NULL; 3 | 4 | CREATE INDEX idx_post_url_content_type ON post USING gin (url_content_type gin_trgm_ops); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000058_instance_block_communities_persons/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE instance_actions RENAME COLUMN blocked_communities_at TO blocked_at; 2 | 3 | ALTER TABLE instance_actions 4 | DROP COLUMN blocked_persons_at; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2024-01-22-105746_lemmynsfw-changes/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD COLUMN content_warning text; 3 | 4 | ALTER TABLE local_site 5 | ADD COLUMN default_post_listing_mode post_listing_mode_enum NOT NULL DEFAULT 'List'; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-07-29-152743_post-aggregates-creator-community-indexes/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_post_aggregates_creator ON post_aggregates (creator_id); 2 | 3 | CREATE INDEX idx_post_aggregates_community ON post_aggregates (community_id); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000059_person_votes/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person_actions 2 | DROP COLUMN voted_at, 3 | DROP COLUMN upvotes, 4 | DROP COLUMN downvotes; 5 | 6 | ALTER TABLE local_user 7 | DROP COLUMN show_person_votes; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000067_add_default_items_per_page/down.sql: -------------------------------------------------------------------------------- 1 | -- Drop the new columns 2 | ALTER TABLE local_user 3 | DROP COLUMN default_items_per_page; 4 | 5 | ALTER TABLE local_site 6 | DROP COLUMN default_items_per_page; 7 | 8 | -------------------------------------------------------------------------------- /config/config.hjson: -------------------------------------------------------------------------------- 1 | # See the documentation for available config fields and descriptions: 2 | # https://join-lemmy.org/docs/en/administration/configuration.html 3 | { 4 | hostname: lemmy-alpha 5 | pictrs: { 6 | image_mode: None 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /migrations/2020-11-05-152724_activity_remove_user_id/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE activity 2 | ADD COLUMN user_id integer REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL; 3 | 4 | ALTER TABLE activity 5 | DROP COLUMN sensitive; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-09-28-084231_import_user_settings_rate_limit/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site_rate_limit 2 | DROP COLUMN import_user_settings; 3 | 4 | ALTER TABLE local_site_rate_limit 5 | DROP COLUMN import_user_settings_per_second; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-05-15-154113_missing_post_indexes/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_post_read_post ON post_read (post_id); 2 | 3 | CREATE INDEX idx_post_hide_post ON post_hide (post_id); 4 | 5 | CREATE INDEX idx_post_saved_post ON post_saved (post_id); 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-11-01-223740_federation-published/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE federation_queue_state 2 | DROP COLUMN last_successful_published_time, 3 | ALTER COLUMN last_successful_id SET NOT NULL, 4 | ALTER COLUMN last_retry SET NOT NULL; 5 | 6 | -------------------------------------------------------------------------------- /scripts/restore_db.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | psql -U lemmy -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;" 4 | cat docker/lemmy_dump_2021-01-29_16_13_40.sqldump | psql -U lemmy 5 | psql -U lemmy -c "alter user lemmy with password 'password'" 6 | -------------------------------------------------------------------------------- /migrations/2024-01-15-100133_local-only-community/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE community_visibility AS enum ( 2 | 'Public', 3 | 'LocalOnly' 4 | ); 5 | 6 | ALTER TABLE community 7 | ADD COLUMN visibility community_visibility NOT NULL DEFAULT 'Public'; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2025-04-07-100344_registration-rate-limit/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site_rate_limit 2 | ALTER register SET DEFAULT 3; 3 | 4 | UPDATE 5 | local_site_rate_limit 6 | SET 7 | register = 3 8 | WHERE 9 | register = 10; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2025-04-07-100344_registration-rate-limit/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site_rate_limit 2 | ALTER register SET DEFAULT 10; 3 | 4 | UPDATE 5 | local_site_rate_limit 6 | SET 7 | register = 10 8 | WHERE 9 | register = 3; 10 | 11 | -------------------------------------------------------------------------------- /crates/api/api/src/site/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod admin_allow_instance; 2 | pub mod admin_block_instance; 3 | pub mod admin_list_users; 4 | pub mod federated_instances; 5 | pub mod list_all_media; 6 | pub mod mod_log; 7 | pub mod purge; 8 | pub mod registration_applications; 9 | -------------------------------------------------------------------------------- /migrations/2019-04-03-155205_create_community_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW community_view; 2 | 3 | DROP VIEW community_moderator_view; 4 | 5 | DROP VIEW community_follower_view; 6 | 7 | DROP VIEW community_user_ban_view; 8 | 9 | DROP VIEW site_view; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2021-11-22-135324_add_activity_ap_id_index/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE activity 2 | ALTER COLUMN ap_id DROP NOT NULL; 3 | 4 | CREATE UNIQUE INDEX idx_activity_unique_apid ON activity ((data ->> 'id'::text)); 5 | 6 | DROP INDEX idx_activity_ap_id; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2022-06-21-123144_language-tags/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN language_id; 3 | 4 | DROP TABLE local_user_language; 5 | 6 | DROP TABLE LANGUAGE; 7 | 8 | ALTER TABLE local_user RENAME COLUMN interface_language TO lang; 9 | 10 | -------------------------------------------------------------------------------- /migrations/2023-06-21-153242_add_captcha/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE captcha_answer ( 2 | id serial PRIMARY KEY, 3 | uuid uuid NOT NULL UNIQUE DEFAULT gen_random_uuid (), 4 | answer text NOT NULL, 5 | published timestamp NOT NULL DEFAULT now() 6 | ); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2023-06-22-101245_increase_user_theme_column_size/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE ONLY local_user 2 | ALTER COLUMN theme TYPE character varying(20); 3 | 4 | ALTER TABLE ONLY local_user 5 | ALTER COLUMN theme SET DEFAULT 'browser'::character varying; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-07-24-232635_trigram-index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_comment_content_trigram; 2 | 3 | DROP INDEX idx_post_trigram; 4 | 5 | DROP INDEX idx_person_trigram; 6 | 7 | DROP INDEX idx_community_trigram; 8 | 9 | DROP EXTENSION pg_trgm; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2023-10-24-131607_proxy_links/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE remote_image ( 2 | id serial PRIMARY KEY, 3 | link text NOT NULL UNIQUE, 4 | published timestamptz DEFAULT now() NOT NULL 5 | ); 6 | 7 | ALTER TABLE image_upload RENAME TO local_image; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000037_report_to_admins/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post_report 2 | ADD COLUMN violates_instance_rules bool NOT NULL DEFAULT FALSE; 3 | 4 | ALTER TABLE comment_report 5 | ADD COLUMN violates_instance_rules bool NOT NULL DEFAULT FALSE; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-11-01-223740_federation-published/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE federation_queue_state 2 | ADD COLUMN last_successful_published_time timestamptz NULL, 3 | ALTER COLUMN last_successful_id DROP NOT NULL, 4 | ALTER COLUMN last_retry DROP NOT NULL; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000043_community-local-removed/up.sql: -------------------------------------------------------------------------------- 1 | -- Same for remote community, local removal should not be overwritten by 2 | -- remove+restore on home instance 3 | ALTER TABLE community 4 | ADD COLUMN local_removed boolean NOT NULL DEFAULT FALSE; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000068_local_user_trigger/up.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | local_site 3 | SET 4 | users = ( 5 | SELECT 6 | count(*) 7 | FROM 8 | local_user 9 | WHERE 10 | accepted_application); 11 | 12 | -------------------------------------------------------------------------------- /migrations/2021-03-31-144349_add_site_short_description/up.sql: -------------------------------------------------------------------------------- 1 | -- Renaming description to sidebar 2 | ALTER TABLE site RENAME COLUMN description TO sidebar; 3 | 4 | -- Adding a short description column 5 | ALTER TABLE site 6 | ADD COLUMN description varchar(150); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2022-04-11-210137_fix_unique_changeme/up.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION generate_unique_changeme () 2 | RETURNS text 3 | LANGUAGE sql 4 | AS $$ 5 | SELECT 6 | 'http://changeme.invalid/' || substr(md5(random()::text), 0, 25); 7 | $$; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2024-06-24-000000_ap_id_triggers/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | ALTER COLUMN ap_id DROP DEFAULT; 3 | 4 | ALTER TABLE post 5 | ALTER COLUMN ap_id DROP DEFAULT; 6 | 7 | ALTER TABLE private_message 8 | ALTER COLUMN ap_id DROP DEFAULT; 9 | 10 | -------------------------------------------------------------------------------- /migrations/2025-11-05-181519-0000_add_registration_application_updated_at/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE registration_application 2 | ADD COLUMN updated_at timestamptz; 3 | 4 | CREATE INDEX idx_registration_application_updated ON registration_application (updated_at DESC); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2022-11-21-143249_remove-federation-settings/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN federation_strict_allowlist bool DEFAULT TRUE NOT NULL; 3 | 4 | ALTER TABLE local_site 5 | ADD COLUMN federation_http_fetch_retry_limit int NOT NULL DEFAULT 25; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000026_add_inbox_combined_table/down.sql: -------------------------------------------------------------------------------- 1 | -- Rename the person_mention table to person_comment_mention 2 | ALTER TABLE person_comment_mention RENAME TO person_mention; 3 | 4 | -- Drop the new tables 5 | DROP TABLE person_post_mention, inbox_combined; 6 | 7 | -------------------------------------------------------------------------------- /migrations/2019-02-27-170003_create_community/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE site; 2 | 3 | DROP TABLE community_user_ban; 4 | 5 | ; 6 | 7 | DROP TABLE community_moderator; 8 | 9 | DROP TABLE community_follower; 10 | 11 | DROP TABLE community; 12 | 13 | DROP TABLE category; 14 | 15 | -------------------------------------------------------------------------------- /migrations/2020-12-17-031053_remove_fast_tables_and_views/down.sql: -------------------------------------------------------------------------------- 1 | -- There is no restore for this, it would require every view, table, index, etc. 2 | -- If you want to save past this point, you should make a DB backup. 3 | SELECT 4 | * 5 | FROM 6 | user_ 7 | LIMIT 1; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2023-02-13-221303_add_instance_software_and_version/up.sql: -------------------------------------------------------------------------------- 1 | -- Add Software and Version columns from nodeinfo to the instance table 2 | ALTER TABLE instance 3 | ADD COLUMN software varchar(255); 4 | 5 | ALTER TABLE instance 6 | ADD COLUMN version varchar(255); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2024-03-06-201637_url_blocklist/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE local_site_url_blocklist ( 2 | id serial NOT NULL PRIMARY KEY, 3 | url text NOT NULL UNIQUE, 4 | published timestamp with time zone NOT NULL DEFAULT now(), 5 | updated timestamp with time zone 6 | ); 7 | 8 | -------------------------------------------------------------------------------- /scripts/clean-workspace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Run `cargo clean -p` for each workspace member. This allows to accurately measure the time for 5 | # an incremental build. 6 | clear && cargo metadata --no-deps | jq .packages.[].name | sed 's/.*/-p &/' | xargs cargo clean 7 | -------------------------------------------------------------------------------- /scripts/upgrade_deps.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | pushd ../ 4 | 5 | # Check unused deps 6 | cargo udeps --all-targets 7 | 8 | # Update deps first 9 | cargo update 10 | 11 | # Upgrade deps 12 | cargo upgrade 13 | 14 | # Run clippy 15 | cargo clippy 16 | 17 | popd 18 | -------------------------------------------------------------------------------- /crates/api/api_common/src/media.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::source::images::{ImageDetails, LocalImage, RemoteImage}; 2 | pub use lemmy_db_views_local_image::{ 3 | LocalImageView, 4 | api::{DeleteImageParams, ImageGetParams, ImageProxyParams, ListMedia, UploadImageResponse}, 5 | }; 6 | -------------------------------------------------------------------------------- /migrations/2023-07-14-215339_aggregates_nonzero_indexes/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP INDEX idx_community_aggregates_nonzero_hotrank; 3 | 4 | DROP INDEX idx_comment_aggregates_nonzero_hotrank; 5 | 6 | DROP INDEX idx_post_aggregates_nonzero_hotrank; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000011_add_short_community_description/up.sql: -------------------------------------------------------------------------------- 1 | -- Renaming description to sidebar 2 | ALTER TABLE community RENAME COLUMN description TO sidebar; 3 | 4 | -- Adding a short description column 5 | ALTER TABLE community 6 | ADD COLUMN description varchar(150); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000019_add_report_count/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post_aggregates 2 | DROP COLUMN report_count, 3 | DROP COLUMN unresolved_report_count; 4 | 5 | ALTER TABLE comment_aggregates 6 | DROP COLUMN report_count, 7 | DROP COLUMN unresolved_report_count; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2023-06-22-051755_fix_local_communities_marked_non_local/up.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | community c 3 | SET 4 | local = TRUE 5 | FROM 6 | local_site ls 7 | JOIN site s ON ls.site_id = s.id 8 | WHERE 9 | c.instance_id = s.instance_id 10 | AND NOT c.local; 11 | 12 | -------------------------------------------------------------------------------- /migrations/2023-09-28-084231_import_user_settings_rate_limit/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site_rate_limit 2 | ADD COLUMN import_user_settings int NOT NULL DEFAULT 1; 3 | 4 | ALTER TABLE local_site_rate_limit 5 | ADD COLUMN import_user_settings_per_second int NOT NULL DEFAULT 86400; 6 | 7 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lotide/activities/delete_note.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "https://narwhal.city/users/3", 3 | "object": "https://narwhal.city/posts/12", 4 | "@context": "https://www.w3.org/ns/activitystreams", 5 | "id": "https://narwhal.city/posts/12/delete", 6 | "type": "Delete" 7 | } 8 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000008_create_oauth_provider/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE oauth_account; 2 | 3 | DROP TABLE oauth_provider; 4 | 5 | ALTER TABLE local_site 6 | DROP COLUMN oauth_registration; 7 | 8 | ALTER TABLE local_user 9 | ALTER COLUMN password_encrypted SET NOT NULL; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000033_add_post_keyword_block_table/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE local_user_keyword_block ( 2 | local_user_id int REFERENCES local_user (id) ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 3 | keyword varchar(50) NOT NULL, 4 | PRIMARY KEY (local_user_id, keyword) 5 | ); 6 | 7 | -------------------------------------------------------------------------------- /crates/api/api/src/post/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod feature; 2 | pub mod get_link_metadata; 3 | pub mod hide; 4 | pub mod like; 5 | pub mod list_post_likes; 6 | pub mod lock; 7 | pub mod mark_many_read; 8 | pub mod mark_read; 9 | pub mod mod_update; 10 | pub mod save; 11 | pub mod update_notifications; 12 | -------------------------------------------------------------------------------- /migrations/2021-09-20-112945_jwt-secret/up.sql: -------------------------------------------------------------------------------- 1 | -- generate a jwt secret 2 | CREATE EXTENSION IF NOT EXISTS pgcrypto; 3 | 4 | CREATE TABLE secret ( 5 | id serial PRIMARY KEY, 6 | jwt_secret varchar NOT NULL DEFAULT gen_random_uuid () 7 | ); 8 | 9 | INSERT INTO secret DEFAULT VALUES; 10 | -------------------------------------------------------------------------------- /migrations/2023-06-17-175955_add_listingtype_sorttype_hour_enums/up.sql: -------------------------------------------------------------------------------- 1 | -- Update the enums 2 | ALTER TYPE sort_type_enum 3 | ADD VALUE 'TopHour'; 4 | 5 | ALTER TYPE sort_type_enum 6 | ADD VALUE 'TopSixHour'; 7 | 8 | ALTER TYPE sort_type_enum 9 | ADD VALUE 'TopTwelveHour'; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2023-08-08-163911_add_post_listing_mode_setting/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE post_listing_mode_enum AS enum ( 2 | 'List', 3 | 'Card', 4 | 'SmallCard' 5 | ); 6 | 7 | ALTER TABLE local_user 8 | ADD COLUMN post_listing_mode post_listing_mode_enum DEFAULT 'List' NOT NULL; 9 | 10 | -------------------------------------------------------------------------------- /migrations/2025-09-19-132648-0000_theme-instance-default/up.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | local_user 3 | SET 4 | theme = 'instance' 5 | WHERE 6 | theme = 'browser'; 7 | 8 | UPDATE 9 | local_user 10 | SET 11 | theme = 'instance-compact' 12 | WHERE 13 | theme = 'browser-compact'; 14 | 15 | -------------------------------------------------------------------------------- /scripts/postgres_12_to_15_upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "Updating docker-compose to use postgres version 16." 5 | sudo sed -i "s/image: .*postgres:.*/image: pgautoupgrade\/pgautoupgrade:16-alpine/" ./docker-compose.yml 6 | 7 | echo "Starting up lemmy..." 8 | sudo docker-compose up -d 9 | -------------------------------------------------------------------------------- /scripts/postgres_15_to_16_upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "Updating docker-compose to use postgres version 16." 5 | sudo sed -i "s/image: .*postgres:.*/image: pgautoupgrade\/pgautoupgrade:16-alpine/" ./docker-compose.yml 6 | 7 | echo "Starting up lemmy..." 8 | sudo docker-compose up -d 9 | -------------------------------------------------------------------------------- /crates/api/api_common/src/tagline.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{newtypes::TaglineId, source::tagline::Tagline}; 2 | pub use lemmy_db_views_site::api::{ListTaglines, TaglineResponse}; 3 | 4 | pub mod administration { 5 | pub use lemmy_db_views_site::api::{CreateTagline, DeleteTagline, UpdateTagline}; 6 | } 7 | -------------------------------------------------------------------------------- /crates/diesel_utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "full")] 2 | pub mod connection; 3 | pub mod dburl; 4 | pub mod pagination; 5 | #[cfg(feature = "full")] 6 | pub mod schema_setup; 7 | pub mod sensitive; 8 | #[cfg(feature = "full")] 9 | pub mod traits; 10 | #[cfg(feature = "full")] 11 | pub mod utils; 12 | -------------------------------------------------------------------------------- /docker/federation/start-local-instances.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | sudo docker compose down 5 | 6 | for Item in alpha beta gamma delta epsilon; do 7 | sudo mkdir -p volumes/pictrs_$Item 8 | sudo chown -R 991:991 volumes/pictrs_$Item 9 | done 10 | 11 | sudo docker compose up --build 12 | -------------------------------------------------------------------------------- /migrations/2025-08-06-170325_add_indexes_for_aggregates_activity_new/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_post_actions_voted_at ON post_actions (voted_at) 2 | WHERE 3 | voted_at IS NOT NULL; 4 | 5 | CREATE INDEX idx_comment_actions_voted_at ON comment_actions (voted_at) 6 | WHERE 7 | voted_at IS NOT NULL; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2025-09-19-132648-0000_theme-instance-default/down.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | local_user 3 | SET 4 | theme = 'browser' 5 | WHERE 6 | theme = 'instance'; 7 | 8 | UPDATE 9 | local_user 10 | SET 11 | theme = 'browser-compact' 12 | WHERE 13 | theme = 'instance-compact'; 14 | 15 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/mastodon/activities/like_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "id": "https://mastodon.madrid/users/felix#likes/212340", 4 | "type": "Like", 5 | "actor": "https://mastodon.madrid/users/felix", 6 | "object": "https://ds9.lemmy.ml/post/147" 7 | } 8 | -------------------------------------------------------------------------------- /migrations/2019-10-24-002614_create_password_reset_request/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE password_reset_request ( 2 | id serial PRIMARY KEY, 3 | user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 4 | token_encrypted text NOT NULL, 5 | published timestamp NOT NULL DEFAULT now() 6 | ); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2022-04-19-111004_default_require_application/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ALTER COLUMN require_application SET DEFAULT TRUE; 3 | 4 | ALTER TABLE site 5 | ALTER COLUMN application_question SET DEFAULT 'To verify that you are human, please explain why you want to create an account on this site'; 6 | 7 | -------------------------------------------------------------------------------- /crates/api/api_common/src/notification.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{ 2 | NotificationDataType, 3 | newtypes::NotificationId, 4 | source::notification::Notification, 5 | }; 6 | pub use lemmy_db_views_notification::{ 7 | ListNotifications, 8 | NotificationView, 9 | api::MarkNotificationAsRead, 10 | }; 11 | -------------------------------------------------------------------------------- /migrations/2023-06-20-191145_add_listingtype_sorttype_3_6_9_months_enums/up.sql: -------------------------------------------------------------------------------- 1 | -- Update the enums 2 | ALTER TYPE sort_type_enum 3 | ADD VALUE 'TopThreeMonths'; 4 | 5 | ALTER TYPE sort_type_enum 6 | ADD VALUE 'TopSixMonths'; 7 | 8 | ALTER TYPE sort_type_enum 9 | ADD VALUE 'TopNineMonths'; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2023-06-24-185942_aggegates_published_indexes/up.sql: -------------------------------------------------------------------------------- 1 | -- Add indexes on published column (needed for hot_rank updates) 2 | CREATE INDEX idx_community_aggregates_published ON community_aggregates (published DESC); 3 | 4 | CREATE INDEX idx_comment_aggregates_published ON comment_aggregates (published DESC); 5 | 6 | -------------------------------------------------------------------------------- /scripts/update_translations.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | pushd ../../lemmy-translations 5 | git fetch weblate 6 | git merge weblate/main 7 | git push 8 | popd 9 | 10 | git submodule update --remote 11 | git add ../crates/utils/translations 12 | git commit -m"Updating translations." 13 | git push 14 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/mastodon/activities/follow.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "id": "https://masto.asonix.dog/1ea87517-63c5-4118-8831-460ee641b2cf", 4 | "type": "Follow", 5 | "actor": "https://masto.asonix.dog/users/asonix", 6 | "object": "https://ds9.lemmy.ml/c/testcom" 7 | } 8 | -------------------------------------------------------------------------------- /migrations/2025-09-08-140711_remove-actor-name-max-length/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN actor_name_max_length int DEFAULT 20 NOT NULL; 3 | 4 | ALTER TABLE person 5 | ALTER COLUMN display_name TYPE varchar(255); 6 | 7 | ALTER TABLE community 8 | ALTER COLUMN title TYPE varchar(255); 9 | 10 | -------------------------------------------------------------------------------- /migrations/2024-08-03-155932_increase_post_url_max_length/up.sql: -------------------------------------------------------------------------------- 1 | -- Change the post url max limit to 2000 2 | -- From here: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers#417184 3 | ALTER TABLE post 4 | ALTER COLUMN url TYPE varchar(2000); 5 | 6 | ANALYZE post (url); 7 | 8 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/following/follow.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "to": ["http://enterprise.lemmy.ml/c/main"], 4 | "object": "http://enterprise.lemmy.ml/c/main", 5 | "type": "Follow", 6 | "id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866" 7 | } 8 | -------------------------------------------------------------------------------- /migrations/2020-12-14-020038_create_comment_aggregates/down.sql: -------------------------------------------------------------------------------- 1 | -- comment aggregates 2 | DROP TABLE comment_aggregates; 3 | 4 | DROP TRIGGER comment_aggregates_comment ON comment; 5 | 6 | DROP TRIGGER comment_aggregates_score ON comment_like; 7 | 8 | DROP FUNCTION comment_aggregates_comment, comment_aggregates_score; 9 | 10 | -------------------------------------------------------------------------------- /migrations/2023-05-10-095739_force_enable_undetermined_language/up.sql: -------------------------------------------------------------------------------- 1 | -- force enable undetermined language for all users 2 | INSERT INTO local_user_language (local_user_id, language_id) 3 | SELECT 4 | id, 5 | 0 6 | FROM 7 | local_user 8 | ON CONFLICT (local_user_id, 9 | language_id) 10 | DO NOTHING; 11 | 12 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/voting/like_note.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "object": "http://ds9.lemmy.ml/comment/1", 4 | "audience": "https://enterprise.lemmy.ml/c/tenforward", 5 | "type": "Like", 6 | "id": "http://ds9.lemmy.ml/activities/like/fd61d070-7382-46a9-b2b7-6bb253732877" 7 | } 8 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lotide/activities/follow.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "https://dev.narwhal.city/users/1", 3 | "object": "https://beehaw.org/c/foss", 4 | "to": "https://beehaw.org/c/foss", 5 | "@context": "https://www.w3.org/ns/activitystreams", 6 | "id": "https://dev.narwhal.city/communities/90/followers/1", 7 | "type": "Follow" 8 | } 9 | -------------------------------------------------------------------------------- /migrations/2025-09-01-141127_local-community-collections/up.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | community c1 3 | SET 4 | moderators_url = trim(TRAILING '/' FROM c2.ap_id) || '/moderators', 5 | featured_url = trim(TRAILING '/' FROM c2.ap_id) || '/featured' 6 | FROM 7 | community c2 8 | WHERE 9 | c1.local 10 | AND c1.id = c2.id; 11 | 12 | -------------------------------------------------------------------------------- /migrations/2023-07-19-163511_comment_sort_hot_rank_then_score/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_comment_aggregates_hot, idx_comment_aggregates_score; 2 | 3 | CREATE INDEX idx_comment_aggregates_hot ON comment_aggregates (hot_rank DESC, published DESC); 4 | 5 | CREATE INDEX idx_comment_aggregates_score ON comment_aggregates (score DESC, published DESC); 6 | 7 | -------------------------------------------------------------------------------- /migrations/2023-09-01-112158_auto_resolve_report/down.sql: -------------------------------------------------------------------------------- 1 | DROP TRIGGER IF EXISTS post_removed_resolve_reports ON mod_remove_post; 2 | 3 | DROP FUNCTION IF EXISTS post_removed_resolve_reports; 4 | 5 | DROP TRIGGER IF EXISTS comment_removed_resolve_reports ON mod_remove_comment; 6 | 7 | DROP FUNCTION IF EXISTS comment_removed_resolve_reports; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2024-06-24-000000_ap_id_triggers/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | ALTER COLUMN ap_id SET DEFAULT generate_unique_changeme (); 3 | 4 | ALTER TABLE post 5 | ALTER COLUMN ap_id SET DEFAULT generate_unique_changeme (); 6 | 7 | ALTER TABLE private_message 8 | ALTER COLUMN ap_id SET DEFAULT generate_unique_changeme (); 9 | 10 | -------------------------------------------------------------------------------- /migrations/2022-11-13-181529_create_taglines/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE tagline ( 2 | id serial PRIMARY KEY, 3 | local_site_id int REFERENCES local_site ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 4 | content text NOT NULL, 5 | published timestamp without time zone DEFAULT now() NOT NULL, 6 | updated timestamp without time zone 7 | ); 8 | 9 | -------------------------------------------------------------------------------- /migrations/2024-02-28-144211_hide_posts/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE post_hide ( 2 | post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 3 | person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 4 | published timestamp with time zone NOT NULL DEFAULT now(), 5 | PRIMARY KEY (person_id, post_id) 6 | ); 7 | 8 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/voting/dislike_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "object": "http://ds9.lemmy.ml/post/1", 4 | "audience": "https://enterprise.lemmy.ml/c/tenforward", 5 | "type": "Dislike", 6 | "id": "http://enterprise.lemmy.ml/activities/dislike/64d40d40-a829-43a5-8247-1fb595b3ca1c" 7 | } 8 | -------------------------------------------------------------------------------- /migrations/2023-06-27-065106_add_ui_settings/up.sql: -------------------------------------------------------------------------------- 1 | -- Add the blur_nsfw to the local user table as a setting 2 | ALTER TABLE local_user 3 | ADD COLUMN blur_nsfw boolean NOT NULL DEFAULT TRUE; 4 | 5 | -- Add the auto_expand to the local user table as a setting 6 | ALTER TABLE local_user 7 | ADD COLUMN auto_expand boolean NOT NULL DEFAULT FALSE; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2024-01-25-151400_remove_auto_resolve_report_trigger/up.sql: -------------------------------------------------------------------------------- 1 | DROP TRIGGER IF EXISTS post_removed_resolve_reports ON mod_remove_post; 2 | 3 | DROP FUNCTION IF EXISTS post_removed_resolve_reports; 4 | 5 | DROP TRIGGER IF EXISTS comment_removed_resolve_reports ON mod_remove_comment; 6 | 7 | DROP FUNCTION IF EXISTS comment_removed_resolve_reports; 8 | 9 | -------------------------------------------------------------------------------- /migrations/2019-04-07-003142_create_moderation_logs/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE mod_remove_post; 2 | 3 | DROP TABLE mod_lock_post; 4 | 5 | DROP TABLE mod_remove_comment; 6 | 7 | DROP TABLE mod_remove_community; 8 | 9 | DROP TABLE mod_ban; 10 | 11 | DROP TABLE mod_ban_from_community; 12 | 13 | DROP TABLE mod_add; 14 | 15 | DROP TABLE mod_add_community; 16 | 17 | -------------------------------------------------------------------------------- /crates/diesel_utils/build.rs: -------------------------------------------------------------------------------- 1 | use std::path::Path; 2 | 3 | fn main() -> Result<(), Box> { 4 | let migrations_dir = Path::new("../../migrations/"); 5 | if !migrations_dir.exists() { 6 | return Err("Migrations dir not found".into()); 7 | } 8 | println!("cargo:rerun-if-changed={}", migrations_dir.display()); 9 | Ok(()) 10 | } 11 | -------------------------------------------------------------------------------- /migrations/2023-12-22-040137_make-mixed-sorting-directions-work-with-tuple-comparison/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_aggregates_community_published_asc, idx_post_aggregates_featured_community_published_asc, idx_post_aggregates_featured_local_published_asc, idx_post_aggregates_published_asc; 2 | 3 | DROP FUNCTION reverse_timestamp_sort (t timestamp with time zone); 4 | 5 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000067_add_default_items_per_page/up.sql: -------------------------------------------------------------------------------- 1 | -- Adds an optional default fetch limit (IE fetch a certain number of posts) to local_user and local_site 2 | ALTER TABLE local_user 3 | ADD COLUMN default_items_per_page integer NOT NULL DEFAULT 20; 4 | 5 | ALTER TABLE local_site 6 | ADD COLUMN default_items_per_page integer NOT NULL DEFAULT 20; 7 | 8 | -------------------------------------------------------------------------------- /migrations/2023-08-01-101826_admin_flag_local_user/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN admin boolean DEFAULT FALSE NOT NULL; 3 | 4 | UPDATE 5 | local_user 6 | SET 7 | admin = TRUE 8 | FROM 9 | person 10 | WHERE 11 | local_user.person_id = person.id 12 | AND person.admin; 13 | 14 | ALTER TABLE person 15 | DROP COLUMN admin; 16 | 17 | -------------------------------------------------------------------------------- /scripts/alpine_install_pg_formatter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | version=5.8 5 | wget https://github.com/darold/pgFormatter/archive/refs/tags/v${version}.tar.gz -q 6 | tar xzf v${version}.tar.gz 7 | cd pgFormatter-${version}/ 8 | perl Makefile.PL 9 | make && make install 10 | cd ../ && rm -rf v${version}.tar.gz && rm -rf pgFormatter-${version} #clean up 11 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/deletion/delete_private_message.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "to": ["http://enterprise.lemmy.ml/u/lemmy_beta"], 4 | "object": "http://enterprise.lemmy.ml/private_message/1", 5 | "type": "Delete", 6 | "id": "http://enterprise.lemmy.ml/activities/delete/041d9858-5eef-4ad9-84ae-7455b4d87ed9" 7 | } 8 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/deletion/delete_user.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": "http://ds9.lemmy.ml/u/lemmy_alpha", 5 | "type": "Delete", 6 | "id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12", 7 | "removeData": true 8 | } 9 | -------------------------------------------------------------------------------- /migrations/2021-02-02-153240_apub_columns/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN followers_url; 3 | 4 | ALTER TABLE community 5 | DROP COLUMN inbox_url; 6 | 7 | ALTER TABLE community 8 | DROP COLUMN shared_inbox_url; 9 | 10 | ALTER TABLE user_ 11 | DROP COLUMN inbox_url; 12 | 13 | ALTER TABLE user_ 14 | DROP COLUMN shared_inbox_url; 15 | 16 | -------------------------------------------------------------------------------- /migrations/2024-06-17-160323_fix_post_aggregates_featured_local/up.sql: -------------------------------------------------------------------------------- 1 | -- Fix rows that were not updated because of the old incorrect trigger 2 | UPDATE 3 | post_aggregates 4 | SET 5 | featured_local = post.featured_local 6 | FROM 7 | post 8 | WHERE 9 | post.id = post_aggregates.post_id 10 | AND post.featured_local != post_aggregates.featured_local; 11 | 12 | -------------------------------------------------------------------------------- /migrations/2025-01-10-135505_donation-dialog/up.sql: -------------------------------------------------------------------------------- 1 | -- Generate new column last_donation_notification with default value at random time in the 2 | -- past year (so that users dont see it all at the same time after instance upgrade). 3 | ALTER TABLE local_user 4 | ADD COLUMN last_donation_notification timestamptz NOT NULL DEFAULT (now() - (random() * (interval '12 months'))); 5 | 6 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000018_custom_migration_runner/up.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA IF EXISTS r CASCADE; 2 | 3 | CREATE TABLE previously_run_sql ( 4 | -- For compatibility with Diesel 5 | id boolean PRIMARY KEY, 6 | -- Too big to be used as primary key 7 | content text NOT NULL 8 | ); 9 | 10 | INSERT INTO previously_run_sql (id, content) 11 | VALUES (TRUE, ''); 12 | 13 | -------------------------------------------------------------------------------- /migrations/2019-04-11-144915_create_mod_views/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW mod_remove_post_view; 2 | 3 | DROP VIEW mod_lock_post_view; 4 | 5 | DROP VIEW mod_remove_comment_view; 6 | 7 | DROP VIEW mod_remove_community_view; 8 | 9 | DROP VIEW mod_ban_from_community_view; 10 | 11 | DROP VIEW mod_ban_view; 12 | 13 | DROP VIEW mod_add_community_view; 14 | 15 | DROP VIEW mod_add_view; 16 | 17 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000061_drop-person-ban/down.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE person_ban ( 2 | person_id integer REFERENCES person (id) ON UPDATE CASCADE ON DELETE CASCADE, 3 | published_at timestamptz DEFAULT now(), 4 | CONSTRAINT user_ban_user_id_not_null NOT NULL person_id, 5 | CONSTRAINT user_ban_published_not_null NOT NULL published_at, 6 | PRIMARY KEY (person_id) 7 | ); 8 | 9 | -------------------------------------------------------------------------------- /crates/api/api_common/src/oauth.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{ 2 | newtypes::OAuthProviderId, 3 | source::{ 4 | oauth_account::OAuthAccount, 5 | oauth_provider::{AdminOAuthProvider, PublicOAuthProvider}, 6 | }, 7 | }; 8 | pub use lemmy_db_views_site::api::{ 9 | AuthenticateWithOauth, 10 | CreateOAuthProvider, 11 | DeleteOAuthProvider, 12 | EditOAuthProvider, 13 | }; 14 | -------------------------------------------------------------------------------- /migrations/2021-01-26-173850_default_actor_id/down.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION generate_unique_changeme () 2 | RETURNS text 3 | LANGUAGE sql 4 | AS $$ 5 | SELECT 6 | 'changeme_' || string_agg(substr('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789', ceil(random() * 62)::integer, 1), '') 7 | FROM 8 | generate_series(1, 20) 9 | $$; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2021-11-22-143904_add_required_public_key/up.sql: -------------------------------------------------------------------------------- 1 | -- Delete the empty public keys 2 | DELETE FROM community 3 | WHERE public_key IS NULL; 4 | 5 | DELETE FROM person 6 | WHERE public_key IS NULL; 7 | 8 | -- Make it required 9 | ALTER TABLE community 10 | ALTER COLUMN public_key SET NOT NULL; 11 | 12 | ALTER TABLE person 13 | ALTER COLUMN public_key SET NOT NULL; 14 | 15 | -------------------------------------------------------------------------------- /migrations/2021-01-26-173850_default_actor_id/up.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION generate_unique_changeme () 2 | RETURNS text 3 | LANGUAGE sql 4 | AS $$ 5 | SELECT 6 | 'http://changeme_' || string_agg(substr('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789', ceil(random() * 62)::integer, 1), '') 7 | FROM 8 | generate_series(1, 20) 9 | $$; 10 | 11 | -------------------------------------------------------------------------------- /migrations/00000000000000_diesel_initial_setup/down.sql: -------------------------------------------------------------------------------- 1 | -- This file was automatically created by Diesel to setup helper functions 2 | -- and other internal bookkeeping. This file is safe to edit, any future 3 | -- changes will be added to existing projects as new migrations. 4 | DROP FUNCTION IF EXISTS diesel_manage_updated_at (_tbl regclass); 5 | 6 | DROP FUNCTION IF EXISTS diesel_set_updated_at (); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2022-04-11-210137_fix_unique_changeme/down.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION generate_unique_changeme () 2 | RETURNS text 3 | LANGUAGE sql 4 | AS $$ 5 | SELECT 6 | 'http://changeme_' || string_agg(substr('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789', ceil(random() * 62)::integer, 1), '') 7 | FROM 8 | generate_series(1, 20) 9 | $$; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2025-07-29-152742_add_indexes_for_aggregates_activity/up.sql: -------------------------------------------------------------------------------- 1 | -- These actually increased query time, but they prevent more postgres workers from being launched, and so should free up locks. 2 | CREATE INDEX idx_post_published ON post (published); 3 | 4 | CREATE INDEX idx_post_like_published ON post_like (published); 5 | 6 | CREATE INDEX idx_comment_like_published ON comment_like (published); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2021-03-31-105915_add_bot_account/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW person_alias_1, person_alias_2; 2 | 3 | ALTER TABLE person 4 | DROP COLUMN bot_account; 5 | 6 | CREATE VIEW person_alias_1 AS 7 | SELECT 8 | * 9 | FROM 10 | person; 11 | 12 | CREATE VIEW person_alias_2 AS 13 | SELECT 14 | * 15 | FROM 16 | person; 17 | 18 | ALTER TABLE local_user 19 | DROP COLUMN show_bot_accounts; 20 | 21 | -------------------------------------------------------------------------------- /migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person RENAME preferred_username TO display_name; 2 | 3 | -- Regenerate the person_alias views 4 | DROP VIEW person_alias_1, person_alias_2; 5 | 6 | CREATE VIEW person_alias_1 AS 7 | SELECT 8 | * 9 | FROM 10 | person; 11 | 12 | CREATE VIEW person_alias_2 AS 13 | SELECT 14 | * 15 | FROM 16 | person; 17 | 18 | -------------------------------------------------------------------------------- /crates/api/api_common/src/private_message.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{newtypes::PrivateMessageId, source::private_message::PrivateMessage}; 2 | pub use lemmy_db_views_private_message::{PrivateMessageView, api::PrivateMessageResponse}; 3 | 4 | pub mod actions { 5 | pub use lemmy_db_views_private_message::api::{ 6 | CreatePrivateMessage, 7 | DeletePrivateMessage, 8 | EditPrivateMessage, 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person RENAME display_name TO preferred_username; 2 | 3 | -- Regenerate the person_alias views 4 | DROP VIEW person_alias_1, person_alias_2; 5 | 6 | CREATE VIEW person_alias_1 AS 7 | SELECT 8 | * 9 | FROM 10 | person; 11 | 12 | CREATE VIEW person_alias_2 AS 13 | SELECT 14 | * 15 | FROM 16 | person; 17 | 18 | -------------------------------------------------------------------------------- /migrations/2021-12-14-181537_add_temporary_bans/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW person_alias_1, person_alias_2; 2 | 3 | ALTER TABLE person 4 | DROP COLUMN ban_expires; 5 | 6 | ALTER TABLE community_person_ban 7 | DROP COLUMN expires; 8 | 9 | CREATE VIEW person_alias_1 AS 10 | SELECT 11 | * 12 | FROM 13 | person; 14 | 15 | CREATE VIEW person_alias_2 AS 16 | SELECT 17 | * 18 | FROM 19 | person; 20 | 21 | -------------------------------------------------------------------------------- /migrations/2023-08-01-115243_persistent-activity-queue/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE sent_activity 2 | DROP COLUMN send_inboxes, 3 | DROP COLUMN send_community_followers_of, 4 | DROP COLUMN send_all_instances, 5 | DROP COLUMN actor_apub_id, 6 | DROP COLUMN actor_type; 7 | 8 | DROP TYPE actor_type_enum; 9 | 10 | DROP TABLE federation_queue_state; 11 | 12 | DROP INDEX idx_community_follower_published; 13 | 14 | -------------------------------------------------------------------------------- /scripts/update_schema_file.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" 5 | 6 | cd "$CWD/../" 7 | 8 | source scripts/start_dev_db.sh 9 | 10 | cargo run --package lemmy_diesel_utils --features full 11 | diesel print-schema >crates/db_schema_file/src/schema.rs 12 | cargo +nightly fmt --package lemmy_db_schema_file 13 | 14 | pg_ctl stop 15 | rm -rf $PGDATA 16 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000044_post_comment_pending/up.sql: -------------------------------------------------------------------------------- 1 | -- When posting to a remote community mark it as pending until it gets announced back to us. 2 | -- This way the posts of banned users wont appear in the community on other instances. 3 | ALTER TABLE post 4 | ADD COLUMN federation_pending boolean NOT NULL DEFAULT FALSE; 5 | 6 | ALTER TABLE comment 7 | ADD COLUMN federation_pending boolean NOT NULL DEFAULT FALSE; 8 | 9 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/community/report_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "to": ["http://enterprise.lemmy.ml/c/main"], 4 | "audience": "http://enterprise.lemmy.ml/u/main", 5 | "object": "http://enterprise.lemmy.ml/post/7", 6 | "summary": "report this post", 7 | "type": "Flag", 8 | "id": "http://ds9.lemmy.ml/activities/flag/98b0933f-5e45-4a95-a15f-e0dc86361ba4" 9 | } 10 | -------------------------------------------------------------------------------- /migrations/2022-01-28-104106_instance-actor/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | ADD COLUMN actor_id varchar(255) NOT NULL UNIQUE DEFAULT generate_unique_changeme (), 3 | ADD COLUMN last_refreshed_at timestamp NOT NULL DEFAULT now(), 4 | ADD COLUMN inbox_url varchar(255) NOT NULL DEFAULT generate_unique_changeme (), 5 | ADD COLUMN private_key text, 6 | ADD COLUMN public_key text NOT NULL DEFAULT generate_unique_changeme (); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2023-11-22-194806_low_rank_defaults/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community_aggregates 2 | ALTER COLUMN hot_rank SET DEFAULT 0.1728; 3 | 4 | ALTER TABLE comment_aggregates 5 | ALTER COLUMN hot_rank SET DEFAULT 0.1728; 6 | 7 | ALTER TABLE post_aggregates 8 | ALTER COLUMN hot_rank SET DEFAULT 0.1728, 9 | ALTER COLUMN hot_rank_active SET DEFAULT 0.1728, 10 | ALTER COLUMN scaled_rank SET DEFAULT 0.3621; 11 | 12 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000005_drop-enable-nsfw/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN enable_nsfw boolean NOT NULL DEFAULT TRUE; 3 | 4 | UPDATE 5 | local_site 6 | SET 7 | enable_nsfw = CASE WHEN site.content_warning IS NULL THEN 8 | FALSE 9 | ELSE 10 | TRUE 11 | END 12 | FROM 13 | site 14 | WHERE 15 | -- only local site has private key 16 | site.private_key IS NOT NULL; 17 | 18 | -------------------------------------------------------------------------------- /crates/api/api_common/src/search.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{ 2 | CommunitySortType, 3 | LikeType, 4 | PersonContentType, 5 | SearchSortType, 6 | SearchType, 7 | newtypes::SearchCombinedId, 8 | source::combined::search::SearchCombined, 9 | }; 10 | pub use lemmy_db_schema_file::enums::{CommentSortType, ListingType, PostSortType}; 11 | pub use lemmy_db_views_search_combined::{Search, SearchCombinedView, SearchResponse}; 12 | -------------------------------------------------------------------------------- /diesel.toml: -------------------------------------------------------------------------------- 1 | [print_schema] 2 | file = "crates/db_schema_file/src/schema.rs" 3 | patch_file = "crates/db_schema_file/diesel_ltree.patch" 4 | # Required for https://github.com/adwhit/diesel-derive-enum 5 | custom_type_derives = ["diesel::query_builder::QueryId"] 6 | # This table is in the lemmy_diesel_utils crate instead. 7 | filter = { except_tables = ["previously_run_sql"] } 8 | allow_tables_to_appear_in_same_query_config = "fk_related_tables" 9 | -------------------------------------------------------------------------------- /docker/test_deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | export COMPOSE_DOCKER_CLI_BUILD=1 5 | export DOCKER_BUILDKIT=1 6 | 7 | # Rebuilding dev docker 8 | pushd .. 9 | sudo docker build . -f docker/Dockerfile --build-arg RUST_RELEASE_MODE=release -t "dessalines/lemmy:dev" --platform=linux/amd64 --push 10 | 11 | # Run the playbook 12 | # pushd ../../../lemmy-ansible 13 | # ansible-playbook -i test playbooks/site.yml 14 | # popd 15 | -------------------------------------------------------------------------------- /migrations/2023-06-06-104440_index_post_url/up.sql: -------------------------------------------------------------------------------- 1 | -- Make a hard limit of 512 for the post.url column 2 | -- Truncate existing long rows. 3 | UPDATE 4 | post 5 | SET 6 | url = 7 | LEFT (url, 8 | 512) 9 | WHERE 10 | length(url) > 512; 11 | 12 | -- Enforce the limit 13 | ALTER TABLE post 14 | ALTER COLUMN url TYPE varchar(512); 15 | 16 | -- Add the index 17 | CREATE INDEX idx_post_url ON post (url); 18 | 19 | -------------------------------------------------------------------------------- /docker/federation/lemmy_beta.hjson: -------------------------------------------------------------------------------- 1 | { 2 | hostname: lemmy-beta:8551 3 | port: 8551 4 | tls_enabled: false 5 | setup: { 6 | admin_username: lemmy_beta 7 | admin_password: lemmylemmy 8 | site_name: lemmy-beta 9 | } 10 | database: { 11 | connection: "postgres://lemmy:password@postgres_beta:5432/lemmy" 12 | } 13 | pictrs: { 14 | api_key: "my-pictrs-key" 15 | image_mode: StoreLinkPreviews 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docker/federation/lemmy_gamma.hjson: -------------------------------------------------------------------------------- 1 | { 2 | hostname: lemmy-gamma:8561 3 | port: 8561 4 | tls_enabled: false 5 | setup: { 6 | admin_username: lemmy_gamma 7 | admin_password: lemmylemmy 8 | site_name: lemmy-gamma 9 | } 10 | database: { 11 | connection: "postgres://lemmy:password@postgres_gamma:5432/lemmy" 12 | } 13 | pictrs: { 14 | api_key: "my-pictrs-key" 15 | image_mode: ProxyAllImages 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /migrations/2023-08-31-205559_add_image_upload/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE image_upload ( 2 | id serial PRIMARY KEY, 3 | local_user_id int REFERENCES local_user ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 4 | pictrs_alias text NOT NULL UNIQUE, 5 | pictrs_delete_token text NOT NULL, 6 | published timestamptz DEFAULT now() NOT NULL 7 | ); 8 | 9 | CREATE INDEX idx_image_upload_local_user_id ON image_upload (local_user_id); 10 | 11 | -------------------------------------------------------------------------------- /api_tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "declarationDir": "./dist", 5 | "module": "CommonJS", 6 | "noImplicitAny": true, 7 | "lib": ["es2022", "es7", "es6", "dom"], 8 | "outDir": "./dist", 9 | "target": "ES2020", 10 | "strictNullChecks": true, 11 | "moduleResolution": "Node" 12 | }, 13 | "include": ["src/**/*"], 14 | "exclude": ["node_modules", "dist"] 15 | } 16 | -------------------------------------------------------------------------------- /docker/federation/lemmy_alpha.hjson: -------------------------------------------------------------------------------- 1 | { 2 | hostname: lemmy-alpha:8541 3 | port: 8541 4 | tls_enabled: false 5 | setup: { 6 | admin_username: lemmy_alpha 7 | admin_password: lemmylemmy 8 | site_name: lemmy-alpha 9 | } 10 | database: { 11 | connection: "postgres://lemmy:password@postgres_alpha:5432/lemmy" 12 | } 13 | pictrs: { 14 | api_key: "my-pictrs-key" 15 | image_mode: StoreLinkPreviews 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docker/federation/lemmy_delta.hjson: -------------------------------------------------------------------------------- 1 | { 2 | hostname: lemmy-delta:8571 3 | port: 8571 4 | tls_enabled: false 5 | setup: { 6 | admin_username: lemmy_delta 7 | admin_password: lemmylemmy 8 | site_name: lemmy-delta 9 | } 10 | database: { 11 | connection: "postgres://lemmy:password@postgres_delta:5432/lemmy" 12 | } 13 | pictrs: { 14 | api_key: "my-pictrs-key" 15 | image_mode: StoreLinkPreviews 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /migrations/2020-12-17-030456_create_alias_views/up.sql: -------------------------------------------------------------------------------- 1 | -- Some view that act as aliases 2 | -- unfortunately necessary, since diesel doesn't have self joins 3 | -- or alias support yet 4 | CREATE VIEW user_alias_1 AS 5 | SELECT 6 | * 7 | FROM 8 | user_; 9 | 10 | CREATE VIEW user_alias_2 AS 11 | SELECT 12 | * 13 | FROM 14 | user_; 15 | 16 | CREATE VIEW comment_alias_1 AS 17 | SELECT 18 | * 19 | FROM 20 | comment; 21 | 22 | -------------------------------------------------------------------------------- /migrations/2021-11-23-153753_add_invite_only_columns/down.sql: -------------------------------------------------------------------------------- 1 | -- Add columns to site table 2 | ALTER TABLE site 3 | DROP COLUMN require_application; 4 | 5 | ALTER TABLE site 6 | DROP COLUMN application_question; 7 | 8 | ALTER TABLE site 9 | DROP COLUMN private_instance; 10 | 11 | -- Add pending to local_user 12 | ALTER TABLE local_user 13 | DROP COLUMN accepted_application; 14 | 15 | DROP TABLE registration_application; 16 | 17 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/deletion/delete_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": "http://ds9.lemmy.ml/post/1", 5 | "cc": ["http://enterprise.lemmy.ml/c/main"], 6 | "audience": "https://enterprise.lemmy.ml/c/main", 7 | "type": "Delete", 8 | "id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12" 9 | } 10 | -------------------------------------------------------------------------------- /crates/api/api_common/src/custom_emoji.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{ 2 | newtypes::CustomEmojiId, 3 | source::{custom_emoji::CustomEmoji, custom_emoji_keyword::CustomEmojiKeyword}, 4 | }; 5 | pub use lemmy_db_views_custom_emoji::{ 6 | CustomEmojiView, 7 | api::{ 8 | CreateCustomEmoji, 9 | CustomEmojiResponse, 10 | DeleteCustomEmoji, 11 | EditCustomEmoji, 12 | ListCustomEmojis, 13 | ListCustomEmojisResponse, 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /crates/apub/apub/src/protocol/collections/group_followers.rs: -------------------------------------------------------------------------------- 1 | use activitypub_federation::kinds::collection::CollectionType; 2 | use serde::{Deserialize, Serialize}; 3 | use url::Url; 4 | 5 | #[derive(Clone, Debug, Deserialize, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub(crate) struct GroupFollowers { 8 | pub(crate) id: Url, 9 | pub(crate) r#type: CollectionType, 10 | pub(crate) total_items: i32, 11 | pub(crate) items: Vec<()>, 12 | } 13 | -------------------------------------------------------------------------------- /migrations/2023-08-01-101826_admin_flag_local_user/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person 2 | ADD COLUMN admin boolean DEFAULT FALSE NOT NULL; 3 | 4 | UPDATE 5 | person 6 | SET 7 | admin = TRUE 8 | FROM 9 | local_user 10 | WHERE 11 | local_user.person_id = person.id 12 | AND local_user.admin; 13 | 14 | ALTER TABLE local_user 15 | DROP COLUMN admin; 16 | 17 | CREATE INDEX idx_person_admin ON person (admin) 18 | WHERE 19 | admin; 20 | 21 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000012_no-individual-inboxes/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person 2 | ADD COLUMN shared_inbox_url varchar(255); 3 | 4 | ALTER TABLE person RENAME CONSTRAINT person_shared_inbox_url_not_null TO user__inbox_url_not_null; 5 | 6 | ALTER TABLE community 7 | DROP CONSTRAINT community_shared_inbox_url_not_null; 8 | 9 | ALTER TABLE community 10 | ADD COLUMN shared_inbox_url varchar(255), 11 | ALTER COLUMN inbox_url SET NOT NULL; 12 | 13 | -------------------------------------------------------------------------------- /crates/apub/apub/src/protocol/collections/url_collection.rs: -------------------------------------------------------------------------------- 1 | use activitypub_federation::kinds::collection::OrderedCollectionType; 2 | use serde::{Deserialize, Serialize}; 3 | use url::Url; 4 | 5 | #[derive(Serialize, Deserialize, Debug)] 6 | #[serde(rename_all = "camelCase")] 7 | pub(crate) struct UrlCollection { 8 | pub(crate) r#type: OrderedCollectionType, 9 | pub(crate) id: String, 10 | pub(crate) total_items: i32, 11 | pub(crate) ordered_items: Vec, 12 | } 13 | -------------------------------------------------------------------------------- /migrations/2020-12-10-152350_create_post_aggregates/down.sql: -------------------------------------------------------------------------------- 1 | -- post aggregates 2 | DROP TABLE post_aggregates; 3 | 4 | DROP TRIGGER post_aggregates_post ON post; 5 | 6 | DROP TRIGGER post_aggregates_comment_count ON comment; 7 | 8 | DROP TRIGGER post_aggregates_score ON post_like; 9 | 10 | DROP TRIGGER post_aggregates_stickied ON post; 11 | 12 | DROP FUNCTION post_aggregates_post, post_aggregates_comment_count, post_aggregates_score, post_aggregates_stickied; 13 | 14 | -------------------------------------------------------------------------------- /migrations/2023-07-26-222023_site-aggregates-one/down.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION site_aggregates_site () 2 | RETURNS TRIGGER 3 | LANGUAGE plpgsql 4 | AS $$ 5 | BEGIN 6 | IF (TG_OP = 'INSERT') THEN 7 | INSERT INTO site_aggregates (site_id) 8 | VALUES (NEW.id); 9 | ELSIF (TG_OP = 'DELETE') THEN 10 | DELETE FROM site_aggregates 11 | WHERE site_id = OLD.id; 12 | END IF; 13 | RETURN NULL; 14 | END 15 | $$; 16 | 17 | -------------------------------------------------------------------------------- /migrations/2024-07-01-014711_exponential_controversy/up.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | post_aggregates 3 | SET 4 | controversy_rank = (upvotes + downvotes) ^ CASE WHEN upvotes > downvotes THEN 5 | downvotes::float / upvotes::float 6 | ELSE 7 | upvotes::float / downvotes::float 8 | END 9 | WHERE 10 | upvotes > 0 11 | AND downvotes > 0 12 | -- a number divided by itself is 1, and `* 1` does the same thing as `^ 1` 13 | AND upvotes != downvotes; 14 | 15 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000013_comment-vote-remote-postid/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment_like 2 | ADD COLUMN post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE; 3 | 4 | UPDATE 5 | comment_like 6 | SET 7 | post_id = comment.post_id 8 | FROM 9 | comment 10 | WHERE 11 | comment_id = comment.id; 12 | 13 | ALTER TABLE comment_like 14 | ALTER COLUMN post_id SET NOT NULL; 15 | 16 | CREATE INDEX idx_comment_like_post ON comment_like (post_id); 17 | 18 | -------------------------------------------------------------------------------- /crates/db_views/notification/src/api.rs: -------------------------------------------------------------------------------- 1 | use lemmy_db_schema::newtypes::NotificationId; 2 | use serde::{Deserialize, Serialize}; 3 | 4 | #[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)] 5 | #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] 6 | #[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] 7 | /// Mark a comment reply as read. 8 | pub struct MarkNotificationAsRead { 9 | pub notification_id: NotificationId, 10 | pub read: bool, 11 | } 12 | -------------------------------------------------------------------------------- /migrations/2021-12-14-181537_add_temporary_bans/up.sql: -------------------------------------------------------------------------------- 1 | -- Add ban_expires to person, community_person_ban 2 | ALTER TABLE person 3 | ADD COLUMN ban_expires timestamp; 4 | 5 | ALTER TABLE community_person_ban 6 | ADD COLUMN expires timestamp; 7 | 8 | DROP VIEW person_alias_1, person_alias_2; 9 | 10 | CREATE VIEW person_alias_1 AS 11 | SELECT 12 | * 13 | FROM 14 | person; 15 | 16 | CREATE VIEW person_alias_2 AS 17 | SELECT 18 | * 19 | FROM 20 | person; 21 | 22 | -------------------------------------------------------------------------------- /migrations/2024-04-05-153647_alter_vote_display_mode_defaults/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user_vote_display_mode 2 | DROP COLUMN score, 3 | ADD COLUMN score boolean DEFAULT TRUE NOT NULL, 4 | DROP COLUMN upvotes, 5 | ADD COLUMN upvotes boolean DEFAULT FALSE NOT NULL, 6 | DROP COLUMN downvotes, 7 | ADD COLUMN downvotes boolean DEFAULT FALSE NOT NULL, 8 | DROP COLUMN upvote_percentage, 9 | ADD COLUMN upvote_percentage boolean DEFAULT TRUE NOT NULL; 10 | 11 | -------------------------------------------------------------------------------- /migrations/2023-07-06-151124_hot-rank-future/down.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION hot_rank (score numeric, published timestamp without time zone) 2 | RETURNS integer 3 | AS $$ 4 | BEGIN 5 | -- hours_diff:=EXTRACT(EPOCH FROM (timezone('utc',now()) - published))/3600 6 | RETURN floor(10000 * log(greatest (1, score + 3)) / power(((EXTRACT(EPOCH FROM (timezone('utc', now()) - published)) / 3600) + 2), 1.8))::integer; 7 | END; 8 | $$ 9 | LANGUAGE plpgsql 10 | IMMUTABLE; 11 | 12 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000058_instance_block_communities_persons/up.sql: -------------------------------------------------------------------------------- 1 | -- Currently, the instance.blocked_at columns only blocks communities from the given instance. 2 | -- 3 | -- This creates a new block type, to also be able to block persons. 4 | -- Also changes the name of blocked_at to blocked_communities_at 5 | ALTER TABLE instance_actions RENAME COLUMN blocked_at TO blocked_communities_at; 6 | 7 | ALTER TABLE instance_actions 8 | ADD COLUMN blocked_persons_at timestamptz; 9 | 10 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/community/lock_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://lemmy-alpha:8541/activities/lock/cb48761d-9e8c-42ce-aacb-b4bbe6408db2", 3 | "actor": "http://lemmy-alpha:8541/u/lemmy_alpha", 4 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 5 | "object": "http://lemmy-alpha:8541/post/2", 6 | "cc": ["http://lemmy-alpha:8541/c/main"], 7 | "type": "Lock", 8 | "summary": "A reason for the lock", 9 | "audience": "http://lemmy-alpha:8541/c/main" 10 | } 11 | -------------------------------------------------------------------------------- /migrations/2020-03-26-192410_add_activitypub_tables/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE activity; 2 | 3 | ALTER TABLE user_ 4 | DROP COLUMN actor_id, 5 | DROP COLUMN private_key, 6 | DROP COLUMN public_key, 7 | DROP COLUMN bio, 8 | DROP COLUMN local, 9 | DROP COLUMN last_refreshed_at; 10 | 11 | ALTER TABLE community 12 | DROP COLUMN actor_id, 13 | DROP COLUMN private_key, 14 | DROP COLUMN public_key, 15 | DROP COLUMN local, 16 | DROP COLUMN last_refreshed_at; 17 | 18 | -------------------------------------------------------------------------------- /migrations/2023-07-14-215339_aggregates_nonzero_indexes/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE INDEX idx_community_aggregates_nonzero_hotrank ON community_aggregates (published) 3 | WHERE 4 | hot_rank != 0; 5 | 6 | CREATE INDEX idx_comment_aggregates_nonzero_hotrank ON comment_aggregates (published) 7 | WHERE 8 | hot_rank != 0; 9 | 10 | CREATE INDEX idx_post_aggregates_nonzero_hotrank ON post_aggregates (published DESC) 11 | WHERE 12 | hot_rank != 0 OR hot_rank_active != 0; 13 | 14 | -------------------------------------------------------------------------------- /migrations/2024-07-01-014711_exponential_controversy/down.sql: -------------------------------------------------------------------------------- 1 | UPDATE 2 | post_aggregates 3 | SET 4 | controversy_rank = CASE WHEN downvotes <= 0 5 | OR upvotes <= 0 THEN 6 | 0 7 | ELSE 8 | (upvotes + downvotes) * CASE WHEN upvotes > downvotes THEN 9 | downvotes::float / upvotes::float 10 | ELSE 11 | upvotes::float / downvotes::float 12 | END 13 | END 14 | WHERE 15 | upvotes > 0 16 | AND downvotes > 0; 17 | 18 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000065_group-follow/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE community_community_follow ( 2 | target_id int REFERENCES community (id) ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 3 | community_id int REFERENCES community (id) ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 4 | published_at timestamptz NOT NULL DEFAULT now(), 5 | PRIMARY KEY (community_id, target_id) 6 | ); 7 | 8 | CREATE INDEX idx_community_community_follow_target ON community_community_follow (target_id); 9 | 10 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/deletion/remove_note.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": "http://ds9.lemmy.ml/comment/1", 5 | "cc": ["http://enterprise.lemmy.ml/c/main"], 6 | "audience": "https://enterprise.lemmy.ml/c/main", 7 | "type": "Delete", 8 | "summary": "bad comment", 9 | "id": "http://enterprise.lemmy.ml/activities/delete/42ca1a79-f99e-4518-a2ca-ba2df221eb5e" 10 | } 11 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/mastodon/activities/undo_like_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "id": "https://mastodon.madrid/users/felix#likes/212341/undo", 4 | "type": "Undo", 5 | "actor": "https://mastodon.madrid/users/felix", 6 | "object": { 7 | "id": "https://mastodon.madrid/users/felix#likes/212341", 8 | "type": "Like", 9 | "actor": "https://mastodon.madrid/users/felix", 10 | "object": "https://ds9.lemmy.ml/post/147" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/db_schema/src/source/secret.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "full")] 2 | use lemmy_db_schema_file::schema::secret; 3 | use lemmy_diesel_utils::sensitive::SensitiveString; 4 | 5 | #[derive(Clone)] 6 | #[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))] 7 | #[cfg_attr(feature = "full", diesel(table_name = secret))] 8 | #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] 9 | pub struct Secret { 10 | pub id: i32, 11 | pub jwt_secret: SensitiveString, 12 | } 13 | -------------------------------------------------------------------------------- /migrations/2022-01-04-034553_add_hidden_column/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | ADD COLUMN hidden boolean DEFAULT FALSE; 3 | 4 | CREATE TABLE mod_hide_community ( 5 | id serial PRIMARY KEY, 6 | community_id int REFERENCES community ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 7 | mod_person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 8 | when_ timestamp NOT NULL DEFAULT now(), 9 | reason text, 10 | hidden boolean DEFAULT FALSE 11 | ); 12 | 13 | -------------------------------------------------------------------------------- /migrations/2025-11-08-123111-0000_add_multi_community_subscribers_community_count/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_multi_community_lower_name; 2 | 3 | DROP INDEX idx_multi_community_subscribers; 4 | 5 | DROP INDEX idx_multi_community_subscribers_local; 6 | 7 | DROP INDEX idx_multi_community_communities; 8 | 9 | DROP INDEX idx_multi_community_published; 10 | 11 | ALTER TABLE multi_community 12 | DROP COLUMN subscribers, 13 | DROP COLUMN subscribers_local, 14 | DROP COLUMN communities; 15 | 16 | -------------------------------------------------------------------------------- /scripts/dump_schema.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # Dumps database schema, not including things that are added outside of migrations 5 | 6 | CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" 7 | 8 | cd "$CWD/../" 9 | 10 | source scripts/start_dev_db.sh 11 | 12 | cargo run --package lemmy_diesel_utils 13 | pg_dump --no-owner --no-privileges --no-table-access-method --schema-only --exclude-schema=r --no-sync -f schema.sqldump 14 | 15 | pg_ctl stop 16 | rm -rf $PGDATA 17 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/community/add_featured_post.json: -------------------------------------------------------------------------------- 1 | { 2 | "cc": ["https://ds9.lemmy.ml/c/main"], 3 | "id": "https://ds9.lemmy.ml/activities/add/47d911f5-52c5-4659-b2fd-0e58c451a427", 4 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 5 | "type": "Add", 6 | "actor": "https://ds9.lemmy.ml/u/lemmy_alpha", 7 | "object": "https://ds9.lemmy.ml/post/2", 8 | "target": "https://ds9.lemmy.ml/c/main/featured", 9 | "audience": "http://enterprise.lemmy.ml/u/main" 10 | } 11 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/community/remove_featured_post.json: -------------------------------------------------------------------------------- 1 | { 2 | "cc": ["https://ds9.lemmy.ml/c/main"], 3 | "id": "https://ds9.lemmy.ml/activities/add/47d911f5-52c5-4659-b2fd-0e58c451a427", 4 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 5 | "type": "Remove", 6 | "actor": "https://ds9.lemmy.ml/u/lemmy_alpha", 7 | "object": "https://ds9.lemmy.ml/post/2", 8 | "target": "https://ds9.lemmy.ml/c/main/featured", 9 | "audience": "https://ds9.lemmy.ml/c/main" 10 | } 11 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/objects/private_message.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "https://enterprise.lemmy.ml/private_message/1621", 3 | "type": "Note", 4 | "attributedTo": "https://enterprise.lemmy.ml/u/picard", 5 | "to": ["https://queer.hacktivis.me/users/lanodan"], 6 | "content": "

Hello hello, testing

\n", 7 | "mediaType": "text/html", 8 | "source": { 9 | "content": "Hello hello, testing", 10 | "mediaType": "text/markdown" 11 | }, 12 | "published": "2021-10-21T10:13:14.597721Z" 13 | } 14 | -------------------------------------------------------------------------------- /crates/db_schema/src/source/community_community_follow.rs: -------------------------------------------------------------------------------- 1 | use crate::newtypes::CommunityId; 2 | use lemmy_db_schema_file::schema::community_community_follow; 3 | 4 | #[derive(Clone, Debug, PartialEq, Queryable, Selectable)] 5 | #[diesel(belongs_to(crate::source::community::Community))] 6 | #[ diesel(table_name = community_community_follow)] 7 | #[diesel(check_for_backend(diesel::pg::Pg))] 8 | pub struct CommunityCommunityFollow { 9 | pub target_id: CommunityId, 10 | pub community_id: CommunityId, 11 | } 12 | -------------------------------------------------------------------------------- /migrations/2023-02-01-012747_fix_active_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_aggregates_featured_local_active, idx_post_aggregates_featured_community_active; 2 | 3 | CREATE INDEX idx_post_aggregates_featured_local_active ON post_aggregates (featured_local DESC, hot_rank (score, newest_comment_time) DESC, newest_comment_time DESC); 4 | 5 | CREATE INDEX idx_post_aggregates_featured_community_active ON post_aggregates (featured_community DESC, hot_rank (score, newest_comment_time) DESC, newest_comment_time DESC); 6 | 7 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/mastodon/activities/undo_follow.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "id": "https://masto.asonix.dog/users/asonix#follows/449/undo", 4 | "type": "Undo", 5 | "actor": "https://masto.asonix.dog/users/asonix", 6 | "object": { 7 | "id": "https://masto.asonix.dog/1ea87517-63c5-4118-8831-460ee641b2cf", 8 | "type": "Follow", 9 | "actor": "https://masto.asonix.dog/users/asonix", 10 | "object": "https://ds9.lemmy.ml/c/testcom" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /migrations/2022-09-07-113813_drop_ccnew_indexes_function/up.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION drop_ccnew_indexes () 2 | RETURNS integer 3 | AS $$ 4 | DECLARE 5 | i RECORD; 6 | BEGIN 7 | FOR i IN ( 8 | SELECT 9 | relname 10 | FROM 11 | pg_class 12 | WHERE 13 | relname LIKE '%ccnew%') 14 | LOOP 15 | EXECUTE 'DROP INDEX ' || i.relname; 16 | END LOOP; 17 | RETURN 1; 18 | END; 19 | $$ 20 | LANGUAGE plpgsql; 21 | 22 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/gnusocial/activities/like_note.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Like", 3 | "@context": ["https://www.w3.org/ns/activitystreams"], 4 | "id": "https://another_instance.gnusocial.test/activity/41362", 5 | "published": "2022-03-20T17:54:15+00:00", 6 | "actor": "https://another_instance.gnusocial.test/actor/43", 7 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 8 | "cc": ["https://instance.gnusocial.test/actor/42"], 9 | "object": "https://instance.gnusocial.test/object/note/1337" 10 | } 11 | -------------------------------------------------------------------------------- /scripts/lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" 5 | 6 | cd "$CWD/../" 7 | 8 | # Format rust files 9 | cargo +nightly fmt 10 | 11 | # Format toml files 12 | taplo format 13 | 14 | # Format sql files 15 | find migrations crates/diesel_utils/replaceable_schema -type f -name '*.sql' -print0 | xargs -0 -P 10 -L 10 pg_format -i 16 | 17 | cargo clippy --workspace --fix --allow-staged --allow-dirty --tests --all-targets --all-features -- -D warnings 18 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/community/add_mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": "http://ds9.lemmy.ml/u/lemmy_alpha", 5 | "target": "http://enterprise.lemmy.ml/c/main/moderators", 6 | "cc": ["http://enterprise.lemmy.ml/c/main"], 7 | "audience": "http://enterprise.lemmy.ml/u/main", 8 | "type": "Add", 9 | "id": "http://enterprise.lemmy.ml/activities/add/ec069147-77c3-447f-88c8-0ef1df10403f" 10 | } 11 | -------------------------------------------------------------------------------- /crates/apub/apub/src/protocol/collections/group_featured.rs: -------------------------------------------------------------------------------- 1 | use activitypub_federation::kinds::collection::OrderedCollectionType; 2 | use lemmy_apub_objects::protocol::page::Page; 3 | use serde::{Deserialize, Serialize}; 4 | use url::Url; 5 | 6 | #[derive(Clone, Debug, Deserialize, Serialize)] 7 | #[serde(rename_all = "camelCase")] 8 | pub struct GroupFeatured { 9 | pub(crate) r#type: OrderedCollectionType, 10 | pub(crate) id: Url, 11 | pub(crate) total_items: i64, 12 | pub(crate) ordered_items: Vec, 13 | } 14 | -------------------------------------------------------------------------------- /migrations/2021-11-23-132840_email_verification/down.sql: -------------------------------------------------------------------------------- 1 | -- revert defaults from db for local user init 2 | ALTER TABLE local_user 3 | ALTER COLUMN theme SET DEFAULT 'darkly'; 4 | 5 | ALTER TABLE local_user 6 | ALTER COLUMN default_listing_type SET DEFAULT 1; 7 | 8 | -- remove tables and columns for optional email verification 9 | ALTER TABLE site 10 | DROP COLUMN require_email_verification; 11 | 12 | ALTER TABLE local_user 13 | DROP COLUMN email_verified; 14 | 15 | DROP TABLE email_verification; 16 | 17 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000032_community_report/down.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM report_combined 2 | WHERE community_report_id IS NOT NULL; 3 | 4 | ALTER TABLE report_combined 5 | DROP CONSTRAINT report_combined_check, 6 | ADD CHECK (num_nonnulls (post_report_id, comment_report_id, private_message_report_id) = 1), 7 | DROP COLUMN community_report_id; 8 | 9 | DROP TABLE community_report CASCADE; 10 | 11 | ALTER TABLE community_aggregates 12 | DROP COLUMN report_count, 13 | DROP COLUMN unresolved_report_count; 14 | 15 | -------------------------------------------------------------------------------- /scripts/query_testing/views_to_diesel_migration/timings-2021-01-05_21-32-54.out: -------------------------------------------------------------------------------- 1 | comment.json: "Execution Time": 0.136 2 | community.json: "Execution Time": 0.157 3 | community_ordered_by_subscribers.json: "Execution Time": 16.036 4 | post.json: "Execution Time": 0.129 5 | post_ordered_by_rank.json: "Execution Time": 15.969 6 | private_message.json: "Execution Time": 0.133 7 | site.json: "Execution Time": 0.056 8 | user_.json: "Execution Time": 0.300 9 | user_mention.json: "Execution Time": 0.122 10 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/community/lock_note.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "https://lemmy-alpha/u/lemmy_aplha", 3 | "to": [ 4 | "https://lemmy-alpha/c/test", 5 | "https://www.w3.org/ns/activitystreams#Public" 6 | ], 7 | "object": "https://lemmy-alpha/comment/1", 8 | "cc": ["https://lemmy-alpha/c/test"], 9 | "type": "Lock", 10 | "id": "https://lemmy-alpha/activities/lock/ae02478a-c7fa-4cc9-9838-eae131d3e9fa", 11 | "summary": "A reason for a lock", 12 | "audience": "http://lemmy-alpha/c/main" 13 | } 14 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/mbin/activities/flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": ["https://www.w3.org/ns/activitystreams"], 3 | "id": "https://mbin-test1/reports/45f8a01d-a73e-4575-bffa-c9f24c61f458", 4 | "type": "Flag", 5 | "actor": "https://mbin-test1/u/BentiGorlich", 6 | "object": ["https://lemmy-test/post/4", "https://lemmy-test/u/BentiGorlich"], 7 | "audience": "https://lemmy-test/c/test_mag", 8 | "summary": "dikjhgasdpas dsaü", 9 | "content": "dikjhgasdpas dsaü", 10 | "to": ["https://lemmy-test/c/test_mag"] 11 | } 12 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/pleroma/objects/chat_message.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": [ 3 | "https://www.w3.org/ns/activitystreams", 4 | "https://queer.hacktivis.me/schemas/litepub-0.1.jsonld", 5 | { 6 | "@language": "und" 7 | } 8 | ], 9 | "attributedTo": "https://queer.hacktivis.me/users/lanodan", 10 | "content": "Hi!", 11 | "id": "https://queer.hacktivis.me/objects/2", 12 | "published": "2020-02-12T14:08:20Z", 13 | "to": ["https://enterprise.lemmy.ml/u/picard"], 14 | "type": "ChatMessage" 15 | } 16 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/community/remove_mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": "http://ds9.lemmy.ml/u/lemmy_alpha", 5 | "cc": ["http://enterprise.lemmy.ml/c/main"], 6 | "type": "Remove", 7 | "target": "http://enterprise.lemmy.ml/c/main/moderators", 8 | "audience": "http://enterprise.lemmy.ml/u/main", 9 | "id": "http://enterprise.lemmy.ml/activities/remove/aab114f8-cfbd-4935-a5b7-e1a64603650d" 10 | } 11 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/mastodon/activities/flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "id": "https://mastodon.example/ccb4f39a-506a-490e-9a8c-71831c7713a4", 4 | "type": "Flag", 5 | "actor": "https://mastodon.example/actor", 6 | "content": "Please take a look at this user and their posts", 7 | "object": [ 8 | "https://example.com/users/1", 9 | "https://example.com/posts/380590", 10 | "https://example.com/posts/380591" 11 | ], 12 | "to": "https://example.com/users/1" 13 | } 14 | -------------------------------------------------------------------------------- /migrations/2021-03-04-040229_clean_icon_urls/up.sql: -------------------------------------------------------------------------------- 1 | -- If these are not urls, it will crash the server 2 | UPDATE 3 | user_ 4 | SET 5 | avatar = NULL 6 | WHERE 7 | avatar NOT LIKE 'http%'; 8 | 9 | UPDATE 10 | user_ 11 | SET 12 | banner = NULL 13 | WHERE 14 | banner NOT LIKE 'http%'; 15 | 16 | UPDATE 17 | community 18 | SET 19 | icon = NULL 20 | WHERE 21 | icon NOT LIKE 'http%'; 22 | 23 | UPDATE 24 | community 25 | SET 26 | banner = NULL 27 | WHERE 28 | banner NOT LIKE 'http%'; 29 | 30 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000050_show_downvotes_for_others_only/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ALTER COLUMN show_downvotes DROP DEFAULT; 3 | 4 | ALTER TABLE local_user 5 | ALTER COLUMN show_downvotes TYPE boolean 6 | USING 7 | CASE show_downvotes 8 | WHEN 'Hide' THEN 9 | FALSE 10 | ELSE 11 | TRUE 12 | END; 13 | 14 | -- Make true the default 15 | ALTER TABLE local_user 16 | ALTER COLUMN show_downvotes SET DEFAULT TRUE; 17 | 18 | DROP TYPE vote_show_enum; 19 | 20 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/pleroma/activities/follow.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": [ 3 | "https://www.w3.org/ns/activitystreams", 4 | "https://mycrowd.ca/schemas/litepub-0.1.jsonld", 5 | { 6 | "@language": "und" 7 | } 8 | ], 9 | "actor": "https://mycrowd.ca/users/kinetix", 10 | "cc": [], 11 | "id": "https://mycrowd.ca/activities/dab6a4d3-0db0-41ee-8aab-7bfa4929b4fd", 12 | "object": "https://lemmy.ca/u/kinetix", 13 | "state": "pending", 14 | "to": ["https://lemmy.ca/u/kinetix"], 15 | "type": "Follow" 16 | } 17 | -------------------------------------------------------------------------------- /crates/diesel_utils/src/main.rs: -------------------------------------------------------------------------------- 1 | /// Very minimal wrapper around `lemmy_diesel_utils::run` to allow running migrations without 2 | /// compiling everything. 3 | fn main() -> anyhow::Result<()> { 4 | if std::env::args().len() > 1 { 5 | anyhow::bail!("To set parameters for running migrations, use the lemmy_server command."); 6 | } 7 | 8 | lemmy_diesel_utils::schema_setup::run( 9 | lemmy_diesel_utils::schema_setup::Options::default().run(), 10 | &std::env::var("LEMMY_DATABASE_URL")?, 11 | )?; 12 | 13 | Ok(()) 14 | } 15 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000005_drop-enable-nsfw/up.sql: -------------------------------------------------------------------------------- 1 | -- if site has enable_nsfw, set a default content warning 2 | UPDATE 3 | site 4 | SET 5 | content_warning = CASE WHEN local_site.enable_nsfw THEN 6 | 'NSFW' 7 | ELSE 8 | NULL 9 | END 10 | FROM 11 | local_site 12 | -- only local site has private key 13 | WHERE 14 | private_key IS NOT NULL 15 | -- dont overwrite existing content warning 16 | AND content_warning IS NOT NULL; 17 | 18 | ALTER TABLE local_site 19 | DROP enable_nsfw; 20 | 21 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/mbin/activities/accept.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "id": "https://some-mbin.instance/f/object/2721ffc3-f8a9-417e-a124-af057434a3af#accept", 4 | "type": "Accept", 5 | "actor": "https://some-mbin.instance/m/someMag", 6 | "object": { 7 | "id": "https://some-other.instance/f/object/c51ea652-e594-4920-a989-f5350f0cec05", 8 | "type": "Follow", 9 | "actor": "https://some-other.instance/u/someUser", 10 | "object": "https://some-mbin.instance/m/someMag" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /migrations/2020-01-11-012452_add_indexes/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_creator; 2 | 3 | DROP INDEX idx_post_community; 4 | 5 | DROP INDEX idx_post_like_post; 6 | 7 | DROP INDEX idx_post_like_user; 8 | 9 | DROP INDEX idx_comment_creator; 10 | 11 | DROP INDEX idx_comment_parent; 12 | 13 | DROP INDEX idx_comment_post; 14 | 15 | DROP INDEX idx_comment_like_comment; 16 | 17 | DROP INDEX idx_comment_like_user; 18 | 19 | DROP INDEX idx_comment_like_post; 20 | 21 | DROP INDEX idx_community_creator; 22 | 23 | DROP INDEX idx_community_category; 24 | 25 | -------------------------------------------------------------------------------- /migrations/2021-08-17-210508_create_mod_transfer_community/up.sql: -------------------------------------------------------------------------------- 1 | -- Add the mod_transfer_community log table 2 | CREATE TABLE mod_transfer_community ( 3 | id serial PRIMARY KEY, 4 | mod_person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 5 | other_person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 6 | community_id int REFERENCES community ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 7 | removed boolean DEFAULT FALSE, 8 | when_ timestamp NOT NULL DEFAULT now() 9 | ); 10 | 11 | -------------------------------------------------------------------------------- /migrations/2022-01-20-160328_remove_site_creator/down.sql: -------------------------------------------------------------------------------- 1 | -- Add the column back 2 | ALTER TABLE site 3 | ADD COLUMN creator_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE; 4 | 5 | -- Add the data, selecting the highest admin 6 | UPDATE 7 | site 8 | SET 9 | creator_id = sub.id 10 | FROM ( 11 | SELECT 12 | id 13 | FROM 14 | person 15 | WHERE 16 | admin = TRUE 17 | LIMIT 1) AS sub; 18 | 19 | -- Set to not null 20 | ALTER TABLE site 21 | ALTER COLUMN creator_id SET NOT NULL; 22 | 23 | -------------------------------------------------------------------------------- /migrations/2023-07-06-151124_hot-rank-future/up.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION hot_rank (score numeric, published timestamp without time zone) 2 | RETURNS integer 3 | AS $$ 4 | DECLARE 5 | hours_diff numeric := EXTRACT(EPOCH FROM (timezone('utc', now()) - published)) / 3600; 6 | BEGIN 7 | IF (hours_diff > 0) THEN 8 | RETURN floor(10000 * log(greatest (1, score + 3)) / power((hours_diff + 2), 1.8))::integer; 9 | ELSE 10 | RETURN 0; 11 | END IF; 12 | END; 13 | $$ 14 | LANGUAGE plpgsql 15 | IMMUTABLE PARALLEL SAFE; 16 | 17 | -------------------------------------------------------------------------------- /migrations/2023-07-24-232635_trigram-index/up.sql: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION IF NOT EXISTS pg_trgm; 2 | 3 | CREATE INDEX IF NOT EXISTS idx_comment_content_trigram ON comment USING gin (content gin_trgm_ops); 4 | 5 | CREATE INDEX IF NOT EXISTS idx_post_trigram ON post USING gin (name gin_trgm_ops, body gin_trgm_ops); 6 | 7 | CREATE INDEX IF NOT EXISTS idx_person_trigram ON person USING gin (name gin_trgm_ops, display_name gin_trgm_ops); 8 | 9 | CREATE INDEX IF NOT EXISTS idx_community_trigram ON community USING gin (name gin_trgm_ops, title gin_trgm_ops); 10 | 11 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lotide/objects/page.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "id": "https://narwhal.city/posts/9", 4 | "type": "Page", 5 | "name": "What's Dylan Grillin'? (reupload)", 6 | "to": "https://narwhal.city/communities/4", 7 | "attributedTo": "https://narwhal.city/users/1", 8 | "published": "2020-12-30T07:29:19.460932+00:00", 9 | "url": "https://www.youtube.com/watch?v=ZI4LGTXscR4", 10 | "summary": "What's Dylan Grillin'? (reupload)", 11 | "cc": "https://www.w3.org/ns/activitystreams#Public" 12 | } 13 | -------------------------------------------------------------------------------- /crates/apub/apub/src/protocol/collections/group_outbox.rs: -------------------------------------------------------------------------------- 1 | use activitypub_federation::kinds::collection::OrderedCollectionType; 2 | use lemmy_apub_activities::protocol::community::announce::AnnounceActivity; 3 | use serde::{Deserialize, Serialize}; 4 | use url::Url; 5 | 6 | #[derive(Clone, Debug, Deserialize, Serialize)] 7 | #[serde(rename_all = "camelCase")] 8 | pub struct GroupOutbox { 9 | pub(crate) r#type: OrderedCollectionType, 10 | pub(crate) id: Url, 11 | pub(crate) total_items: i32, 12 | pub(crate) ordered_items: Vec, 13 | } 14 | -------------------------------------------------------------------------------- /crates/db_views/local_user/src/api.rs: -------------------------------------------------------------------------------- 1 | use lemmy_diesel_utils::pagination::PaginationCursor; 2 | use serde::{Deserialize, Serialize}; 3 | use serde_with::skip_serializing_none; 4 | 5 | #[skip_serializing_none] 6 | #[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] 7 | #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] 8 | #[cfg_attr(feature = "ts-rs", ts(optional_fields, export))] 9 | pub struct AdminListUsers { 10 | pub banned_only: Option, 11 | pub page_cursor: Option, 12 | pub limit: Option, 13 | } 14 | -------------------------------------------------------------------------------- /crates/db_views/report_combined_sql/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lemmy_db_views_report_combined_sql" 3 | version.workspace = true 4 | edition.workspace = true 5 | description.workspace = true 6 | license.workspace = true 7 | homepage.workspace = true 8 | documentation.workspace = true 9 | repository.workspace = true 10 | rust-version.workspace = true 11 | 12 | [lib] 13 | doctest = false 14 | 15 | [lints] 16 | workspace = true 17 | 18 | [dependencies] 19 | lemmy_db_schema_file = { workspace = true, features = ["full"] } 20 | diesel = { workspace = true } 21 | -------------------------------------------------------------------------------- /migrations/2023-09-18-141700_login-token/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE login_token ( 2 | id serial PRIMARY KEY, 3 | token text NOT NULL UNIQUE, 4 | user_id int REFERENCES local_user ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 5 | published timestamptz NOT NULL DEFAULT now(), 6 | ip text, 7 | user_agent text 8 | ); 9 | 10 | CREATE INDEX idx_login_token_user_token ON login_token (user_id, token); 11 | 12 | -- not needed anymore as we invalidate login tokens on password change 13 | ALTER TABLE local_user 14 | DROP COLUMN validator_time; 15 | 16 | -------------------------------------------------------------------------------- /crates/apub/apub/src/protocol/collections/group_moderators.rs: -------------------------------------------------------------------------------- 1 | use activitypub_federation::{ 2 | fetch::object_id::ObjectId, 3 | kinds::collection::OrderedCollectionType, 4 | }; 5 | use lemmy_apub_objects::objects::person::ApubPerson; 6 | use serde::{Deserialize, Serialize}; 7 | use url::Url; 8 | 9 | #[derive(Clone, Debug, Deserialize, Serialize)] 10 | #[serde(rename_all = "camelCase")] 11 | pub struct GroupModerators { 12 | pub(crate) r#type: OrderedCollectionType, 13 | pub(crate) id: Url, 14 | pub(crate) ordered_items: Vec>, 15 | } 16 | -------------------------------------------------------------------------------- /crates/db_views/notification_sql/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lemmy_db_views_notification_sql" 3 | version.workspace = true 4 | edition.workspace = true 5 | description.workspace = true 6 | license.workspace = true 7 | homepage.workspace = true 8 | documentation.workspace = true 9 | repository.workspace = true 10 | rust-version.workspace = true 11 | publish = false 12 | 13 | [lib] 14 | doctest = false 15 | 16 | [lints] 17 | workspace = true 18 | 19 | [dependencies] 20 | lemmy_db_schema_file = { workspace = true, features = ["full"] } 21 | diesel = { workspace = true } 22 | -------------------------------------------------------------------------------- /migrations/2020-12-04-183345_create_community_aggregates/down.sql: -------------------------------------------------------------------------------- 1 | -- community aggregates 2 | DROP TABLE community_aggregates; 3 | 4 | DROP TRIGGER community_aggregates_community ON community; 5 | 6 | DROP TRIGGER community_aggregates_post_count ON post; 7 | 8 | DROP TRIGGER community_aggregates_comment_count ON comment; 9 | 10 | DROP TRIGGER community_aggregates_subscriber_count ON community_follower; 11 | 12 | DROP FUNCTION community_aggregates_community, community_aggregates_post_count, community_aggregates_comment_count, community_aggregates_subscriber_count; 13 | 14 | -------------------------------------------------------------------------------- /migrations/2021-01-27-202728_active_users_monthly/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site_aggregates 2 | DROP COLUMN users_active_day, 3 | DROP COLUMN users_active_week, 4 | DROP COLUMN users_active_month, 5 | DROP COLUMN users_active_half_year; 6 | 7 | ALTER TABLE community_aggregates 8 | DROP COLUMN users_active_day, 9 | DROP COLUMN users_active_week, 10 | DROP COLUMN users_active_month, 11 | DROP COLUMN users_active_half_year; 12 | 13 | DROP FUNCTION site_aggregates_activity (i text); 14 | 15 | DROP FUNCTION community_aggregates_activity (i text); 16 | 17 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000054_mod-change-community-vis/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_change_community_visibility 2 | ADD COLUMN reason text, 3 | ADD COLUMN visibility_new community_visibility; 4 | 5 | UPDATE 6 | mod_change_community_visibility 7 | SET 8 | visibility_new = visibility; 9 | 10 | ALTER TABLE mod_change_community_visibility 11 | DROP COLUMN visibility; 12 | 13 | ALTER TABLE mod_change_community_visibility RENAME COLUMN visibility_new TO visibility; 14 | 15 | ALTER TABLE mod_change_community_visibility 16 | ALTER COLUMN visibility SET NOT NULL; 17 | 18 | -------------------------------------------------------------------------------- /migrations/2020-12-03-035643_create_user_aggregates/down.sql: -------------------------------------------------------------------------------- 1 | -- User aggregates 2 | DROP TABLE user_aggregates; 3 | 4 | DROP TRIGGER user_aggregates_user ON user_; 5 | 6 | DROP TRIGGER user_aggregates_post_count ON post; 7 | 8 | DROP TRIGGER user_aggregates_post_score ON post_like; 9 | 10 | DROP TRIGGER user_aggregates_comment_count ON comment; 11 | 12 | DROP TRIGGER user_aggregates_comment_score ON comment_like; 13 | 14 | DROP FUNCTION user_aggregates_user, user_aggregates_post_count, user_aggregates_post_score, user_aggregates_comment_count, user_aggregates_comment_score; 15 | 16 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/following/undo_follow.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "to": ["http://enterprise.lemmy.ml/c/main"], 4 | "object": { 5 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 6 | "to": ["http://enterprise.lemmy.ml/c/main"], 7 | "object": "http://enterprise.lemmy.ml/c/main", 8 | "type": "Follow", 9 | "id": "http://ds9.lemmy.ml/activities/follow/dc2f1bc5-f3a0-4daa-a46b-428cbfbd023c" 10 | }, 11 | "type": "Undo", 12 | "id": "http://ds9.lemmy.ml/activities/undo/dd83c482-8ebd-4b6c-9008-c8373bd1a86a" 13 | } 14 | -------------------------------------------------------------------------------- /migrations/2021-03-31-105915_add_bot_account/up.sql: -------------------------------------------------------------------------------- 1 | -- Add the bot_account column to the person table 2 | DROP VIEW person_alias_1, person_alias_2; 3 | 4 | ALTER TABLE person 5 | ADD COLUMN bot_account boolean NOT NULL DEFAULT FALSE; 6 | 7 | CREATE VIEW person_alias_1 AS 8 | SELECT 9 | * 10 | FROM 11 | person; 12 | 13 | CREATE VIEW person_alias_2 AS 14 | SELECT 15 | * 16 | FROM 17 | person; 18 | 19 | -- Add the show_bot_accounts to the local user table as a setting 20 | ALTER TABLE local_user 21 | ADD COLUMN show_bot_accounts boolean NOT NULL DEFAULT TRUE; 22 | 23 | -------------------------------------------------------------------------------- /migrations/2023-07-19-163511_comment_sort_hot_rank_then_score/up.sql: -------------------------------------------------------------------------------- 1 | -- Alter the comment_aggregates hot sort to sort by score after hot_rank. 2 | -- Reason being, is that hot_ranks go to zero after a few days, 3 | -- and then comments should be sorted by score, not published. 4 | DROP INDEX idx_comment_aggregates_hot, idx_comment_aggregates_score; 5 | 6 | CREATE INDEX idx_comment_aggregates_hot ON comment_aggregates (hot_rank DESC, score DESC); 7 | 8 | -- Remove published from this sort, its pointless 9 | CREATE INDEX idx_comment_aggregates_score ON comment_aggregates (score DESC); 10 | 11 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/following/accept.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/c/main", 3 | "to": ["http://ds9.lemmy.ml/u/lemmy_alpha"], 4 | "object": { 5 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 6 | "to": ["http://enterprise.lemmy.ml/c/main"], 7 | "object": "http://enterprise.lemmy.ml/c/main", 8 | "type": "Follow", 9 | "id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866" 10 | }, 11 | "type": "Accept", 12 | "id": "http://enterprise.lemmy.ml/activities/accept/75f080cc-3d45-4654-8186-8f3bb853fa27" 13 | } 14 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/voting/undo_like_note.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "object": { 4 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 5 | "object": "http://ds9.lemmy.ml/comment/1", 6 | "audience": "https://enterprise.lemmy.ml/c/tenforward", 7 | "type": "Like", 8 | "id": "http://ds9.lemmy.ml/activities/like/efcf7ae2-dfcc-4ff4-9ce4-6adf251ff004" 9 | }, 10 | "audience": "https://enterprise.lemmy.ml/c/tenforward", 11 | "type": "Undo", 12 | "id": "http://ds9.lemmy.ml/activities/undo/3518565c-24a7-4d9e-8e0a-f7a2f45ac618" 13 | } 14 | -------------------------------------------------------------------------------- /migrations/2021-07-20-102033_actor_name_length/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW person_alias_1; 2 | 3 | DROP VIEW person_alias_2; 4 | 5 | ALTER TABLE community 6 | ALTER COLUMN name TYPE varchar(20); 7 | 8 | ALTER TABLE community 9 | ALTER COLUMN title TYPE varchar(100); 10 | 11 | ALTER TABLE person 12 | ALTER COLUMN name TYPE varchar(20); 13 | 14 | ALTER TABLE person 15 | ALTER COLUMN display_name TYPE varchar(20); 16 | 17 | CREATE VIEW person_alias_1 AS 18 | SELECT 19 | * 20 | FROM 21 | person; 22 | 23 | CREATE VIEW person_alias_2 AS 24 | SELECT 25 | * 26 | FROM 27 | person; 28 | 29 | -------------------------------------------------------------------------------- /migrations/2021-07-20-102033_actor_name_length/up.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW person_alias_1; 2 | 3 | DROP VIEW person_alias_2; 4 | 5 | ALTER TABLE community 6 | ALTER COLUMN name TYPE varchar(255); 7 | 8 | ALTER TABLE community 9 | ALTER COLUMN title TYPE varchar(255); 10 | 11 | ALTER TABLE person 12 | ALTER COLUMN name TYPE varchar(255); 13 | 14 | ALTER TABLE person 15 | ALTER COLUMN display_name TYPE varchar(255); 16 | 17 | CREATE VIEW person_alias_1 AS 18 | SELECT 19 | * 20 | FROM 21 | person; 22 | 23 | CREATE VIEW person_alias_2 AS 24 | SELECT 25 | * 26 | FROM 27 | person; 28 | 29 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/block/block_user.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": "http://ds9.lemmy.ml/u/lemmy_alpha", 5 | "cc": ["http://enterprise.lemmy.ml/c/main"], 6 | "audience": "http://enterprise.lemmy.ml/u/main", 7 | "target": "http://enterprise.lemmy.ml/c/main", 8 | "type": "Block", 9 | "removeData": true, 10 | "summary": "spam post", 11 | "endTime": "2021-11-01T12:23:50.151874Z", 12 | "id": "http://enterprise.lemmy.ml/activities/block/5d42fffb-0903-4625-86d4-0b39bb344fc2" 13 | } 14 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/tagline/list.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json, Query}; 2 | use lemmy_api_utils::context::LemmyContext; 3 | use lemmy_db_schema::source::tagline::Tagline; 4 | use lemmy_db_views_site::api::ListTaglines; 5 | use lemmy_diesel_utils::pagination::PagedResponse; 6 | use lemmy_utils::error::LemmyError; 7 | 8 | pub async fn list_taglines( 9 | Query(data): Query, 10 | context: Data, 11 | ) -> Result>, LemmyError> { 12 | let taglines = Tagline::list(&mut context.pool(), data.page_cursor, data.limit).await?; 13 | 14 | Ok(Json(taglines)) 15 | } 16 | -------------------------------------------------------------------------------- /migrations/2023-02-01-012747_fix_active_index/up.sql: -------------------------------------------------------------------------------- 1 | -- This should use the newest_comment_time_necro, not the newest_comment_time for the hot_rank 2 | DROP INDEX idx_post_aggregates_featured_local_active, idx_post_aggregates_featured_community_active; 3 | 4 | CREATE INDEX idx_post_aggregates_featured_local_active ON post_aggregates (featured_local DESC, hot_rank (score, newest_comment_time_necro) DESC, newest_comment_time_necro DESC); 5 | 6 | CREATE INDEX idx_post_aggregates_featured_community_active ON post_aggregates (featured_community DESC, hot_rank (score, newest_comment_time_necro) DESC, newest_comment_time_necro DESC); 7 | 8 | -------------------------------------------------------------------------------- /migrations/2024-05-05-162540_add_image_detail_table/up.sql: -------------------------------------------------------------------------------- 1 | -- Drop the id column from the remote_image table, just use link 2 | ALTER TABLE remote_image 3 | DROP COLUMN id, 4 | ADD PRIMARY KEY (link), 5 | DROP CONSTRAINT remote_image_link_key; 6 | 7 | -- No good way to do references here unfortunately, unless we combine the images tables 8 | -- The link should be the URL, not the pictrs_alias, to allow joining from post.thumbnail_url 9 | CREATE TABLE image_details ( 10 | link text PRIMARY KEY, 11 | width integer NOT NULL, 12 | height integer NOT NULL, 13 | content_type text NOT NULL 14 | ); 15 | 16 | -------------------------------------------------------------------------------- /scripts/db_perf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script runs crates/db_views/post/src/db_perf/mod.rs, which lets you see info related to database query performance, such as query plans. 4 | 5 | set -e 6 | 7 | CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" 8 | 9 | cd "$CWD/../" 10 | 11 | source scripts/start_dev_db.sh 12 | 13 | export LEMMY_CONFIG_LOCATION=$(pwd)/config/config.hjson 14 | export RUST_BACKTRACE=1 15 | 16 | cargo test -p lemmy_db_views_post --features full --no-fail-fast db_perf -- --nocapture 17 | 18 | pg_ctl stop --silent 19 | 20 | # $PGDATA directory is kept so log can be seen 21 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/voting/undo_dislike_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "object": { 4 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 5 | "object": "http://ds9.lemmy.ml/post/1", 6 | "type": "Like", 7 | "audience": "https://enterprise.lemmy.ml/c/tenforward", 8 | "id": "http://enterprise.lemmy.ml/activities/like/2227ab2c-79e2-4fca-a1d2-1d67dacf2457" 9 | }, 10 | "audience": "https://enterprise.lemmy.ml/c/tenforward", 11 | "type": "Undo", 12 | "id": "http://enterprise.lemmy.ml/activities/undo/6cc6fb71-39fe-49ea-9506-f0423b101e98" 13 | } 14 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000062_username-instance-unique/up.sql: -------------------------------------------------------------------------------- 1 | -- lemmy requires (username + instance_id) to be unique 2 | -- delete any existing duplicates 3 | DELETE FROM person p1 USING ( 4 | SELECT 5 | min(id) AS id, 6 | name, 7 | instance_id 8 | FROM 9 | person 10 | GROUP BY 11 | name, 12 | instance_id 13 | HAVING 14 | count(*) > 1) p2 15 | WHERE 16 | p1.name = p2.name 17 | AND p1.instance_id = p2.instance_id 18 | AND p1.id <> p2.id; 19 | 20 | ALTER TABLE person 21 | ADD CONSTRAINT person_name_instance_unique UNIQUE (name, instance_id); 22 | 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # local ansible configuration 2 | ansible/inventory 3 | ansible/passwords/ 4 | 5 | # docker build files 6 | docker/lemmy_mine.hjson 7 | docker/dev/env_deploy.sh 8 | docker/volumes 9 | 10 | # ide config 11 | .idea 12 | .vscode 13 | 14 | # local build files 15 | target 16 | env_setup.sh 17 | query_testing/**/reports/*.json 18 | 19 | # API tests 20 | api_tests/node_modules 21 | api_tests/.yalc 22 | api_tests/yalc.lock 23 | api_tests/pict-rs 24 | 25 | # pictrs data 26 | pictrs/ 27 | 28 | # The generated typescript bindings 29 | bindings 30 | 31 | # database dumps 32 | *.sqldump 33 | 34 | # diesel 35 | migrations/.diesel_lock 36 | -------------------------------------------------------------------------------- /crates/api/api/src/local_user/list_logins.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json}; 2 | use lemmy_api_utils::context::LemmyContext; 3 | use lemmy_db_schema::source::login_token::LoginToken; 4 | use lemmy_db_views_local_user::LocalUserView; 5 | use lemmy_db_views_site::api::ListLoginsResponse; 6 | use lemmy_utils::error::LemmyResult; 7 | 8 | pub async fn list_logins( 9 | context: Data, 10 | local_user_view: LocalUserView, 11 | ) -> LemmyResult> { 12 | let logins = LoginToken::list(&mut context.pool(), local_user_view.local_user.id).await?; 13 | 14 | Ok(Json(ListLoginsResponse { logins })) 15 | } 16 | -------------------------------------------------------------------------------- /migrations/2023-06-19-120700_no_double_deletion/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | CREATE OR REPLACE FUNCTION was_removed_or_deleted (TG_OP text, OLD record, NEW record) 3 | RETURNS boolean 4 | LANGUAGE plpgsql 5 | AS $$ 6 | BEGIN 7 | IF (TG_OP = 'INSERT') THEN 8 | RETURN FALSE; 9 | END IF; 10 | IF (TG_OP = 'DELETE') THEN 11 | RETURN TRUE; 12 | END IF; 13 | RETURN TG_OP = 'UPDATE' 14 | AND ((OLD.deleted = 'f' 15 | AND NEW.deleted = 't') 16 | OR (OLD.removed = 'f' 17 | AND NEW.removed = 't')); 18 | END 19 | $$; 20 | 21 | -------------------------------------------------------------------------------- /migrations/2024-04-05-153647_alter_vote_display_mode_defaults/up.sql: -------------------------------------------------------------------------------- 1 | -- Based on a poll, update the local_user_vote_display_mode defaults to: 2 | -- Upvotes + Downvotes 3 | -- Rather than 4 | -- Score + upvote_percentage 5 | ALTER TABLE local_user_vote_display_mode 6 | DROP COLUMN score, 7 | ADD COLUMN score boolean DEFAULT FALSE NOT NULL, 8 | DROP COLUMN upvotes, 9 | ADD COLUMN upvotes boolean DEFAULT TRUE NOT NULL, 10 | DROP COLUMN downvotes, 11 | ADD COLUMN downvotes boolean DEFAULT TRUE NOT NULL, 12 | DROP COLUMN upvote_percentage, 13 | ADD COLUMN upvote_percentage boolean DEFAULT FALSE NOT NULL; 14 | 15 | -------------------------------------------------------------------------------- /crates/api/api_crud/src/custom_emoji/list.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json, Query}; 2 | use lemmy_api_utils::context::LemmyContext; 3 | use lemmy_db_views_custom_emoji::{ 4 | CustomEmojiView, 5 | api::{ListCustomEmojis, ListCustomEmojisResponse}, 6 | }; 7 | use lemmy_utils::error::LemmyError; 8 | 9 | pub async fn list_custom_emojis( 10 | Query(data): Query, 11 | context: Data, 12 | ) -> Result, LemmyError> { 13 | let custom_emojis = CustomEmojiView::list(&mut context.pool(), &data.category).await?; 14 | 15 | Ok(Json(ListCustomEmojisResponse { custom_emojis })) 16 | } 17 | -------------------------------------------------------------------------------- /scripts/query_testing/views_old/timings-2021-01-05_21-06-37.out: -------------------------------------------------------------------------------- 1 | comment_fast_view.json: "Execution Time": 93.165 2 | comment_view.json: "Execution Time": 4513.485 3 | community_fast_view.json: "Execution Time": 3.998 4 | community_view.json: "Execution Time": 561.814 5 | post_fast_view.json: "Execution Time": 1604.543 6 | post_view.json: "Execution Time": 11630.471 7 | reply_fast_view.json: "Execution Time": 85.708 8 | site_view.json: "Execution Time": 27.264 9 | user_fast.json: "Execution Time": 0.135 10 | user_mention_fast_view.json: "Execution Time": 6.665 11 | user_mention_view.json: "Execution Time": 4996.688 12 | -------------------------------------------------------------------------------- /api_tests/run-federation-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432 5 | pushd .. 6 | cargo build 7 | rm target/lemmy_server || true 8 | cp target/debug/lemmy_server target/lemmy_server 9 | killall -s1 lemmy_server || true 10 | ./api_tests/prepare-drone-federation-test.sh 11 | popd 12 | 13 | pnpm i 14 | pnpm api-test || true 15 | 16 | killall -s1 lemmy_server || true 17 | killall -s1 pict-rs || true 18 | for INSTANCE in lemmy_alpha lemmy_beta lemmy_gamma lemmy_delta lemmy_epsilon; do 19 | psql "$LEMMY_DATABASE_URL" -c "DROP DATABASE $INSTANCE" 20 | done 21 | rm -r /tmp/pictrs 22 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/lemmy/activities/deletion/undo_delete_private_message.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "to": ["http://ds9.lemmy.ml/u/lemmy_alpha"], 4 | "object": { 5 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 6 | "to": ["http://enterprise.lemmy.ml/u/lemmy_beta"], 7 | "object": "http://enterprise.lemmy.ml/private_message/1", 8 | "type": "Delete", 9 | "id": "http://enterprise.lemmy.ml/activities/delete/616c41be-04ed-4bd4-b865-30712186b122" 10 | }, 11 | "type": "Undo", 12 | "id": "http://enterprise.lemmy.ml/activities/undo/35e5b337-014c-4bbe-8d63-6fac96f51409" 13 | } 14 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000066_modlog-rename/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE admin_ban RENAME TO mod_ban; 2 | 3 | ALTER TABLE admin_add RENAME TO mod_add; 4 | 5 | ALTER TABLE admin_remove_community RENAME TO mod_remove_community; 6 | 7 | ALTER TABLE mod_add_to_community RENAME TO mod_add_community; 8 | 9 | ALTER TABLE modlog_combined RENAME COLUMN admin_ban_id TO mod_ban_id; 10 | 11 | ALTER TABLE modlog_combined RENAME COLUMN admin_add_id TO mod_add_id; 12 | 13 | ALTER TABLE modlog_combined RENAME COLUMN admin_remove_community_id TO mod_remove_community_id; 14 | 15 | ALTER TABLE modlog_combined RENAME COLUMN mod_add_to_community_id TO mod_add_community_id; 16 | 17 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000066_modlog-rename/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_ban RENAME TO admin_ban; 2 | 3 | ALTER TABLE mod_add RENAME TO admin_add; 4 | 5 | ALTER TABLE mod_remove_community RENAME TO admin_remove_community; 6 | 7 | ALTER TABLE mod_add_community RENAME TO mod_add_to_community; 8 | 9 | ALTER TABLE modlog_combined RENAME COLUMN mod_ban_id TO admin_ban_id; 10 | 11 | ALTER TABLE modlog_combined RENAME COLUMN mod_add_id TO admin_add_id; 12 | 13 | ALTER TABLE modlog_combined RENAME COLUMN mod_remove_community_id TO admin_remove_community_id; 14 | 15 | ALTER TABLE modlog_combined RENAME COLUMN mod_add_community_id TO mod_add_to_community_id; 16 | 17 | -------------------------------------------------------------------------------- /crates/api/api/src/local_user/notifications/mark_all_read.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json}; 2 | use lemmy_api_utils::context::LemmyContext; 3 | use lemmy_db_schema::source::notification::Notification; 4 | use lemmy_db_views_local_user::LocalUserView; 5 | use lemmy_db_views_site::api::SuccessResponse; 6 | use lemmy_utils::error::LemmyResult; 7 | 8 | pub async fn mark_all_notifications_read( 9 | context: Data, 10 | local_user_view: LocalUserView, 11 | ) -> LemmyResult> { 12 | Notification::mark_all_as_read(&mut context.pool(), local_user_view.person.id).await?; 13 | 14 | Ok(Json(SuccessResponse::default())) 15 | } 16 | -------------------------------------------------------------------------------- /scripts/sql_format_check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # This check is only used for CI. 5 | 6 | CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" 7 | 8 | cd "$CWD/../" 9 | 10 | # Copy the files to a temp dir 11 | TMP_DIR=$(mktemp -d) 12 | cp -a migrations/. $TMP_DIR/migrations 13 | cp -a crates/diesel_utils/replaceable_schema/. $TMP_DIR/replaceable_schema 14 | 15 | # Format the new files 16 | find $TMP_DIR -type f -name '*.sql' -print0 | xargs -0 -P 10 -L 10 pg_format -i 17 | 18 | # Diff the directories 19 | diff -r migrations $TMP_DIR/migrations 20 | diff -r crates/diesel_utils/replaceable_schema $TMP_DIR/replaceable_schema 21 | -------------------------------------------------------------------------------- /crates/apub/activities/src/protocol/voting/undo_vote.rs: -------------------------------------------------------------------------------- 1 | use super::vote::Vote; 2 | use activitypub_federation::{fetch::object_id::ObjectId, kinds::activity::UndoType}; 3 | use lemmy_apub_objects::objects::{community::ApubCommunity, person::ApubPerson}; 4 | use serde::{Deserialize, Serialize}; 5 | use url::Url; 6 | 7 | #[derive(Clone, Debug, Deserialize, Serialize)] 8 | #[serde(rename_all = "camelCase")] 9 | pub struct UndoVote { 10 | pub(crate) actor: ObjectId, 11 | pub(crate) object: Vote, 12 | #[serde(rename = "type")] 13 | pub(crate) kind: UndoType, 14 | pub(crate) id: Url, 15 | pub(crate) audience: Option>, 16 | } 17 | -------------------------------------------------------------------------------- /docker/federation/lemmy_epsilon.hjson: -------------------------------------------------------------------------------- 1 | { 2 | hostname: lemmy-epsilon:8581 3 | port: 8581 4 | tls_enabled: false 5 | setup: { 6 | admin_username: lemmy_epsilon 7 | admin_password: lemmylemmy 8 | site_name: lemmy-epsilon 9 | } 10 | database: { 11 | connection: "postgres://lemmy:password@postgres_epsilon:5432/lemmy" 12 | } 13 | pictrs: { 14 | api_key: "my-pictrs-key" 15 | image_mode: ProxyAllImages 16 | } 17 | plugins: [{ 18 | file: "https://github.com/LemmyNet/lemmy-plugins/releases/download/0.1.1/go_replace_words.wasm" 19 | hash: "37cdc01a3ff26eef578b668c6cc57fc06649deddb3a92cb6bae8e79b4e60fe12" 20 | }] 21 | } 22 | -------------------------------------------------------------------------------- /migrations/2022-08-05-203502_add_person_post_aggregates/up.sql: -------------------------------------------------------------------------------- 1 | -- This table stores the # of read comments for a person, on a post 2 | -- It can then be joined to post_aggregates to get an unread count: 3 | -- unread = post_aggregates.comments - person_post_aggregates.read_comments 4 | CREATE TABLE person_post_aggregates ( 5 | id serial PRIMARY KEY, 6 | person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 7 | post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 8 | read_comments bigint NOT NULL DEFAULT 0, 9 | published timestamp NOT NULL DEFAULT now(), 10 | UNIQUE (person_id, post_id) 11 | ); 12 | 13 | -------------------------------------------------------------------------------- /crates/api/api/src/site/federated_instances.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json, Query}; 2 | use lemmy_api_utils::context::LemmyContext; 3 | use lemmy_db_views_site::{FederatedInstanceView, api::GetFederatedInstances}; 4 | use lemmy_diesel_utils::pagination::PagedResponse; 5 | use lemmy_utils::error::LemmyResult; 6 | 7 | pub async fn get_federated_instances( 8 | Query(data): Query, 9 | context: Data, 10 | ) -> LemmyResult>> { 11 | let federated_instances = FederatedInstanceView::list(&mut context.pool(), data).await?; 12 | 13 | // Return the jwt 14 | Ok(Json(federated_instances)) 15 | } 16 | -------------------------------------------------------------------------------- /crates/apub/activities/src/protocol/block/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod block_user; 2 | pub mod undo_block_user; 3 | 4 | #[cfg(test)] 5 | mod tests { 6 | use crate::protocol::block::{block_user::BlockUser, undo_block_user::UndoBlockUser}; 7 | use lemmy_apub_objects::utils::test::test_parse_lemmy_item; 8 | use lemmy_utils::error::LemmyResult; 9 | 10 | #[test] 11 | fn test_parse_lemmy_block() -> LemmyResult<()> { 12 | test_parse_lemmy_item::("../apub/assets/lemmy/activities/block/block_user.json")?; 13 | test_parse_lemmy_item::( 14 | "../apub/assets/lemmy/activities/block/undo_block_user.json", 15 | )?; 16 | Ok(()) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /crates/api/routes/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lemmy_api_routes" 3 | version.workspace = true 4 | edition.workspace = true 5 | description.workspace = true 6 | license.workspace = true 7 | homepage.workspace = true 8 | documentation.workspace = true 9 | repository.workspace = true 10 | rust-version.workspace = true 11 | publish = false 12 | 13 | [lib] 14 | doctest = false 15 | 16 | [lints] 17 | workspace = true 18 | 19 | [features] 20 | default = [] 21 | 22 | [dependencies] 23 | lemmy_api = { workspace = true } 24 | lemmy_api_crud = { workspace = true } 25 | lemmy_utils = { workspace = true } 26 | lemmy_routes = { workspace = true } 27 | actix-web = { workspace = true } 28 | -------------------------------------------------------------------------------- /crates/routes/src/images/mod.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::*; 2 | use lemmy_api_utils::context::LemmyContext; 3 | use lemmy_db_views_site::api::SuccessResponse; 4 | use lemmy_utils::error::LemmyResult; 5 | 6 | pub mod delete; 7 | pub mod download; 8 | pub mod upload; 9 | mod utils; 10 | 11 | pub async fn pictrs_health(context: Data) -> LemmyResult> { 12 | let pictrs_config = context.settings().pictrs()?; 13 | let url = format!("{}healthz", pictrs_config.url); 14 | 15 | context 16 | .pictrs_client() 17 | .get(url) 18 | .send() 19 | .await? 20 | .error_for_status()?; 21 | 22 | Ok(Json(SuccessResponse::default())) 23 | } 24 | -------------------------------------------------------------------------------- /migrations/2025-08-20-000000_comment-lock/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE modlog_combined 2 | DROP COLUMN mod_lock_comment_id, 3 | ADD CONSTRAINT modlog_combined_check CHECK (num_nonnulls (admin_allow_instance_id, admin_block_instance_id, admin_purge_comment_id, admin_purge_community_id, admin_purge_person_id, admin_purge_post_id, admin_add_id, mod_add_to_community_id, admin_ban_id, mod_ban_from_community_id, mod_feature_post_id, mod_change_community_visibility_id, mod_lock_post_id, mod_remove_comment_id, admin_remove_community_id, mod_remove_post_id, mod_transfer_community_id) = 1); 4 | 5 | DROP TABLE mod_lock_comment; 6 | 7 | ALTER TABLE comment 8 | DROP COLUMN LOCKED; 9 | 10 | -------------------------------------------------------------------------------- /migrations/2019-08-29-040006_add_community_count/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW site_view; 2 | 3 | CREATE VIEW site_view AS 4 | SELECT 5 | *, 6 | ( 7 | SELECT 8 | name 9 | FROM 10 | user_ u 11 | WHERE 12 | s.creator_id = u.id) AS creator_name, 13 | ( 14 | SELECT 15 | count(*) 16 | FROM 17 | user_) AS number_of_users, 18 | ( 19 | SELECT 20 | count(*) 21 | FROM 22 | post) AS number_of_posts, 23 | ( 24 | SELECT 25 | count(*) 26 | FROM 27 | comment) AS number_of_comments 28 | FROM 29 | site s; 30 | 31 | -------------------------------------------------------------------------------- /migrations/2022-11-21-204256_user-following/up.sql: -------------------------------------------------------------------------------- 1 | -- create user follower table with two references to persons 2 | CREATE TABLE person_follower ( 3 | id serial PRIMARY KEY, 4 | person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 5 | follower_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 6 | published timestamp NOT NULL DEFAULT now(), 7 | pending boolean NOT NULL, 8 | UNIQUE (follower_id, person_id) 9 | ); 10 | 11 | UPDATE 12 | community_follower 13 | SET 14 | pending = FALSE 15 | WHERE 16 | pending IS NULL; 17 | 18 | ALTER TABLE community_follower 19 | ALTER COLUMN pending SET NOT NULL; 20 | 21 | -------------------------------------------------------------------------------- /migrations/2025-09-08-140711_remove-actor-name-max-length/up.sql: -------------------------------------------------------------------------------- 1 | -- get rid of max name length setting 2 | ALTER TABLE local_site 3 | DROP COLUMN actor_name_max_length; 4 | 5 | -- truncate existing strings 6 | UPDATE 7 | person 8 | SET 9 | display_name = substring(display_name FROM 1 FOR 50) 10 | WHERE 11 | length(display_name) > 50; 12 | 13 | UPDATE 14 | community 15 | SET 16 | title = substring(title FROM 1 FOR 50) 17 | WHERE 18 | length(title) > 50; 19 | 20 | -- reduce max length of db columns 21 | ALTER TABLE person 22 | ALTER COLUMN display_name TYPE varchar(50); 23 | 24 | ALTER TABLE community 25 | ALTER COLUMN title TYPE varchar(50); 26 | 27 | -------------------------------------------------------------------------------- /migrations/2023-11-22-194806_low_rank_defaults/up.sql: -------------------------------------------------------------------------------- 1 | -- Change the hot_ranks to a miniscule number, so that new / fetched content 2 | -- won't crowd out existing content. 3 | -- 4 | -- They must be non-zero, in order for them to be picked up by the hot_ranks updater. 5 | -- See https://github.com/LemmyNet/lemmy/issues/4178 6 | ALTER TABLE community_aggregates 7 | ALTER COLUMN hot_rank SET DEFAULT 0.0001; 8 | 9 | ALTER TABLE comment_aggregates 10 | ALTER COLUMN hot_rank SET DEFAULT 0.0001; 11 | 12 | ALTER TABLE post_aggregates 13 | ALTER COLUMN hot_rank SET DEFAULT 0.0001, 14 | ALTER COLUMN hot_rank_active SET DEFAULT 0.0001, 15 | ALTER COLUMN scaled_rank SET DEFAULT 0.0001; 16 | 17 | -------------------------------------------------------------------------------- /migrations/2025-08-01-000006_default_comment_sort_type/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | -- Rename the post sort enum 3 | ALTER TYPE post_sort_type_enum RENAME TO sort_type_enum; 4 | 5 | -- Rename the default post sort columns 6 | ALTER TABLE local_user RENAME COLUMN default_post_sort_type TO default_sort_type; 7 | 8 | ALTER TABLE local_site RENAME COLUMN default_post_sort_type TO default_sort_type; 9 | 10 | -- Create the comment sort type enum 11 | ALTER TABLE local_user 12 | DROP COLUMN default_comment_sort_type; 13 | 14 | ALTER TABLE local_site 15 | DROP COLUMN default_comment_sort_type; 16 | 17 | -- Drop the comment enum 18 | DROP TYPE comment_sort_type_enum; 19 | 20 | -------------------------------------------------------------------------------- /migrations/2025-10-09-101527-0000_community-follower-denied/down.sql: -------------------------------------------------------------------------------- 1 | -- revert change to community follow state enum 2 | ALTER TYPE community_follower_state RENAME TO community_follower_state__; 3 | 4 | CREATE TYPE community_follower_state AS ENUM ( 5 | 'Accepted', 6 | 'Pending', 7 | 'ApprovalRequired' 8 | ); 9 | 10 | ALTER TABLE community_actions 11 | ALTER COLUMN follow_state TYPE community_follower_state 12 | USING follow_state::text::community_follower_state; 13 | 14 | ALTER TABLE multi_community_follow 15 | ALTER COLUMN follow_state TYPE community_follower_state 16 | USING follow_state::text::community_follower_state; 17 | 18 | DROP TYPE community_follower_state__; 19 | 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/QUESTION.yml: -------------------------------------------------------------------------------- 1 | name: "? Question" 2 | description: General questions about Lemmy 3 | title: "Question: " 4 | labels: ["question", "triage"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | For questions or discussions use https://lemmy.ml/c/lemmy_support or the [matrix chat](https://matrix.to/#/#lemmy:matrix.org). 10 | 11 | Have a question about how Lemmy works? 12 | Please check the docs first: https://join-lemmy.org/docs/en/index.html 13 | - type: textarea 14 | id: question 15 | attributes: 16 | label: Question 17 | description: What's the question you have about Lemmy? 18 | validations: 19 | required: true 20 | -------------------------------------------------------------------------------- /crates/apub/apub/assets/peertube/activities/announce_video.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": [ 3 | "https://www.w3.org/ns/activitystreams", 4 | "https://w3id.org/security/v1", 5 | { 6 | "RsaSignature2017": "https://w3id.org/security#RsaSignature2017" 7 | } 8 | ], 9 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 10 | "cc": ["https://tilvids.com/accounts/thelinuxexperiment/followers"], 11 | "type": "Announce", 12 | "id": "https://tilvids.com/videos/watch/e7946124-7b72-4ad7-9d22-844a84bb2de1/announces/299", 13 | "actor": "https://tilvids.com/video-channels/thelinuxexperiment_channel", 14 | "object": "https://tilvids.com/videos/watch/e7946124-7b72-4ad7-9d22-844a84bb2de1" 15 | } 16 | -------------------------------------------------------------------------------- /crates/utils/src/cache_header.rs: -------------------------------------------------------------------------------- 1 | use actix_web::middleware::DefaultHeaders; 2 | 3 | /// Adds a cache header to requests 4 | /// 5 | /// Common cache amounts are: 6 | /// * 1 hour = 60s * 60m = `3600` seconds 7 | /// * 3 days = 60s * 60m * 24h * 3d = `259200` seconds 8 | /// 9 | /// Mastodon & other activitypub server defaults to 3d 10 | fn cache_header(seconds: usize) -> DefaultHeaders { 11 | DefaultHeaders::new().add(("Cache-Control", format!("public, max-age={seconds}"))) 12 | } 13 | 14 | /// Set a 1 hour cache time 15 | pub fn cache_1hour() -> DefaultHeaders { 16 | cache_header(3600) 17 | } 18 | 19 | /// Set a 3 day cache time 20 | pub fn cache_3days() -> DefaultHeaders { 21 | cache_header(259200) 22 | } 23 | -------------------------------------------------------------------------------- /migrations/2023-11-07-135409_inbox_unique/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person 2 | ADD CONSTRAINT idx_person_inbox_url UNIQUE (inbox_url); 3 | 4 | ALTER TABLE community 5 | ADD CONSTRAINT idx_community_inbox_url UNIQUE (inbox_url); 6 | 7 | UPDATE 8 | site 9 | SET 10 | inbox_url = inbox_query.inbox 11 | FROM ( 12 | SELECT 13 | format('https://%s/site_inbox', DOMAIN) AS inbox 14 | FROM 15 | instance, 16 | site, 17 | local_site 18 | WHERE 19 | instance.id = site.instance_id 20 | AND local_site.id = site.id) AS inbox_query, 21 | instance, 22 | local_site 23 | WHERE 24 | instance.id = site.instance_id 25 | AND local_site.id = site.id; 26 | 27 | -------------------------------------------------------------------------------- /crates/api/api_common/src/comment.rs: -------------------------------------------------------------------------------- 1 | pub use lemmy_db_schema::{ 2 | newtypes::CommentId, 3 | source::comment::{Comment, CommentActions, CommentInsertForm}, 4 | }; 5 | pub use lemmy_db_views_comment::{ 6 | CommentSlimView, 7 | CommentView, 8 | api::{CommentResponse, GetComment, GetComments}, 9 | }; 10 | 11 | pub mod actions { 12 | pub use lemmy_db_views_comment::api::{ 13 | CreateComment, 14 | CreateCommentLike, 15 | DeleteComment, 16 | EditComment, 17 | SaveComment, 18 | }; 19 | 20 | pub mod moderation { 21 | pub use lemmy_db_views_comment::api::{ 22 | DistinguishComment, 23 | ListCommentLikes, 24 | PurgeComment, 25 | RemoveComment, 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /migrations/2021-11-22-135324_add_activity_ap_id_index/up.sql: -------------------------------------------------------------------------------- 1 | -- Delete the empty ap_ids 2 | DELETE FROM activity 3 | WHERE ap_id IS NULL; 4 | 5 | -- Make it required 6 | ALTER TABLE activity 7 | ALTER COLUMN ap_id SET NOT NULL; 8 | 9 | -- Delete dupes, keeping the first one 10 | DELETE FROM activity a USING ( 11 | SELECT 12 | min(id) AS id, 13 | ap_id 14 | FROM 15 | activity 16 | GROUP BY 17 | ap_id 18 | HAVING 19 | count(*) > 1) b 20 | WHERE 21 | a.ap_id = b.ap_id 22 | AND a.id <> b.id; 23 | 24 | -- The index 25 | CREATE UNIQUE INDEX idx_activity_ap_id ON activity (ap_id); 26 | 27 | -- Drop the old index 28 | DROP INDEX idx_activity_unique_apid; 29 | 30 | -------------------------------------------------------------------------------- /migrations/2023-10-02-145002_community_followers_count_federated/down.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION community_aggregates_subscriber_count () 2 | RETURNS TRIGGER 3 | LANGUAGE plpgsql 4 | AS $$ 5 | BEGIN 6 | IF (TG_OP = 'INSERT') THEN 7 | UPDATE 8 | community_aggregates 9 | SET 10 | subscribers = subscribers + 1 11 | WHERE 12 | community_id = NEW.community_id; 13 | ELSIF (TG_OP = 'DELETE') THEN 14 | UPDATE 15 | community_aggregates 16 | SET 17 | subscribers = subscribers - 1 18 | WHERE 19 | community_id = OLD.community_id; 20 | END IF; 21 | RETURN NULL; 22 | END 23 | $$; 24 | 25 | --------------------------------------------------------------------------------