├── .dockerignore ├── .gitattributes ├── .github ├── CODEOWNERS ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.yml │ ├── FEATURE_REQUEST.yml │ └── QUESTION.yml └── SECURITY.md ├── .gitignore ├── .gitmodules ├── .rustfmt.toml ├── .woodpecker.yml ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── api_tests ├── .npmrc ├── .prettierrc.json ├── eslint.config.mjs ├── jest.config.js ├── package.json ├── plugins │ └── go_replace_words.json ├── pnpm-lock.yaml ├── prepare-drone-federation-test.sh ├── run-federation-test.sh ├── src │ ├── comment.spec.ts │ ├── community.spec.ts │ ├── follow.spec.ts │ ├── image.spec.ts │ ├── post.spec.ts │ ├── private_community.spec.ts │ ├── private_message.spec.ts │ ├── shared.ts │ ├── tags.spec.ts │ └── user.spec.ts └── tsconfig.json ├── cliff.toml ├── config ├── config.hjson └── defaults.hjson ├── crates ├── api │ ├── Cargo.toml │ └── src │ │ ├── comment │ │ ├── distinguish.rs │ │ ├── like.rs │ │ ├── list_comment_likes.rs │ │ ├── mod.rs │ │ └── save.rs │ │ ├── community │ │ ├── add_mod.rs │ │ ├── ban.rs │ │ ├── block.rs │ │ ├── follow.rs │ │ ├── mod.rs │ │ ├── pending_follows │ │ │ ├── approve.rs │ │ │ ├── count.rs │ │ │ ├── list.rs │ │ │ └── mod.rs │ │ ├── random.rs │ │ ├── tag.rs │ │ └── transfer.rs │ │ ├── lib.rs │ │ ├── local_user │ │ ├── add_admin.rs │ │ ├── ban_person.rs │ │ ├── block.rs │ │ ├── change_password.rs │ │ ├── change_password_after_reset.rs │ │ ├── donation_dialog_shown.rs │ │ ├── generate_totp_secret.rs │ │ ├── get_captcha.rs │ │ ├── list_hidden.rs │ │ ├── list_liked.rs │ │ ├── list_logins.rs │ │ ├── list_media.rs │ │ ├── list_read.rs │ │ ├── list_saved.rs │ │ ├── login.rs │ │ ├── logout.rs │ │ ├── mod.rs │ │ ├── notifications │ │ │ ├── list_inbox.rs │ │ │ ├── mark_all_read.rs │ │ │ ├── mark_comment_mention_read.rs │ │ │ ├── mark_post_mention_read.rs │ │ │ ├── mark_reply_read.rs │ │ │ ├── mod.rs │ │ │ └── unread_count.rs │ │ ├── report_count.rs │ │ ├── resend_verification_email.rs │ │ ├── reset_password.rs │ │ ├── save_settings.rs │ │ ├── update_totp.rs │ │ ├── user_block_instance.rs │ │ ├── validate_auth.rs │ │ └── verify_email.rs │ │ ├── post │ │ ├── feature.rs │ │ ├── get_link_metadata.rs │ │ ├── hide.rs │ │ ├── like.rs │ │ ├── list_post_likes.rs │ │ ├── lock.rs │ │ ├── mark_many_read.rs │ │ ├── mark_read.rs │ │ ├── mod.rs │ │ └── save.rs │ │ ├── private_message │ │ ├── mark_read.rs │ │ └── mod.rs │ │ ├── reports │ │ ├── comment_report │ │ │ ├── create.rs │ │ │ ├── mod.rs │ │ │ └── resolve.rs │ │ ├── community_report │ │ │ ├── create.rs │ │ │ ├── mod.rs │ │ │ └── resolve.rs │ │ ├── mod.rs │ │ ├── post_report │ │ │ ├── create.rs │ │ │ ├── mod.rs │ │ │ └── resolve.rs │ │ ├── private_message_report │ │ │ ├── create.rs │ │ │ ├── mod.rs │ │ │ └── resolve.rs │ │ └── report_combined │ │ │ ├── list.rs │ │ │ └── mod.rs │ │ ├── site │ │ ├── admin_allow_instance.rs │ │ ├── admin_block_instance.rs │ │ ├── admin_list_users.rs │ │ ├── federated_instances.rs │ │ ├── leave_admin.rs │ │ ├── list_all_media.rs │ │ ├── mod.rs │ │ ├── mod_log.rs │ │ ├── purge │ │ │ ├── comment.rs │ │ │ ├── community.rs │ │ │ ├── mod.rs │ │ │ ├── person.rs │ │ │ └── post.rs │ │ └── registration_applications │ │ │ ├── approve.rs │ │ │ ├── get.rs │ │ │ ├── list.rs │ │ │ ├── mod.rs │ │ │ ├── tests.rs │ │ │ └── unread_count.rs │ │ └── sitemap.rs ├── api_common │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── build_response.rs │ │ ├── claims.rs │ │ ├── comment.rs │ │ ├── community.rs │ │ ├── context.rs │ │ ├── custom_emoji.rs │ │ ├── image.rs │ │ ├── lib.rs │ │ ├── oauth_provider.rs │ │ ├── person.rs │ │ ├── plugins.rs │ │ ├── post.rs │ │ ├── private_message.rs │ │ ├── reports │ │ ├── combined.rs │ │ ├── comment.rs │ │ ├── community.rs │ │ ├── mod.rs │ │ ├── post.rs │ │ └── private_message.rs │ │ ├── request.rs │ │ ├── send_activity.rs │ │ ├── site.rs │ │ ├── tagline.rs │ │ ├── tags.rs │ │ └── utils.rs ├── api_crud │ ├── Cargo.toml │ └── src │ │ ├── comment │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── mod.rs │ │ ├── read.rs │ │ ├── remove.rs │ │ └── update.rs │ │ ├── community │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── list.rs │ │ ├── mod.rs │ │ ├── remove.rs │ │ └── update.rs │ │ ├── custom_emoji │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── list.rs │ │ ├── mod.rs │ │ └── update.rs │ │ ├── lib.rs │ │ ├── oauth_provider │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── mod.rs │ │ └── update.rs │ │ ├── post │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── mod.rs │ │ ├── read.rs │ │ ├── remove.rs │ │ └── update.rs │ │ ├── private_message │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── mod.rs │ │ └── update.rs │ │ ├── site │ │ ├── create.rs │ │ ├── mod.rs │ │ ├── read.rs │ │ └── update.rs │ │ ├── tagline │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── list.rs │ │ ├── mod.rs │ │ └── update.rs │ │ └── user │ │ ├── create.rs │ │ ├── delete.rs │ │ ├── mod.rs │ │ └── my_user.rs ├── apub │ ├── Cargo.toml │ ├── assets │ │ ├── discourse │ │ │ └── objects │ │ │ │ ├── group.json │ │ │ │ ├── page.json │ │ │ │ └── person.json │ │ ├── friendica │ │ │ ├── activities │ │ │ │ ├── create_note.json │ │ │ │ ├── create_page_1.json │ │ │ │ ├── create_page_2.json │ │ │ │ ├── delete.json │ │ │ │ ├── dislike_page.json │ │ │ │ ├── like_page.json │ │ │ │ ├── undo_dislike_page.json │ │ │ │ └── update_note.json │ │ │ └── objects │ │ │ │ ├── note_1.json │ │ │ │ ├── note_2.json │ │ │ │ ├── page_1.json │ │ │ │ ├── page_2.json │ │ │ │ ├── person_1.json │ │ │ │ └── person_2.json │ │ ├── gnusocial │ │ │ ├── activities │ │ │ │ ├── create_note.json │ │ │ │ ├── create_page.json │ │ │ │ └── like_note.json │ │ │ └── objects │ │ │ │ ├── group.json │ │ │ │ ├── note.json │ │ │ │ ├── page.json │ │ │ │ └── person.json │ │ ├── lemmy │ │ │ ├── activities │ │ │ │ ├── block │ │ │ │ │ ├── block_user.json │ │ │ │ │ └── undo_block_user.json │ │ │ │ ├── community │ │ │ │ │ ├── add_featured_post.json │ │ │ │ │ ├── add_mod.json │ │ │ │ │ ├── announce_create_page.json │ │ │ │ │ ├── lock_page.json │ │ │ │ │ ├── remove_featured_post.json │ │ │ │ │ ├── remove_mod.json │ │ │ │ │ ├── report_page.json │ │ │ │ │ ├── resolve_report_page.json │ │ │ │ │ ├── undo_lock_page.json │ │ │ │ │ └── update_community.json │ │ │ │ ├── create_or_update │ │ │ │ │ ├── create_comment.json │ │ │ │ │ ├── create_page.json │ │ │ │ │ ├── create_private_message.json │ │ │ │ │ └── update_page.json │ │ │ │ ├── deletion │ │ │ │ │ ├── delete_page.json │ │ │ │ │ ├── delete_private_message.json │ │ │ │ │ ├── delete_user.json │ │ │ │ │ ├── remove_note.json │ │ │ │ │ ├── undo_delete_page.json │ │ │ │ │ ├── undo_delete_private_message.json │ │ │ │ │ └── undo_remove_note.json │ │ │ │ ├── following │ │ │ │ │ ├── accept.json │ │ │ │ │ ├── follow.json │ │ │ │ │ └── undo_follow.json │ │ │ │ └── voting │ │ │ │ │ ├── dislike_page.json │ │ │ │ │ ├── like_note.json │ │ │ │ │ ├── undo_dislike_page.json │ │ │ │ │ └── undo_like_note.json │ │ │ ├── collections │ │ │ │ ├── group_featured_posts.json │ │ │ │ ├── group_followers.json │ │ │ │ ├── group_moderators.json │ │ │ │ ├── group_outbox.json │ │ │ │ └── person_outbox.json │ │ │ └── objects │ │ │ │ ├── comment.json │ │ │ │ ├── group.json │ │ │ │ ├── instance.json │ │ │ │ ├── page.json │ │ │ │ ├── person.json │ │ │ │ ├── private_message.json │ │ │ │ └── tombstone.json │ │ ├── lotide │ │ │ ├── activities │ │ │ │ ├── create_note_reply.json │ │ │ │ ├── create_page.json │ │ │ │ ├── create_page_image.json │ │ │ │ ├── delete_note.json │ │ │ │ └── follow.json │ │ │ └── objects │ │ │ │ ├── group.json │ │ │ │ ├── note.json │ │ │ │ ├── page.json │ │ │ │ ├── person.json │ │ │ │ └── tombstone.json │ │ ├── mastodon │ │ │ ├── activities │ │ │ │ ├── create_note.json │ │ │ │ ├── delete.json │ │ │ │ ├── flag.json │ │ │ │ ├── follow.json │ │ │ │ ├── like_page.json │ │ │ │ ├── private_message.json │ │ │ │ ├── undo_follow.json │ │ │ │ └── undo_like_page.json │ │ │ ├── collections │ │ │ │ └── featured.json │ │ │ └── objects │ │ │ │ ├── note_1.json │ │ │ │ ├── note_2.json │ │ │ │ ├── page.json │ │ │ │ └── person.json │ │ ├── mbin │ │ │ └── activities │ │ │ │ ├── accept.json │ │ │ │ └── flag.json │ │ ├── mobilizon │ │ │ └── objects │ │ │ │ ├── event.json │ │ │ │ ├── group.json │ │ │ │ └── person.json │ │ ├── nodebb │ │ │ └── objects │ │ │ │ ├── group.json │ │ │ │ ├── page.json │ │ │ │ └── person.json │ │ ├── peertube │ │ │ ├── activities │ │ │ │ └── announce_video.json │ │ │ └── objects │ │ │ │ ├── group.json │ │ │ │ ├── note.json │ │ │ │ ├── person.json │ │ │ │ └── video.json │ │ ├── pleroma │ │ │ ├── activities │ │ │ │ ├── create_note.json │ │ │ │ ├── delete.json │ │ │ │ └── follow.json │ │ │ └── objects │ │ │ │ ├── chat_message.json │ │ │ │ ├── note.json │ │ │ │ └── person.json │ │ ├── smithereen │ │ │ ├── activities │ │ │ │ └── create_note.json │ │ │ └── objects │ │ │ │ ├── note.json │ │ │ │ └── person.json │ │ └── wordpress │ │ │ ├── activities │ │ │ └── announce.json │ │ │ └── objects │ │ │ ├── group.json │ │ │ ├── note.json │ │ │ ├── page.json │ │ │ └── person.json │ └── src │ │ ├── activities │ │ ├── block │ │ │ ├── block_user.rs │ │ │ ├── mod.rs │ │ │ └── undo_block_user.rs │ │ ├── community │ │ │ ├── announce.rs │ │ │ ├── collection_add.rs │ │ │ ├── collection_remove.rs │ │ │ ├── lock_page.rs │ │ │ ├── mod.rs │ │ │ ├── report.rs │ │ │ ├── resolve_report.rs │ │ │ └── update.rs │ │ ├── create_or_update │ │ │ ├── comment.rs │ │ │ ├── mod.rs │ │ │ ├── note_wrapper.rs │ │ │ ├── post.rs │ │ │ └── private_message.rs │ │ ├── deletion │ │ │ ├── delete.rs │ │ │ ├── mod.rs │ │ │ └── undo_delete.rs │ │ ├── following │ │ │ ├── accept.rs │ │ │ ├── follow.rs │ │ │ ├── mod.rs │ │ │ ├── reject.rs │ │ │ └── undo_follow.rs │ │ ├── mod.rs │ │ └── voting │ │ │ ├── mod.rs │ │ │ ├── undo_vote.rs │ │ │ └── vote.rs │ │ ├── activity_lists.rs │ │ ├── api │ │ ├── list_comments.rs │ │ ├── list_person_content.rs │ │ ├── list_posts.rs │ │ ├── mod.rs │ │ ├── read_community.rs │ │ ├── read_person.rs │ │ ├── resolve_object.rs │ │ ├── search.rs │ │ └── user_settings_backup.rs │ │ ├── collections │ │ ├── community_featured.rs │ │ ├── community_follower.rs │ │ ├── community_moderators.rs │ │ ├── community_outbox.rs │ │ └── mod.rs │ │ ├── fetcher │ │ ├── mod.rs │ │ └── search.rs │ │ ├── http │ │ ├── comment.rs │ │ ├── community.rs │ │ ├── mod.rs │ │ ├── person.rs │ │ ├── post.rs │ │ ├── routes.rs │ │ └── site.rs │ │ ├── lib.rs │ │ └── protocol │ │ ├── activities │ │ ├── block │ │ │ ├── block_user.rs │ │ │ ├── mod.rs │ │ │ └── undo_block_user.rs │ │ ├── community │ │ │ ├── announce.rs │ │ │ ├── collection_add.rs │ │ │ ├── collection_remove.rs │ │ │ ├── lock_page.rs │ │ │ ├── mod.rs │ │ │ ├── report.rs │ │ │ ├── resolve_report.rs │ │ │ └── update.rs │ │ ├── create_or_update │ │ │ ├── mod.rs │ │ │ ├── note.rs │ │ │ ├── note_wrapper.rs │ │ │ ├── page.rs │ │ │ └── private_message.rs │ │ ├── deletion │ │ │ ├── delete.rs │ │ │ ├── delete_user.rs │ │ │ ├── mod.rs │ │ │ └── undo_delete.rs │ │ ├── following │ │ │ ├── accept.rs │ │ │ ├── follow.rs │ │ │ ├── mod.rs │ │ │ ├── reject.rs │ │ │ └── undo_follow.rs │ │ ├── mod.rs │ │ └── voting │ │ │ ├── mod.rs │ │ │ ├── undo_vote.rs │ │ │ └── vote.rs │ │ ├── collections │ │ ├── empty_outbox.rs │ │ ├── group_featured.rs │ │ ├── group_followers.rs │ │ ├── group_moderators.rs │ │ ├── group_outbox.rs │ │ └── mod.rs │ │ └── mod.rs ├── apub_objects │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── objects │ │ ├── comment.rs │ │ ├── community.rs │ │ ├── instance.rs │ │ ├── mod.rs │ │ ├── person.rs │ │ ├── post.rs │ │ └── private_message.rs │ │ ├── protocol │ │ ├── group.rs │ │ ├── instance.rs │ │ ├── mod.rs │ │ ├── note.rs │ │ ├── page.rs │ │ ├── person.rs │ │ ├── private_message.rs │ │ └── tombstone.rs │ │ └── utils │ │ ├── functions.rs │ │ ├── markdown_links.rs │ │ ├── mentions.rs │ │ ├── mod.rs │ │ ├── protocol.rs │ │ └── test.rs ├── db_perf │ ├── Cargo.toml │ └── src │ │ ├── main.rs │ │ └── series.rs ├── db_schema │ ├── Cargo.toml │ └── src │ │ ├── impls │ │ ├── activity.rs │ │ ├── actor_language.rs │ │ ├── captcha_answer.rs │ │ ├── comment.rs │ │ ├── comment_reply.rs │ │ ├── comment_report.rs │ │ ├── community.rs │ │ ├── community_report.rs │ │ ├── custom_emoji.rs │ │ ├── email_verification.rs │ │ ├── federation_allowlist.rs │ │ ├── federation_blocklist.rs │ │ ├── federation_queue_state.rs │ │ ├── images.rs │ │ ├── instance.rs │ │ ├── keyword_block.rs │ │ ├── language.rs │ │ ├── local_site.rs │ │ ├── local_site_rate_limit.rs │ │ ├── local_site_url_blocklist.rs │ │ ├── local_user.rs │ │ ├── login_token.rs │ │ ├── mod.rs │ │ ├── mod_log │ │ │ ├── admin.rs │ │ │ ├── mod.rs │ │ │ └── moderator.rs │ │ ├── oauth_account.rs │ │ ├── oauth_provider.rs │ │ ├── password_reset_request.rs │ │ ├── person.rs │ │ ├── person_comment_mention.rs │ │ ├── person_post_mention.rs │ │ ├── post.rs │ │ ├── post_report.rs │ │ ├── post_tag.rs │ │ ├── private_message.rs │ │ ├── private_message_report.rs │ │ ├── registration_application.rs │ │ ├── secret.rs │ │ ├── site.rs │ │ ├── tag.rs │ │ └── tagline.rs │ │ ├── lib.rs │ │ ├── newtypes.rs │ │ ├── sensitive.rs │ │ ├── source │ │ ├── activity.rs │ │ ├── actor_language.rs │ │ ├── captcha_answer.rs │ │ ├── combined │ │ │ ├── inbox.rs │ │ │ ├── mod.rs │ │ │ ├── modlog.rs │ │ │ ├── person_content.rs │ │ │ ├── person_liked.rs │ │ │ ├── person_saved.rs │ │ │ ├── report.rs │ │ │ └── search.rs │ │ ├── comment.rs │ │ ├── comment_reply.rs │ │ ├── comment_report.rs │ │ ├── community.rs │ │ ├── community_report.rs │ │ ├── custom_emoji.rs │ │ ├── custom_emoji_keyword.rs │ │ ├── email_verification.rs │ │ ├── federation_allowlist.rs │ │ ├── federation_blocklist.rs │ │ ├── federation_queue_state.rs │ │ ├── images.rs │ │ ├── instance.rs │ │ ├── keyword_block.rs │ │ ├── language.rs │ │ ├── local_site.rs │ │ ├── local_site_rate_limit.rs │ │ ├── local_site_url_blocklist.rs │ │ ├── local_user.rs │ │ ├── login_token.rs │ │ ├── mod.rs │ │ ├── mod_log │ │ │ ├── admin.rs │ │ │ ├── mod.rs │ │ │ └── moderator.rs │ │ ├── oauth_account.rs │ │ ├── oauth_provider.rs │ │ ├── password_reset_request.rs │ │ ├── person.rs │ │ ├── person_comment_mention.rs │ │ ├── person_post_mention.rs │ │ ├── post.rs │ │ ├── post_report.rs │ │ ├── post_tag.rs │ │ ├── private_message.rs │ │ ├── private_message_report.rs │ │ ├── registration_application.rs │ │ ├── secret.rs │ │ ├── site.rs │ │ ├── tag.rs │ │ └── tagline.rs │ │ ├── traits.rs │ │ ├── utils.rs │ │ └── utils │ │ ├── queries.rs │ │ └── uplete.rs ├── db_schema_file │ ├── Cargo.toml │ ├── diesel_ltree.patch │ ├── replaceable_schema │ │ ├── triggers.sql │ │ └── utils.sql │ └── src │ │ ├── diff_check.rs │ │ ├── enums.rs │ │ ├── lib.rs │ │ ├── schema.rs │ │ └── schema_setup.rs ├── db_views │ ├── comment │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── community │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── community_follower │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── community_moderator │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── community_person_ban │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── custom_emoji │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── inbox_combined │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── local_image │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── local_user │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── modlog_combined │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── person │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── person_content_combined │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── person_liked_combined │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── person_saved_combined │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── post │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── private_message │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── registration_applications │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── report_combined │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── reports │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── comment_report_view.rs │ │ │ ├── community_report_view.rs │ │ │ ├── lib.rs │ │ │ ├── post_report_view.rs │ │ │ └── private_message_report_view.rs │ ├── search_combined │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ ├── site │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── impls.rs │ │ │ └── lib.rs │ └── vote │ │ ├── Cargo.toml │ │ └── src │ │ ├── impls.rs │ │ └── lib.rs ├── email │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── account.rs │ │ ├── admin.rs │ │ ├── lib.rs │ │ └── notifications.rs ├── federate │ ├── Cargo.toml │ └── src │ │ ├── inboxes.rs │ │ ├── lib.rs │ │ ├── send.rs │ │ ├── stats.rs │ │ ├── util.rs │ │ └── worker.rs ├── routes │ ├── Cargo.toml │ └── src │ │ ├── feeds.rs │ │ ├── images │ │ ├── delete.rs │ │ ├── download.rs │ │ ├── mod.rs │ │ ├── upload.rs │ │ └── utils.rs │ │ ├── lib.rs │ │ ├── middleware │ │ ├── idempotency.rs │ │ ├── mod.rs │ │ └── session.rs │ │ ├── nodeinfo.rs │ │ ├── utils │ │ ├── mod.rs │ │ ├── prometheus_metrics.rs │ │ ├── scheduled_tasks.rs │ │ └── setup_local_site.rs │ │ └── webfinger.rs └── utils │ ├── Cargo.toml │ ├── src │ ├── cache_header.rs │ ├── error.rs │ ├── lib.rs │ ├── main.rs │ ├── rate_limit │ │ ├── mod.rs │ │ └── rate_limiter.rs │ ├── request.rs │ ├── response.rs │ ├── settings │ │ ├── mod.rs │ │ └── structs.rs │ └── utils │ │ ├── markdown │ │ ├── image_links.rs │ │ ├── link_rule.rs │ │ └── mod.rs │ │ ├── mention.rs │ │ ├── mod.rs │ │ ├── slurs.rs │ │ └── validation.rs │ └── tests │ └── test_errors_used.rs ├── diesel.toml ├── docker ├── Dockerfile ├── README.md ├── docker-compose.yml ├── docker_db_backup.sh ├── docker_update.sh ├── federation │ ├── docker-compose.yml │ ├── lemmy_alpha.hjson │ ├── lemmy_beta.hjson │ ├── lemmy_delta.hjson │ ├── lemmy_epsilon.hjson │ ├── lemmy_gamma.hjson │ ├── nginx.conf │ └── start-local-instances.bash ├── lemmy.hjson ├── nginx.conf └── test_deploy.sh ├── migrations ├── 00000000000000_diesel_initial_setup │ ├── down.sql │ └── up.sql ├── 2019-02-26-002946_create_user │ ├── down.sql │ └── up.sql ├── 2019-02-27-170003_create_community │ ├── down.sql │ └── up.sql ├── 2019-03-03-163336_create_post │ ├── down.sql │ └── up.sql ├── 2019-03-05-233828_create_comment │ ├── down.sql │ └── up.sql ├── 2019-03-30-212058_create_post_view │ ├── down.sql │ └── up.sql ├── 2019-04-03-155205_create_community_view │ ├── down.sql │ └── up.sql ├── 2019-04-03-155309_create_comment_view │ ├── down.sql │ └── up.sql ├── 2019-04-07-003142_create_moderation_logs │ ├── down.sql │ └── up.sql ├── 2019-04-08-015947_create_user_view │ ├── down.sql │ └── up.sql ├── 2019-04-11-144915_create_mod_views │ ├── down.sql │ └── up.sql ├── 2019-04-29-175834_add_delete_columns │ ├── down.sql │ └── up.sql ├── 2019-05-02-051656_community_view_hot_rank │ ├── down.sql │ └── up.sql ├── 2019-06-01-222649_remove_admin │ ├── down.sql │ └── up.sql ├── 2019-08-11-000918_add_nsfw_columns │ ├── down.sql │ └── up.sql ├── 2019-08-29-040006_add_community_count │ ├── down.sql │ └── up.sql ├── 2019-09-05-230317_add_mod_ban_views │ ├── down.sql │ └── up.sql ├── 2019-09-09-042010_add_stickied_posts │ ├── down.sql │ └── up.sql ├── 2019-10-15-181630_add_themes │ ├── down.sql │ └── up.sql ├── 2019-10-19-052737_create_user_mention │ ├── down.sql │ └── up.sql ├── 2019-10-21-011237_add_default_sorts │ ├── down.sql │ └── up.sql ├── 2019-10-24-002614_create_password_reset_request │ ├── down.sql │ └── up.sql ├── 2019-12-09-060754_add_lang │ ├── down.sql │ └── up.sql ├── 2019-12-11-181820_add_site_fields │ ├── down.sql │ └── up.sql ├── 2019-12-29-164820_add_avatar │ ├── down.sql │ └── up.sql ├── 2020-01-01-200418_add_email_to_user_view │ ├── down.sql │ └── up.sql ├── 2020-01-02-172755_add_show_avatar_and_email_notifications_to_user │ ├── down.sql │ └── up.sql ├── 2020-01-11-012452_add_indexes │ ├── down.sql │ └── up.sql ├── 2020-01-13-025151_create_materialized_views │ ├── down.sql │ └── up.sql ├── 2020-01-21-001001_create_private_message │ ├── down.sql │ └── up.sql ├── 2020-01-29-011901_create_reply_materialized_view │ ├── down.sql │ └── up.sql ├── 2020-01-29-030825_create_user_mention_materialized_view │ ├── down.sql │ └── up.sql ├── 2020-02-02-004806_add_case_insensitive_usernames │ ├── down.sql │ └── up.sql ├── 2020-02-06-165953_change_post_title_length │ ├── down.sql │ └── up.sql ├── 2020-02-07-210055_add_comment_subscribed │ ├── down.sql │ └── up.sql ├── 2020-02-08-145624_add_post_newest_activity_time │ ├── down.sql │ └── up.sql ├── 2020-03-06-202329_add_post_iframely_data │ ├── down.sql │ └── up.sql ├── 2020-03-26-192410_add_activitypub_tables │ ├── down.sql │ └── up.sql ├── 2020-04-03-194936_add_activitypub_for_posts_and_comments │ ├── down.sql │ └── up.sql ├── 2020-04-07-135912_add_user_community_apub_constraints │ ├── down.sql │ └── up.sql ├── 2020-04-14-163701_update_views_for_activitypub │ ├── down.sql │ └── up.sql ├── 2020-04-21-123957_remove_unique_user_constraints │ ├── down.sql │ └── up.sql ├── 2020-05-05-210233_add_activitypub_for_private_messages │ ├── down.sql │ └── up.sql ├── 2020-06-30-135809_remove_mat_views │ ├── down.sql │ └── up.sql ├── 2020-07-08-202609_add_creator_published │ ├── down.sql │ └── up.sql ├── 2020-07-12-100442_add_post_title_to_comments_view │ ├── down.sql │ └── up.sql ├── 2020-07-18-234519_add_unique_community_user_actor_ids │ ├── down.sql │ └── up.sql ├── 2020-08-03-000110_add_preferred_usernames_banners_and_icons │ ├── down.sql │ └── up.sql ├── 2020-08-06-205355_update_community_post_count │ ├── down.sql │ └── up.sql ├── 2020-08-25-132005_add_unique_ap_ids │ ├── down.sql │ └── up.sql ├── 2020-09-07-231141_add_migration_utils │ ├── down.sql │ └── up.sql ├── 2020-10-07-234221_fix_fast_triggers │ ├── down.sql │ └── up.sql ├── 2020-10-10-035723_fix_fast_triggers_2 │ ├── down.sql │ └── up.sql ├── 2020-10-13-212240_create_report_tables │ ├── down.sql │ └── up.sql ├── 2020-10-23-115011_activity_ap_id_column │ ├── down.sql │ └── up.sql ├── 2020-11-05-152724_activity_remove_user_id │ ├── down.sql │ └── up.sql ├── 2020-11-10-150835_community_follower_pending │ ├── down.sql │ └── up.sql ├── 2020-11-26-134531_delete_user │ ├── down.sql │ └── up.sql ├── 2020-12-02-152437_create_site_aggregates │ ├── down.sql │ └── up.sql ├── 2020-12-03-035643_create_user_aggregates │ ├── down.sql │ └── up.sql ├── 2020-12-04-183345_create_community_aggregates │ ├── down.sql │ └── up.sql ├── 2020-12-10-152350_create_post_aggregates │ ├── down.sql │ └── up.sql ├── 2020-12-14-020038_create_comment_aggregates │ ├── down.sql │ └── up.sql ├── 2020-12-17-030456_create_alias_views │ ├── down.sql │ └── up.sql ├── 2020-12-17-031053_remove_fast_tables_and_views │ ├── down.sql │ └── up.sql ├── 2021-01-05-200932_add_hot_rank_indexes │ ├── down.sql │ └── up.sql ├── 2021-01-26-173850_default_actor_id │ ├── down.sql │ └── up.sql ├── 2021-01-27-202728_active_users_monthly │ ├── down.sql │ └── up.sql ├── 2021-01-31-050334_add_forum_sort_index │ ├── down.sql │ └── up.sql ├── 2021-02-02-153240_apub_columns │ ├── down.sql │ └── up.sql ├── 2021-02-10-164051_add_new_comments_sort_index │ ├── down.sql │ └── up.sql ├── 2021-02-13-210612_set_correct_aggregates_time_columns │ ├── down.sql │ └── up.sql ├── 2021-02-25-112959_remove-categories │ ├── down.sql │ └── up.sql ├── 2021-02-28-162616_clean_empty_post_urls │ ├── down.sql │ └── up.sql ├── 2021-03-04-040229_clean_icon_urls │ ├── down.sql │ └── up.sql ├── 2021-03-09-171136_split_user_table_2 │ ├── down.sql │ └── up.sql ├── 2021-03-19-014144_add_col_local_user_validator_time │ ├── down.sql │ └── up.sql ├── 2021-03-20-185321_move_matrix_id_to_person │ ├── down.sql │ └── up.sql ├── 2021-03-31-103917_add_show_score_setting │ ├── down.sql │ └── up.sql ├── 2021-03-31-105915_add_bot_account │ ├── down.sql │ └── up.sql ├── 2021-03-31-144349_add_site_short_description │ ├── down.sql │ └── up.sql ├── 2021-04-01-173552_rename_preferred_username_to_display_name │ ├── down.sql │ └── up.sql ├── 2021-04-01-181826_add_community_agg_active_monthly_index │ ├── down.sql │ └── up.sql ├── 2021-04-02-021422_remove_community_creator │ ├── down.sql │ └── up.sql ├── 2021-04-20-155001_limit-admins-create-community │ ├── down.sql │ └── up.sql ├── 2021-04-24-174047_add_show_read_post_setting │ ├── down.sql │ └── up.sql ├── 2021-07-19-130929_add_show_new_post_notifs_setting │ ├── down.sql │ └── up.sql ├── 2021-07-20-102033_actor_name_length │ ├── down.sql │ └── up.sql ├── 2021-08-02-002342_comment_count_fixes │ ├── down.sql │ └── up.sql ├── 2021-08-04-223559_create_user_community_block │ ├── down.sql │ └── up.sql ├── 2021-08-16-004209_fix_remove_bots_from_aggregates │ ├── 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 ├── 2021-10-01-141650_create_admin_purge │ ├── down.sql │ └── up.sql ├── 2021-11-22-135324_add_activity_ap_id_index │ ├── down.sql │ └── up.sql ├── 2021-11-22-143904_add_required_public_key │ ├── down.sql │ └── up.sql ├── 2021-11-23-031528_add_report_published_index │ ├── down.sql │ └── up.sql ├── 2021-11-23-132840_email_verification │ ├── down.sql │ └── up.sql ├── 2021-11-23-153753_add_invite_only_columns │ ├── down.sql │ └── up.sql ├── 2021-12-09-225529_add_published_to_email_verification │ ├── down.sql │ └── up.sql ├── 2021-12-14-181537_add_temporary_bans │ ├── down.sql │ └── up.sql ├── 2022-01-04-034553_add_hidden_column │ ├── down.sql │ └── up.sql ├── 2022-01-20-160328_remove_site_creator │ ├── down.sql │ └── up.sql ├── 2022-01-28-104106_instance-actor │ ├── down.sql │ └── up.sql ├── 2022-02-01-154240_add_community_title_index │ ├── down.sql │ └── up.sql ├── 2022-02-18-210946_default_theme │ ├── down.sql │ └── up.sql ├── 2022-04-04-183652_update_community_aggregates_on_soft_delete │ ├── down.sql │ └── up.sql ├── 2022-04-11-210137_fix_unique_changeme │ ├── down.sql │ └── up.sql ├── 2022-04-12-114352_default_post_listing_type │ ├── down.sql │ └── up.sql ├── 2022-04-12-185205_change_default_listing_type_to_local │ ├── down.sql │ └── up.sql ├── 2022-04-19-111004_default_require_application │ ├── down.sql │ └── up.sql ├── 2022-04-26-105145_only_mod_can_post │ ├── down.sql │ └── up.sql ├── 2022-05-19-153931_legal-information │ ├── down.sql │ └── up.sql ├── 2022-05-20-135341_embed-url │ ├── down.sql │ └── up.sql ├── 2022-06-12-012121_add_site_hide_modlog_names │ ├── down.sql │ └── up.sql ├── 2022-06-13-124806_post_report_name_length │ ├── down.sql │ └── up.sql ├── 2022-06-21-123144_language-tags │ ├── down.sql │ └── up.sql ├── 2022-07-07-182650_comment_ltrees │ ├── down.sql │ └── up.sql ├── 2022-08-04-150644_add_application_email_admins │ ├── down.sql │ └── up.sql ├── 2022-08-04-214722_add_distinguished_comment │ ├── down.sql │ └── up.sql ├── 2022-08-05-203502_add_person_post_aggregates │ ├── down.sql │ └── up.sql ├── 2022-08-22-193848_comment-language-tags │ ├── down.sql │ └── up.sql ├── 2022-09-07-113813_drop_ccnew_indexes_function │ ├── down.sql │ └── up.sql ├── 2022-09-07-114618_pm-reports │ ├── down.sql │ └── up.sql ├── 2022-09-08-102358_site-and-community-languages │ ├── down.sql │ └── up.sql ├── 2022-09-24-161829_remove_table_aliases │ ├── down.sql │ └── up.sql ├── 2022-10-06-183632_move_blocklist_to_db │ ├── down.sql │ └── up.sql ├── 2022-11-13-181529_create_taglines │ ├── down.sql │ └── up.sql ├── 2022-11-20-032430_sticky_local │ ├── down.sql │ └── up.sql ├── 2022-11-21-143249_remove-federation-settings │ ├── down.sql │ └── up.sql ├── 2022-11-21-204256_user-following │ ├── down.sql │ └── up.sql ├── 2022-12-05-110642_registration_mode │ ├── down.sql │ └── up.sql ├── 2023-01-17-165819_cleanup_post_aggregates_indexes │ ├── down.sql │ └── up.sql ├── 2023-02-01-012747_fix_active_index │ ├── down.sql │ └── up.sql ├── 2023-02-05-102549_drop-site-federation-debug │ ├── down.sql │ └── up.sql ├── 2023-02-07-030958_community-collections │ ├── down.sql │ └── up.sql ├── 2023-02-11-173347_custom_emojis │ ├── down.sql │ └── up.sql ├── 2023-02-13-172528_add_report_email_admins │ ├── down.sql │ └── up.sql ├── 2023-02-13-221303_add_instance_software_and_version │ ├── down.sql │ └── up.sql ├── 2023-02-15-212546_add_post_comment_saved_indexes │ ├── down.sql │ └── up.sql ├── 2023-02-16-194139_add_totp_secret │ ├── down.sql │ └── up.sql ├── 2023-04-14-175955_add_listingtype_sorttype_enums │ ├── down.sql │ └── up.sql ├── 2023-04-23-164732_add_person_details_indexes │ ├── down.sql │ └── up.sql ├── 2023-05-10-095739_force_enable_undetermined_language │ ├── down.sql │ └── up.sql ├── 2023-06-06-104440_index_post_url │ ├── down.sql │ └── up.sql ├── 2023-06-07-105918_add_hot_rank_columns │ ├── down.sql │ └── up.sql ├── 2023-06-17-175955_add_listingtype_sorttype_hour_enums │ ├── down.sql │ └── up.sql ├── 2023-06-19-055530_add_retry_worker_setting │ ├── down.sql │ └── up.sql ├── 2023-06-19-120700_no_double_deletion │ ├── down.sql │ └── up.sql ├── 2023-06-20-191145_add_listingtype_sorttype_3_6_9_months_enums │ ├── down.sql │ └── up.sql ├── 2023-06-21-153242_add_captcha │ ├── down.sql │ └── up.sql ├── 2023-06-22-051755_fix_local_communities_marked_non_local │ ├── down.sql │ └── up.sql ├── 2023-06-22-101245_increase_user_theme_column_size │ ├── down.sql │ └── up.sql ├── 2023-06-24-072904_add_open_links_in_new_tab_setting │ ├── down.sql │ └── up.sql ├── 2023-06-24-185942_aggegates_published_indexes │ ├── down.sql │ └── up.sql ├── 2023-06-27-065106_add_ui_settings │ ├── down.sql │ └── up.sql ├── 2023-07-04-153335_add_optimized_indexes │ ├── down.sql │ └── up.sql ├── 2023-07-05-000058_person-admin │ ├── down.sql │ └── up.sql ├── 2023-07-06-151124_hot-rank-future │ ├── down.sql │ └── up.sql ├── 2023-07-08-101154_fix_soft_delete_aggregates │ ├── down.sql │ └── up.sql ├── 2023-07-10-075550_add-infinite-scroll-setting │ ├── down.sql │ └── up.sql ├── 2023-07-11-084714_receive_activity_table │ ├── down.sql │ └── up.sql ├── 2023-07-14-154840_add_optimized_indexes_published │ ├── down.sql │ └── up.sql ├── 2023-07-14-215339_aggregates_nonzero_indexes │ ├── down.sql │ └── up.sql ├── 2023-07-18-082614_post_aggregates_community_id │ ├── down.sql │ └── up.sql ├── 2023-07-19-163511_comment_sort_hot_rank_then_score │ ├── down.sql │ └── up.sql ├── 2023-07-24-232635_trigram-index │ ├── down.sql │ └── up.sql ├── 2023-07-26-000217_create_controversial_indexes │ ├── down.sql │ └── up.sql ├── 2023-07-26-222023_site-aggregates-one │ ├── down.sql │ └── up.sql ├── 2023-07-27-134652_remove-expensive-broken-trigger │ ├── down.sql │ └── up.sql ├── 2023-08-01-101826_admin_flag_local_user │ ├── down.sql │ └── up.sql ├── 2023-08-01-115243_persistent-activity-queue │ ├── down.sql │ └── up.sql ├── 2023-08-02-144930_password-reset-token │ ├── down.sql │ └── up.sql ├── 2023-08-02-174444_fix-timezones │ ├── down.sql │ └── up.sql ├── 2023-08-08-163911_add_post_listing_mode_setting │ ├── down.sql │ └── up.sql ├── 2023-08-09-101305_user_instance_block │ ├── down.sql │ └── up.sql ├── 2023-08-23-182533_scaled_rank │ ├── down.sql │ └── up.sql ├── 2023-08-29-183053_add_listing_type_moderator_view │ ├── down.sql │ └── up.sql ├── 2023-08-31-205559_add_image_upload │ ├── down.sql │ └── up.sql ├── 2023-09-01-112158_auto_resolve_report │ ├── down.sql │ └── up.sql ├── 2023-09-07-215546_post-queries-efficient │ ├── down.sql │ └── up.sql ├── 2023-09-11-110040_rework-2fa-setup │ ├── down.sql │ └── up.sql ├── 2023-09-12-194850_add_federation_worker_index │ ├── down.sql │ └── up.sql ├── 2023-09-18-141700_login-token │ ├── down.sql │ └── up.sql ├── 2023-09-20-110614_drop-show-new-post-notifs │ ├── down.sql │ └── up.sql ├── 2023-09-28-084231_import_user_settings_rate_limit │ ├── down.sql │ └── up.sql ├── 2023-10-02-145002_community_followers_count_federated │ ├── down.sql │ └── up.sql ├── 2023-10-06-133405_add_keyboard_navigation_setting │ ├── down.sql │ └── up.sql ├── 2023-10-13-175712_allow_animated_avatars │ ├── down.sql │ └── up.sql ├── 2023-10-17-181800_drop_remove_community_expires │ ├── down.sql │ └── up.sql ├── 2023-10-23-184941_hot_rank_greatest_fix │ ├── down.sql │ └── up.sql ├── 2023-10-24-030352_change_primary_keys_and_remove_some_id_columns │ ├── down.sql │ └── up.sql ├── 2023-10-24-131607_proxy_links │ ├── down.sql │ └── up.sql ├── 2023-10-24-140438_enable_private_messages │ ├── down.sql │ └── up.sql ├── 2023-10-24-183747_autocollapse_bot_comments │ ├── down.sql │ └── up.sql ├── 2023-10-27-142514_post_url_content_type │ ├── down.sql │ └── up.sql ├── 2023-11-01-223740_federation-published │ ├── down.sql │ └── up.sql ├── 2023-11-02-120140_apub-signed-fetch │ ├── down.sql │ └── up.sql ├── 2023-11-07-135409_inbox_unique │ ├── down.sql │ └── up.sql ├── 2023-11-22-194806_low_rank_defaults │ ├── down.sql │ └── up.sql ├── 2023-12-06-180359_edit_active_users │ ├── down.sql │ └── up.sql ├── 2023-12-19-210053_tolerable-batch-insert-speed │ ├── down.sql │ └── up.sql ├── 2023-12-22-040137_make-mixed-sorting-directions-work-with-tuple-comparison │ ├── down.sql │ └── up.sql ├── 2024-01-02-094916_site-name-not-unique │ ├── down.sql │ └── up.sql ├── 2024-01-05-213000_community_aggregates_add_local_subscribers │ ├── down.sql │ └── up.sql ├── 2024-01-15-100133_local-only-community │ ├── down.sql │ └── up.sql ├── 2024-01-22-105746_lemmynsfw-changes │ ├── down.sql │ └── up.sql ├── 2024-01-25-151400_remove_auto_resolve_report_trigger │ ├── down.sql │ └── up.sql ├── 2024-02-12-211114_add_vote_display_mode_setting │ ├── down.sql │ └── up.sql ├── 2024-02-15-171358_default_instance_sort_type │ ├── down.sql │ └── up.sql ├── 2024-02-24-034523_replaceable-schema │ ├── down.sql │ └── up.sql ├── 2024-02-27-204628_add_post_alt_text │ ├── down.sql │ └── up.sql ├── 2024-02-28-144211_hide_posts │ ├── down.sql │ └── up.sql ├── 2024-03-04-143245_remove_show_scores_column │ ├── down.sql │ └── up.sql ├── 2024-03-06-104706_local_image_user_opt │ ├── down.sql │ └── up.sql ├── 2024-03-06-201637_url_blocklist │ ├── down.sql │ └── up.sql ├── 2024-04-05-153647_alter_vote_display_mode_defaults │ ├── down.sql │ └── up.sql ├── 2024-04-08-204327_custom_emoji_tagline_changes │ ├── down.sql │ └── up.sql ├── 2024-04-15-105932_community_followers_url_optional │ ├── down.sql │ └── up.sql ├── 2024-04-23-020604_add_post_id_index │ ├── down.sql │ └── up.sql ├── 2024-05-04-140749_separate_triggers │ ├── down.sql │ └── up.sql ├── 2024-05-05-162540_add_image_detail_table │ ├── down.sql │ └── up.sql ├── 2024-06-17-160323_fix_post_aggregates_featured_local │ ├── down.sql │ └── up.sql ├── 2024-06-24-000000_ap_id_triggers │ ├── down.sql │ └── up.sql ├── 2024-07-01-014711_exponential_controversy │ ├── down.sql │ └── up.sql ├── 2024-08-03-155932_increase_post_url_max_length │ ├── down.sql │ └── up.sql ├── 2024-09-12-130204_drop-enable-nsfw │ ├── down.sql │ └── up.sql ├── 2024-09-16-000000_default_comment_sort_type │ ├── down.sql │ └── up.sql ├── 2024-09-16-095656_schedule-post │ ├── down.sql │ └── up.sql ├── 2024-09-16-174833_create_oauth_provider │ ├── down.sql │ └── up.sql ├── 2024-09-20-134838_add_federation_vote_rejection │ ├── down.sql │ └── up.sql ├── 2024-09-23-133038_remove_auto_expand │ ├── down.sql │ └── up.sql ├── 2024-10-16-141718_add_short_community_description │ ├── down.sql │ └── up.sql ├── 2024-10-18-074533_no-individual-inboxes │ ├── down.sql │ └── up.sql ├── 2024-10-23-091053_comment-vote-remote-postid │ ├── down.sql │ └── up.sql ├── 2024-10-29-090055_private-community │ ├── down.sql │ └── up.sql ├── 2024-11-01-233231_add_mark_fetched_posts_as_read │ ├── down.sql │ └── up.sql ├── 2024-11-10-134311_smoosh-tables-together │ ├── down.sql │ └── up.sql ├── 2024-11-12-090437_move-triggers │ ├── down.sql │ └── up.sql ├── 2024-11-18-012112_forbid_diesel_cli │ ├── down.sql │ └── up.sql ├── 2024-11-18-012113_custom_migration_runner │ ├── down.sql │ └── up.sql ├── 2024-11-21-195004_add_report_count │ ├── down.sql │ └── up.sql ├── 2024-11-23-234637_oauth_pkce │ ├── down.sql │ └── up.sql ├── 2024-11-25-161129_add_blurhash_to_image_details │ ├── down.sql │ └── up.sql ├── 2024-11-28-142005_instance-block-mod-log │ ├── down.sql │ └── up.sql ├── 2024-12-02-181601_add_report_combined_table │ ├── down.sql │ └── up.sql ├── 2024-12-05-233704_add_person_content_combined_table │ ├── down.sql │ └── up.sql ├── 2024-12-08-165614_add_modlog_combined_table │ ├── down.sql │ └── up.sql ├── 2024-12-10-193418_add_inbox_combined_table │ ├── down.sql │ └── up.sql ├── 2024-12-12-222846_add_search_combined_table │ ├── down.sql │ └── up.sql ├── 2024-12-15-151642_add_index_on_person_id_read_for_read_only_post_actions │ ├── down.sql │ └── up.sql ├── 2024-12-17-144959_community-post-tags │ ├── down.sql │ └── up.sql ├── 2024-12-18-200602_optimize_get_random_community │ ├── down.sql │ └── up.sql ├── 2024-12-20-090225_update-replaceable-schema │ ├── down.sql │ └── up.sql ├── 2024-12-27-220142_community_report │ ├── down.sql │ └── up.sql ├── 2024-12-29-203717_add_post_keyword_block_table │ ├── down.sql │ └── up.sql ├── 2025-01-09-144233_no-image-token │ ├── down.sql │ └── up.sql ├── 2025-01-10-135505_donation-dialog │ ├── down.sql │ └── up.sql ├── 2025-01-14-023145_media_filter │ ├── down.sql │ └── up.sql ├── 2025-01-21-000000_interactions_per_month_schema │ ├── down.sql │ └── up.sql ├── 2025-01-23-143621_report_to_admins │ ├── down.sql │ └── up.sql ├── 2025-02-05-090155_ap_id │ ├── down.sql │ └── up.sql ├── 2025-02-06-233105_remove_post_sort_type_enums │ ├── down.sql │ └── up.sql ├── 2025-02-11-131045_ban-remove-content-pm │ ├── down.sql │ └── up.sql ├── 2025-02-18-143408_block_nsfw │ ├── down.sql │ └── up.sql ├── 2025-02-24-173152_search-alt-text-of-posts │ ├── down.sql │ └── up.sql ├── 2025-03-04-105516_remove-aggregate-tables │ ├── down.sql │ └── up.sql ├── 2025-03-07-094522_enable_english_for_all │ ├── down.sql │ └── up.sql ├── 2025-03-11-015056_local_user_trigger │ ├── down.sql │ └── up.sql ├── 2025-03-11-124442_community-hidden-visibility │ ├── down.sql │ └── up.sql ├── 2025-03-13-112516_community-local-removed │ ├── down.sql │ └── up.sql ├── 2025-03-13-112517_post_comment_pending │ ├── down.sql │ └── up.sql ├── 2025-03-17-110023_site_person_ban │ ├── down.sql │ └── up.sql ├── 2025-03-25-221304_remove_post_instance_id │ ├── down.sql │ └── up.sql ├── 2025-04-07-100344_registration-rate-limit │ ├── down.sql │ └── up.sql ├── 2025-04-07-141445_disable-email-notifications │ ├── down.sql │ └── up.sql ├── 2025-04-09-123352_cursor_pagination_indexes │ ├── down.sql │ └── up.sql ├── 2025-04-10-234244_add_liked_combined │ ├── down.sql │ └── up.sql ├── 2025-04-25-183519_show_downvotes_for_others_only │ ├── down.sql │ └── up.sql ├── 2025-05-06-145536_local_image_person │ ├── down.sql │ └── up.sql ├── 2025-05-08-161908_lock_reason │ ├── down.sql │ └── up.sql ├── 2025-05-15-143802_remove_hide_modlog_names │ ├── down.sql │ └── up.sql ├── 2025-05-26-092442_mod-change-community-vis │ ├── down.sql │ └── up.sql └── 2025-05-30-225731_error_if_code_migrations_needed │ ├── down.sql │ └── up.sql ├── readmes ├── README.es.md ├── README.ja.md ├── README.ru.md ├── README.zh.hans.md └── README.zh.hant.md ├── renovate.json ├── scripts ├── alpine_install_pg_formatter.sh ├── clear_db.sh ├── compilation_benchmark.sh ├── db-init.sh ├── db_perf.sh ├── dump_schema.sh ├── install.sh ├── lint.sh ├── postgres_12_to_15_upgrade.sh ├── postgres_15_to_16_upgrade.sh ├── query_testing │ ├── apache_bench_report.sh │ ├── api_benchmark.sh │ ├── post_query_hot_rank.sh │ ├── views_old │ │ ├── generate_reports.sh │ │ └── timings-2021-01-05_21-06-37.out │ └── views_to_diesel_migration │ │ ├── generate_reports.sh │ │ └── timings-2021-01-05_21-32-54.out ├── release.sh ├── restore_db.sh ├── sql_format_check.sh ├── start_dev_db.sh ├── test-with-coverage.sh ├── test.sh ├── ts_bindings_check.sh ├── update_config_defaults.sh ├── update_translations.sh └── upgrade_deps.sh └── src ├── api_routes.rs ├── lib.rs └── main.rs /.dockerignore: -------------------------------------------------------------------------------- 1 | .gitignore -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Normalize EOL for all files that Git considers text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @Nutomic @dessalines @phiresky @dullbananas @SleeplessOne1917 2 | crates/apub/ @Nutomic 3 | migrations/ @dessalines @phiresky @dullbananas 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: dessalines 4 | liberapay: Lemmy 5 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | 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 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "crates/utils/translations"] 2 | path = crates/email/translations 3 | url = https://github.com/LemmyNet/lemmy-translations.git 4 | branch = main 5 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | tab_spaces = 2 2 | edition = "2021" 3 | imports_layout = "HorizontalVertical" 4 | imports_granularity = "Crate" 5 | group_imports = "One" 6 | wrap_comments = true 7 | comment_width = 100 8 | -------------------------------------------------------------------------------- /api_tests/.npmrc: -------------------------------------------------------------------------------- 1 | package-manager-strict=false 2 | -------------------------------------------------------------------------------- /api_tests/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "avoid", 3 | "semi": true 4 | } 5 | -------------------------------------------------------------------------------- /api_tests/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: "ts-jest", 3 | testEnvironment: "node", 4 | }; 5 | -------------------------------------------------------------------------------- /api_tests/plugins/go_replace_words.json: -------------------------------------------------------------------------------- 1 | { 2 | "wasm": [ 3 | { 4 | "url": "https://github.com/LemmyNet/lemmy-plugins/releases/download/0.1.0/go_replace_words.wasm", 5 | "hash": "d4f4fcc10360b24ea2f805aa89427b4e4dcf5c34263aedd55b528d2e28ef04b4" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /api_tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "declarationDir": "./dist", 5 | "module": "CommonJS", 6 | "noImplicitAny": true, 7 | "lib": ["es2017", "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 | -------------------------------------------------------------------------------- /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 | } 6 | -------------------------------------------------------------------------------- /crates/api/src/comment/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod distinguish; 2 | pub mod like; 3 | pub mod list_comment_likes; 4 | pub mod save; 5 | -------------------------------------------------------------------------------- /crates/api/src/community/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod add_mod; 2 | pub mod ban; 3 | pub mod block; 4 | pub mod follow; 5 | pub mod pending_follows; 6 | pub mod random; 7 | pub mod tag; 8 | pub mod transfer; 9 | -------------------------------------------------------------------------------- /crates/api/src/community/pending_follows/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod approve; 2 | pub mod count; 3 | pub mod list; 4 | -------------------------------------------------------------------------------- /crates/api/src/local_user/donation_dialog_shown.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json}; 2 | use chrono::Utc; 3 | use lemmy_api_common::{context::LemmyContext, SuccessResponse}; 4 | use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm}; 5 | use lemmy_db_views_local_user::LocalUserView; 6 | use lemmy_utils::error::LemmyResult; 7 | 8 | pub async fn donation_dialog_shown( 9 | context: Data, 10 | local_user_view: LocalUserView, 11 | ) -> LemmyResult> { 12 | let form = LocalUserUpdateForm { 13 | last_donation_notification: Some(Utc::now()), 14 | ..Default::default() 15 | }; 16 | LocalUser::update(&mut context.pool(), local_user_view.local_user.id, &form).await?; 17 | 18 | Ok(Json(SuccessResponse::default())) 19 | } 20 | -------------------------------------------------------------------------------- /crates/api/src/local_user/list_logins.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json}; 2 | use lemmy_api_common::{context::LemmyContext, person::ListLoginsResponse}; 3 | use lemmy_db_schema::source::login_token::LoginToken; 4 | use lemmy_db_views_local_user::LocalUserView; 5 | use lemmy_utils::error::LemmyResult; 6 | 7 | pub async fn list_logins( 8 | context: Data, 9 | local_user_view: LocalUserView, 10 | ) -> LemmyResult> { 11 | let logins = LoginToken::list(&mut context.pool(), local_user_view.local_user.id).await?; 12 | 13 | Ok(Json(ListLoginsResponse { logins })) 14 | } 15 | -------------------------------------------------------------------------------- /crates/api/src/local_user/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod add_admin; 2 | pub mod ban_person; 3 | pub mod block; 4 | pub mod change_password; 5 | pub mod change_password_after_reset; 6 | pub mod donation_dialog_shown; 7 | pub mod generate_totp_secret; 8 | pub mod get_captcha; 9 | pub mod list_hidden; 10 | pub mod list_liked; 11 | pub mod list_logins; 12 | pub mod list_media; 13 | pub mod list_read; 14 | pub mod list_saved; 15 | pub mod login; 16 | pub mod logout; 17 | pub mod notifications; 18 | pub mod report_count; 19 | pub mod resend_verification_email; 20 | pub mod reset_password; 21 | pub mod save_settings; 22 | pub mod update_totp; 23 | pub mod user_block_instance; 24 | pub mod validate_auth; 25 | pub mod verify_email; 26 | -------------------------------------------------------------------------------- /crates/api/src/local_user/notifications/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod list_inbox; 2 | pub mod mark_all_read; 3 | pub mod mark_comment_mention_read; 4 | pub mod mark_post_mention_read; 5 | pub mod mark_reply_read; 6 | pub mod unread_count; 7 | -------------------------------------------------------------------------------- /crates/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 save; 10 | -------------------------------------------------------------------------------- /crates/api/src/private_message/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mark_read; 2 | -------------------------------------------------------------------------------- /crates/api/src/reports/comment_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /crates/api/src/reports/community_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/api/src/reports/post_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /crates/api/src/reports/private_message_report/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod resolve; 3 | -------------------------------------------------------------------------------- /crates/api/src/reports/report_combined/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod list; 2 | -------------------------------------------------------------------------------- /crates/api/src/site/federated_instances.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json}; 2 | use lemmy_api_common::{ 3 | context::LemmyContext, 4 | site::GetFederatedInstancesResponse, 5 | utils::build_federated_instances, 6 | }; 7 | use lemmy_db_views_site::SiteView; 8 | use lemmy_utils::error::LemmyResult; 9 | 10 | pub async fn get_federated_instances( 11 | context: Data, 12 | ) -> LemmyResult> { 13 | let site_view = SiteView::read_local(&mut context.pool()).await?; 14 | let federated_instances = 15 | build_federated_instances(&site_view.local_site, &mut context.pool()).await?; 16 | 17 | Ok(Json(GetFederatedInstancesResponse { 18 | federated_instances, 19 | })) 20 | } 21 | -------------------------------------------------------------------------------- /crates/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 leave_admin; 6 | pub mod list_all_media; 7 | pub mod mod_log; 8 | pub mod purge; 9 | pub mod registration_applications; 10 | -------------------------------------------------------------------------------- /crates/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/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 | pub mod unread_count; 7 | -------------------------------------------------------------------------------- /crates/api_common/src/reports/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod combined; 2 | pub mod comment; 3 | pub mod community; 4 | pub mod post; 5 | pub mod private_message; 6 | -------------------------------------------------------------------------------- /crates/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_crud/src/custom_emoji/list.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::{Data, Json, Query}; 2 | use lemmy_api_common::{ 3 | context::LemmyContext, 4 | custom_emoji::{ListCustomEmojis, ListCustomEmojisResponse}, 5 | }; 6 | use lemmy_db_views_custom_emoji::CustomEmojiView; 7 | use lemmy_utils::error::LemmyError; 8 | 9 | pub async fn list_custom_emojis( 10 | 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 | -------------------------------------------------------------------------------- /crates/api_crud/src/custom_emoji/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod list; 4 | pub mod update; 5 | -------------------------------------------------------------------------------- /crates/api_crud/src/lib.rs: -------------------------------------------------------------------------------- 1 | use lemmy_api_common::context::LemmyContext; 2 | use lemmy_db_schema::source::community::{Community, CommunityActions}; 3 | 4 | pub mod comment; 5 | pub mod community; 6 | pub mod custom_emoji; 7 | pub mod oauth_provider; 8 | pub mod post; 9 | pub mod private_message; 10 | pub mod site; 11 | pub mod tagline; 12 | pub mod user; 13 | 14 | /// Only mark new posts/comments to remote community as pending if it has any local followers. 15 | /// Otherwise it could never get updated to be marked as published. 16 | async fn community_use_pending(community: &Community, context: &LemmyContext) -> bool { 17 | if community.local { 18 | return false; 19 | } 20 | CommunityActions::check_has_local_followers(&mut context.pool(), community.id) 21 | .await 22 | .is_ok() 23 | } 24 | -------------------------------------------------------------------------------- /crates/api_crud/src/oauth_provider/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod update; 4 | -------------------------------------------------------------------------------- /crates/api_crud/src/private_message/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod update; 4 | -------------------------------------------------------------------------------- /crates/api_crud/src/tagline/delete.rs: -------------------------------------------------------------------------------- 1 | use activitypub_federation::config::Data; 2 | use actix_web::web::Json; 3 | use lemmy_api_common::{ 4 | context::LemmyContext, 5 | tagline::DeleteTagline, 6 | utils::is_admin, 7 | SuccessResponse, 8 | }; 9 | use lemmy_db_schema::{source::tagline::Tagline, traits::Crud}; 10 | use lemmy_db_views_local_user::LocalUserView; 11 | use lemmy_utils::error::LemmyError; 12 | 13 | pub async fn delete_tagline( 14 | data: Json, 15 | context: Data, 16 | local_user_view: LocalUserView, 17 | ) -> Result, LemmyError> { 18 | // Make sure user is an admin 19 | is_admin(&local_user_view)?; 20 | 21 | Tagline::delete(&mut context.pool(), data.id).await?; 22 | 23 | Ok(Json(SuccessResponse::default())) 24 | } 25 | -------------------------------------------------------------------------------- /crates/api_crud/src/tagline/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod list; 4 | pub mod update; 5 | -------------------------------------------------------------------------------- /crates/api_crud/src/user/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod my_user; 4 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | "target": "http://enterprise.lemmy.ml/c/main", 7 | "type": "Block", 8 | "removeData": true, 9 | "summary": "spam post", 10 | "endTime": "2021-11-01T12:23:50.151874Z", 11 | "id": "http://enterprise.lemmy.ml/activities/block/5d42fffb-0903-4625-86d4-0b39bb344fc2" 12 | } 13 | -------------------------------------------------------------------------------- /crates/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 | } 10 | -------------------------------------------------------------------------------- /crates/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 | "type": "Add", 8 | "id": "http://enterprise.lemmy.ml/activities/add/ec069147-77c3-447f-88c8-0ef1df10403f" 9 | } 10 | -------------------------------------------------------------------------------- /crates/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 | } 10 | -------------------------------------------------------------------------------- /crates/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 | } 10 | -------------------------------------------------------------------------------- /crates/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 | "id": "http://enterprise.lemmy.ml/activities/remove/aab114f8-cfbd-4935-a5b7-e1a64603650d" 9 | } 10 | -------------------------------------------------------------------------------- /crates/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 | "object": "http://enterprise.lemmy.ml/post/7", 5 | "summary": "report this post", 6 | "type": "Flag", 7 | "id": "http://ds9.lemmy.ml/activities/flag/98b0933f-5e45-4a95-a15f-e0dc86361ba4" 8 | } 9 | -------------------------------------------------------------------------------- /crates/apub/assets/lemmy/activities/community/resolve_report_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_user", 3 | "to": ["http://enterprise.lemmy.ml/c/main"], 4 | "type": "Resolve", 5 | "id": "http://ds9.lemmy.ml/activities/flag/4323412-5e45-4a95-a15f-e0dc86361ba4", 6 | "object": { 7 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 8 | "to": ["http://enterprise.lemmy.ml/c/main"], 9 | "object": "http://enterprise.lemmy.ml/post/7", 10 | "summary": "report this post", 11 | "type": "Flag", 12 | "id": "http://ds9.lemmy.ml/activities/flag/98b0933f-5e45-4a95-a15f-e0dc86361ba4" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/apub/assets/lemmy/activities/community/undo_lock_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://lemmy-alpha:8541/activities/undo/d6066719-d277-4964-9190-4d6faffac286", 3 | "actor": "http://lemmy-alpha:8541/u/lemmy_alpha", 4 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 5 | "object": { 6 | "actor": "http://lemmy-alpha:8541/u/lemmy_alpha", 7 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 8 | "object": "http://lemmy-alpha:8541/post/2", 9 | "cc": ["http://lemmy-alpha:8541/c/main"], 10 | "type": "Lock", 11 | "id": "http://lemmy-alpha:8541/activities/lock/08b6fd3e-9ef3-4358-a987-8bb641f3e2c3" 12 | }, 13 | "cc": ["http://lemmy-alpha:8541/c/main"], 14 | "type": "Undo", 15 | "summary": "A reason for the unlock" 16 | } 17 | -------------------------------------------------------------------------------- /crates/apub/assets/lemmy/activities/create_or_update/create_private_message.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://enterprise.lemmy.ml/activities/create/987d05fa-f637-46d7-85be-13d112bc269f", 3 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 4 | "to": ["http://ds9.lemmy.ml/u/lemmy_alpha"], 5 | "object": { 6 | "type": "Note", 7 | "id": "http://enterprise.lemmy.ml/private_message/1", 8 | "attributedTo": "http://enterprise.lemmy.ml/u/lemmy_beta", 9 | "to": ["http://ds9.lemmy.ml/u/lemmy_alpha"], 10 | "content": "hello", 11 | "mediaType": "text/html", 12 | "source": { 13 | "content": "hello", 14 | "mediaType": "text/markdown" 15 | }, 16 | "published": "2021-10-29T15:31:56.058289Z" 17 | }, 18 | "type": "Create" 19 | } 20 | -------------------------------------------------------------------------------- /crates/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 | "type": "Delete", 7 | "id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12" 8 | } 9 | -------------------------------------------------------------------------------- /crates/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/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 | -------------------------------------------------------------------------------- /crates/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 | "type": "Delete", 7 | "summary": "bad comment", 8 | "id": "http://enterprise.lemmy.ml/activities/delete/42ca1a79-f99e-4518-a2ca-ba2df221eb5e" 9 | } 10 | -------------------------------------------------------------------------------- /crates/apub/assets/lemmy/activities/deletion/undo_delete_page.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": { 5 | "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", 6 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 7 | "object": "http://ds9.lemmy.ml/post/1", 8 | "cc": ["http://enterprise.lemmy.ml/c/main"], 9 | "type": "Delete", 10 | "id": "http://ds9.lemmy.ml/activities/delete/b13cca96-7737-41e1-9769-8fbf972b3509" 11 | }, 12 | "cc": ["http://enterprise.lemmy.ml/c/main"], 13 | "type": "Undo", 14 | "id": "http://ds9.lemmy.ml/activities/undo/5e939cfb-b8a1-4de8-950f-9d684e9162b9" 15 | } 16 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/apub/assets/lemmy/activities/deletion/undo_remove_note.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 3 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 4 | "object": { 5 | "actor": "http://enterprise.lemmy.ml/u/lemmy_beta", 6 | "to": ["https://www.w3.org/ns/activitystreams#Public"], 7 | "object": "http://ds9.lemmy.ml/comment/1", 8 | "cc": ["http://enterprise.lemmy.ml/c/main"], 9 | "type": "Delete", 10 | "summary": "bad comment", 11 | "id": "http://enterprise.lemmy.ml/activities/delete/2598435c-87a3-49cd-81f3-a44b03b7af9d" 12 | }, 13 | "cc": ["http://enterprise.lemmy.ml/c/main"], 14 | "type": "Undo", 15 | "id": "http://enterprise.lemmy.ml/activities/undo/a850cf21-3866-4b3a-b80b-56aa00997fee" 16 | } 17 | -------------------------------------------------------------------------------- /crates/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/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | "type": "Dislike", 5 | "id": "http://enterprise.lemmy.ml/activities/dislike/64d40d40-a829-43a5-8247-1fb595b3ca1c" 6 | } 7 | -------------------------------------------------------------------------------- /crates/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 | "type": "Like", 5 | "id": "http://ds9.lemmy.ml/activities/like/fd61d070-7382-46a9-b2b7-6bb253732877" 6 | } 7 | -------------------------------------------------------------------------------- /crates/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 | "id": "http://enterprise.lemmy.ml/activities/like/2227ab2c-79e2-4fca-a1d2-1d67dacf2457" 8 | }, 9 | "type": "Undo", 10 | "id": "http://enterprise.lemmy.ml/activities/undo/6cc6fb71-39fe-49ea-9506-f0423b101e98" 11 | } 12 | -------------------------------------------------------------------------------- /crates/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 | "type": "Like", 7 | "id": "http://ds9.lemmy.ml/activities/like/efcf7ae2-dfcc-4ff4-9ce4-6adf251ff004" 8 | }, 9 | "type": "Undo", 10 | "id": "http://ds9.lemmy.ml/activities/undo/3518565c-24a7-4d9e-8e0a-f7a2f45ac618" 11 | } 12 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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/apub/assets/lemmy/objects/tombstone.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "https://lemmy.ml/comment/110273", 3 | "type": "Tombstone" 4 | } 5 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/apub/assets/lotide/objects/note.json: -------------------------------------------------------------------------------- 1 | { 2 | "source": { 3 | "mediaType": "text/markdown", 4 | "content": "ed: now featuring Bob Dylan and RNG" 5 | }, 6 | "attributedTo": "https://narwhal.city/users/3", 7 | "content": "

ed: now featuring Bob Dylan and RNG

\n", 8 | "@context": "https://www.w3.org/ns/activitystreams", 9 | "inReplyTo": "https://narwhal.city/posts/9", 10 | "to": "https://narwhal.city/users/1", 11 | "cc": [ 12 | "https://www.w3.org/ns/activitystreams#Public", 13 | "https://narwhal.city/communities/4" 14 | ], 15 | "id": "https://narwhal.city/comments/3", 16 | "type": "Note", 17 | "mediaType": "text/html", 18 | "published": "2020-12-31T06:47:24.470801+00:00" 19 | } 20 | -------------------------------------------------------------------------------- /crates/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/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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/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 | -------------------------------------------------------------------------------- /crates/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/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/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/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/src/activities/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/src/protocol/activities/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::activities::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::("assets/lemmy/activities/block/block_user.json")?; 13 | test_parse_lemmy_item::("assets/lemmy/activities/block/undo_block_user.json")?; 14 | Ok(()) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/apub/src/protocol/activities/voting/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod undo_vote; 2 | pub mod vote; 3 | 4 | #[cfg(test)] 5 | mod tests { 6 | use crate::protocol::activities::voting::{undo_vote::UndoVote, vote::Vote}; 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_voting() -> LemmyResult<()> { 12 | test_parse_lemmy_item::("assets/lemmy/activities/voting/like_note.json")?; 13 | test_parse_lemmy_item::("assets/lemmy/activities/voting/dislike_page.json")?; 14 | 15 | test_parse_lemmy_item::("assets/lemmy/activities/voting/undo_like_note.json")?; 16 | test_parse_lemmy_item::("assets/lemmy/activities/voting/undo_dislike_page.json")?; 17 | Ok(()) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/apub/src/protocol/activities/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::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 | } 16 | -------------------------------------------------------------------------------- /crates/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 | -------------------------------------------------------------------------------- /crates/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: i64, 11 | pub(crate) items: Vec<()>, 12 | } 13 | -------------------------------------------------------------------------------- /crates/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/apub/src/protocol/collections/group_outbox.rs: -------------------------------------------------------------------------------- 1 | use crate::protocol::activities::community::announce::AnnounceActivity; 2 | use activitypub_federation::kinds::collection::OrderedCollectionType; 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: i64, 12 | pub(crate) ordered_items: Vec, 13 | } 14 | -------------------------------------------------------------------------------- /crates/apub_objects/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod objects; 2 | pub mod protocol; 3 | pub mod utils; 4 | -------------------------------------------------------------------------------- /crates/apub_objects/src/objects/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod comment; 2 | pub mod community; 3 | pub mod instance; 4 | pub mod person; 5 | pub mod post; 6 | pub mod private_message; 7 | 8 | use comment::ApubComment; 9 | use community::ApubCommunity; 10 | use either::Either; 11 | use instance::ApubSite; 12 | use person::ApubPerson; 13 | use post::ApubPost; 14 | 15 | pub type PostOrComment = Either; 16 | 17 | pub type ReportableObjects = Either; 18 | 19 | pub type SearchableObjects = Either; 20 | 21 | pub type UserOrCommunity = Either; 22 | 23 | pub type SiteOrCommunityOrUser = Either; 24 | -------------------------------------------------------------------------------- /crates/apub_objects/src/protocol/tombstone.rs: -------------------------------------------------------------------------------- 1 | use crate::utils::protocol::Id; 2 | use activitypub_federation::kinds::object::TombstoneType; 3 | use serde::{Deserialize, Serialize}; 4 | use serde_with::skip_serializing_none; 5 | use url::Url; 6 | 7 | #[skip_serializing_none] 8 | #[derive(Clone, Debug, Deserialize, Serialize)] 9 | #[serde(rename_all = "camelCase")] 10 | pub struct Tombstone { 11 | pub(crate) id: Url, 12 | #[serde(rename = "type")] 13 | pub(crate) kind: TombstoneType, 14 | } 15 | 16 | impl Tombstone { 17 | pub fn new(id: Url) -> Tombstone { 18 | Tombstone { 19 | id, 20 | kind: TombstoneType::Tombstone, 21 | } 22 | } 23 | } 24 | 25 | impl Id for Tombstone { 26 | fn object_id(&self) -> &Url { 27 | &self.id 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /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/db_perf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lemmy_db_perf" 3 | publish = false 4 | version.workspace = true 5 | edition.workspace = true 6 | description.workspace = true 7 | license.workspace = true 8 | homepage.workspace = true 9 | documentation.workspace = true 10 | repository.workspace = true 11 | 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | anyhow = { workspace = true } 18 | clap = { workspace = true } 19 | diesel = { workspace = true } 20 | diesel-async = { workspace = true } 21 | lemmy_db_schema = { workspace = true } 22 | lemmy_db_views_post = { workspace = true, features = ["full"] } 23 | lemmy_utils = { workspace = true, features = ["full"] } 24 | lemmy_db_schema_file = { workspace = true } 25 | tokio = { workspace = true } 26 | url = { workspace = true } 27 | -------------------------------------------------------------------------------- /crates/db_schema/src/impls/mod_log/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod admin; 2 | pub mod moderator; 3 | -------------------------------------------------------------------------------- /crates/db_schema/src/impls/secret.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | source::secret::Secret, 3 | utils::{get_conn, DbPool}, 4 | }; 5 | use diesel_async::RunQueryDsl; 6 | use lemmy_db_schema_file::schema::secret::dsl::secret; 7 | use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; 8 | 9 | impl Secret { 10 | /// Initialize the Secrets from the DB. 11 | /// Warning: You should only call this once. 12 | pub async fn init(pool: &mut DbPool<'_>) -> LemmyResult { 13 | Self::read_secrets(pool).await 14 | } 15 | 16 | async fn read_secrets(pool: &mut DbPool<'_>) -> LemmyResult { 17 | let conn = &mut get_conn(pool).await?; 18 | secret 19 | .first(conn) 20 | .await 21 | .with_lemmy_type(LemmyErrorType::NotFound) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /crates/db_schema/src/source/combined/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod inbox; 2 | pub mod modlog; 3 | pub mod person_content; 4 | pub mod person_liked; 5 | pub mod person_saved; 6 | pub mod report; 7 | pub mod search; 8 | -------------------------------------------------------------------------------- /crates/db_schema/src/source/language.rs: -------------------------------------------------------------------------------- 1 | use crate::newtypes::LanguageId; 2 | #[cfg(feature = "full")] 3 | use lemmy_db_schema_file::schema::language; 4 | use serde::{Deserialize, Serialize}; 5 | #[cfg(feature = "full")] 6 | use ts_rs::TS; 7 | 8 | #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] 9 | #[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))] 10 | #[cfg_attr(feature = "full", diesel(table_name = language))] 11 | #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] 12 | #[cfg_attr(feature = "full", ts(export))] 13 | /// A language. 14 | pub struct Language { 15 | pub id: LanguageId, 16 | pub code: String, 17 | pub name: String, 18 | } 19 | -------------------------------------------------------------------------------- /crates/db_schema/src/source/mod_log/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod admin; 2 | pub mod moderator; 3 | -------------------------------------------------------------------------------- /crates/db_schema/src/source/secret.rs: -------------------------------------------------------------------------------- 1 | use crate::sensitive::SensitiveString; 2 | #[cfg(feature = "full")] 3 | use lemmy_db_schema_file::schema::secret; 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 | -------------------------------------------------------------------------------- /crates/db_schema_file/diesel_ltree.patch: -------------------------------------------------------------------------------- 1 | diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs 2 | index 255c6422..f2ccf5e2 100644 3 | --- a/crates/db_schema/src/schema.rs 4 | +++ b/crates/db_schema/src/schema.rs 5 | @@ -76,13 +76,13 @@ diesel::table! { 6 | published -> Timestamptz, 7 | } 8 | } 9 | 10 | diesel::table! { 11 | use diesel::sql_types::*; 12 | - use super::sql_types::Ltree; 13 | + use diesel_ltree::sql_types::Ltree; 14 | 15 | comment (id) { 16 | id -> Int4, 17 | creator_id -> Int4, 18 | post_id -> Int4, 19 | content -> Text, 20 | -------------------------------------------------------------------------------- /crates/db_schema_file/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "full")] 2 | pub mod diff_check; 3 | pub mod enums; 4 | #[cfg(feature = "full")] 5 | pub mod schema; 6 | #[cfg(feature = "full")] 7 | pub mod schema_setup; 8 | -------------------------------------------------------------------------------- /crates/db_views/community_moderator/src/lib.rs: -------------------------------------------------------------------------------- 1 | use lemmy_db_schema::source::{community::Community, person::Person}; 2 | use serde::{Deserialize, Serialize}; 3 | #[cfg(feature = "full")] 4 | use { 5 | diesel::{Queryable, Selectable}, 6 | ts_rs::TS, 7 | }; 8 | 9 | #[cfg(feature = "full")] 10 | pub mod impls; 11 | 12 | #[derive(Debug, Serialize, Deserialize, Clone)] 13 | #[cfg_attr(feature = "full", derive(TS, Queryable, Selectable))] 14 | #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] 15 | #[cfg_attr(feature = "full", ts(export))] 16 | /// A community moderator. 17 | pub struct CommunityModeratorView { 18 | #[cfg_attr(feature = "full", diesel(embed))] 19 | pub community: Community, 20 | #[cfg_attr(feature = "full", diesel(embed))] 21 | pub moderator: Person, 22 | } 23 | -------------------------------------------------------------------------------- /crates/db_views/community_person_ban/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "full")] 2 | use diesel::{Queryable, Selectable}; 3 | use lemmy_db_schema::source::{community::Community, person::Person}; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[cfg(feature = "full")] 7 | pub mod impls; 8 | 9 | #[derive(Debug, Serialize, Deserialize, Clone)] 10 | #[cfg_attr(feature = "full", derive(Queryable, Selectable))] 11 | #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] 12 | /// A community person ban. 13 | pub struct CommunityPersonBanView { 14 | #[cfg_attr(feature = "full", diesel(embed))] 15 | pub community: Community, 16 | #[cfg_attr(feature = "full", diesel(embed))] 17 | pub person: Person, 18 | } 19 | -------------------------------------------------------------------------------- /crates/db_views/custom_emoji/src/lib.rs: -------------------------------------------------------------------------------- 1 | use lemmy_db_schema::source::{ 2 | custom_emoji::CustomEmoji, 3 | custom_emoji_keyword::CustomEmojiKeyword, 4 | }; 5 | use serde::{Deserialize, Serialize}; 6 | #[cfg(feature = "full")] 7 | use {diesel::Queryable, ts_rs::TS}; 8 | 9 | #[cfg(feature = "full")] 10 | pub mod impls; 11 | 12 | #[derive(Debug, Serialize, Deserialize, Clone)] 13 | #[cfg_attr(feature = "full", derive(TS, Queryable))] 14 | #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] 15 | #[cfg_attr(feature = "full", ts(export))] 16 | /// A custom emoji view. 17 | pub struct CustomEmojiView { 18 | pub custom_emoji: CustomEmoji, 19 | pub keywords: Vec, 20 | } 21 | -------------------------------------------------------------------------------- /crates/db_views/vote/src/lib.rs: -------------------------------------------------------------------------------- 1 | use lemmy_db_schema::source::person::Person; 2 | use serde::{Deserialize, Serialize}; 3 | use serde_with::skip_serializing_none; 4 | #[cfg(feature = "full")] 5 | use {diesel::Queryable, ts_rs::TS}; 6 | 7 | #[cfg(feature = "full")] 8 | pub mod impls; 9 | 10 | #[skip_serializing_none] 11 | #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] 12 | #[cfg_attr(feature = "full", derive(TS, Queryable))] 13 | #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] 14 | #[cfg_attr(feature = "full", ts(export))] 15 | /// A vote view for checking a post or comments votes. 16 | pub struct VoteView { 17 | pub creator: Person, 18 | pub creator_banned_from_community: bool, 19 | pub score: i16, 20 | } 21 | -------------------------------------------------------------------------------- /crates/routes/src/images/mod.rs: -------------------------------------------------------------------------------- 1 | use actix_web::web::*; 2 | use lemmy_api_common::{context::LemmyContext, SuccessResponse}; 3 | use lemmy_utils::error::LemmyResult; 4 | 5 | pub mod delete; 6 | pub mod download; 7 | pub mod upload; 8 | mod utils; 9 | 10 | pub async fn pictrs_health(context: Data) -> LemmyResult> { 11 | let pictrs_config = context.settings().pictrs()?; 12 | let url = format!("{}healthz", pictrs_config.url); 13 | 14 | context 15 | .pictrs_client() 16 | .get(url) 17 | .send() 18 | .await? 19 | .error_for_status()?; 20 | 21 | Ok(Json(SuccessResponse::default())) 22 | } 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /crates/routes/src/middleware/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod idempotency; 2 | pub mod session; 3 | -------------------------------------------------------------------------------- /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 | pub 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 | -------------------------------------------------------------------------------- /crates/utils/src/main.rs: -------------------------------------------------------------------------------- 1 | use cfg_if::cfg_if; 2 | 3 | fn main() { 4 | cfg_if! { 5 | if #[cfg(feature = "full")] { 6 | use doku::json::{AutoComments, CommentsStyle, Formatting, ObjectsStyle}; 7 | use lemmy_utils::settings::structs::Settings; 8 | let fmt = Formatting { 9 | auto_comments: AutoComments::none(), 10 | comments_style: CommentsStyle { 11 | separator: "#".to_owned(), 12 | }, 13 | objects_style: ObjectsStyle { 14 | surround_keys_with_quotes: false, 15 | use_comma_as_separator: false, 16 | }, 17 | ..Default::default() 18 | }; 19 | println!("{}", doku::to_json_fmt_val(&fmt, &Settings::default())); 20 | } else { 21 | 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/utils/src/utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod markdown; 2 | pub mod mention; 3 | pub mod slurs; 4 | pub mod validation; 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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_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 | -------------------------------------------------------------------------------- /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 | } 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docker/lemmy.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # for more info about the config, check out the documentation 3 | # https://join-lemmy.org/docs/en/administration/configuration.html 4 | 5 | # This is a minimal lemmy config for the dev / main branch. Do not use for a 6 | # release / stable version. 7 | 8 | setup: { 9 | admin_username: "lemmy" 10 | admin_password: "lemmylemmy" 11 | site_name: "lemmy-dev" 12 | } 13 | database: { 14 | connection: "postgres://lemmy:password@postgres:5432/lemmy" 15 | } 16 | 17 | hostname: "localhost" 18 | bind: "0.0.0.0" 19 | port: 8536 20 | 21 | pictrs: { 22 | url: "http://pictrs:8080/" 23 | api_key: "my-pictrs-key" 24 | image_mode: None 25 | } 26 | 27 | #opentelemetry_url: "http://otel:4137" 28 | } 29 | -------------------------------------------------------------------------------- /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/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/2019-02-26-002946_create_user/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE user_ban; 2 | 3 | DROP TABLE user_; 4 | 5 | -------------------------------------------------------------------------------- /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/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/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/2019-03-30-212058_create_post_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW post_view; 2 | 3 | DROP FUNCTION hot_rank; 4 | 5 | -------------------------------------------------------------------------------- /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/2019-04-03-155309_create_comment_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW reply_view; 2 | 3 | DROP VIEW comment_view; 4 | 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /migrations/2019-04-08-015947_create_user_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_view; 2 | 3 | -------------------------------------------------------------------------------- /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/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/2019-06-01-222649_remove_admin/up.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM user_ 2 | WHERE name LIKE 'admin'; 3 | 4 | -------------------------------------------------------------------------------- /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/2019-10-15-181630_add_themes/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | DROP COLUMN theme; 3 | 4 | -------------------------------------------------------------------------------- /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-10-19-052737_create_user_mention/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_mention_view; 2 | 3 | DROP TABLE user_mention; 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/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/2019-10-24-002614_create_password_reset_request/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE password_reset_request; 2 | 3 | -------------------------------------------------------------------------------- /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/2019-12-09-060754_add_lang/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | DROP COLUMN lang; 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/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/2020-01-29-030825_create_user_mention_materialized_view/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_mention_mview; 2 | 3 | -------------------------------------------------------------------------------- /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-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/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/2020-04-03-194936_add_activitypub_for_posts_and_comments/up.sql: -------------------------------------------------------------------------------- 1 | -- Add federation columns to post, comment 2 | ALTER TABLE post 3 | -- TODO uniqueness constraints should be added on these 3 columns later 4 | ADD COLUMN ap_id character varying(255) NOT NULL DEFAULT 'http://fake.com', -- This needs to be checked and updated in code, building from the site url if local 5 | ADD COLUMN local boolean NOT NULL DEFAULT TRUE; 6 | 7 | ALTER TABLE comment 8 | -- TODO uniqueness constraints should be added on these 3 columns later 9 | ADD COLUMN ap_id character varying(255) NOT NULL DEFAULT 'http://fake.com', -- This needs to be checked and updated in code, building from the site url if local 10 | ADD COLUMN local boolean NOT NULL DEFAULT TRUE; 11 | 12 | -------------------------------------------------------------------------------- /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/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-09-07-231141_add_migration_utils/down.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA utils CASCADE; 2 | 3 | -------------------------------------------------------------------------------- /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/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/2020-11-05-152724_activity_remove_user_id/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE activity 2 | ADD COLUMN user_id integer; 3 | 4 | ALTER TABLE activity 5 | DROP COLUMN sensitive; 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/2020-11-10-150835_community_follower_pending/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community_follower 2 | DROP COLUMN pending; 3 | 4 | -------------------------------------------------------------------------------- /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/2020-11-26-134531_delete_user/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_ 2 | DROP COLUMN deleted; 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/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 | -------------------------------------------------------------------------------- /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/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/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/2020-12-17-030456_create_alias_views/down.sql: -------------------------------------------------------------------------------- 1 | DROP VIEW user_alias_1, user_alias_2, comment_alias_1; 2 | 3 | -------------------------------------------------------------------------------- /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/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/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-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/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/2021-01-31-050334_add_forum_sort_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_post_aggregates_comments; 2 | 3 | -------------------------------------------------------------------------------- /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-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/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-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/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-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/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/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-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-03-20-185321_move_matrix_id_to_person/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN matrix_user_id text; 3 | 4 | ALTER TABLE local_user 5 | ADD COLUMN admin boolean DEFAULT FALSE NOT NULL; 6 | 7 | UPDATE 8 | local_user lu 9 | SET 10 | matrix_user_id = p.matrix_user_id, 11 | admin = p.admin 12 | FROM 13 | person p 14 | WHERE 15 | p.id = lu.person_id; 16 | 17 | DROP VIEW person_alias_1, person_alias_2; 18 | 19 | ALTER TABLE person 20 | DROP COLUMN matrix_user_id; 21 | 22 | ALTER TABLE person 23 | DROP COLUMN admin; 24 | 25 | -- Regenerate the person_alias views 26 | CREATE VIEW person_alias_1 AS 27 | SELECT 28 | * 29 | FROM 30 | person; 31 | 32 | CREATE VIEW person_alias_2 AS 33 | SELECT 34 | * 35 | FROM 36 | person; 37 | 38 | -------------------------------------------------------------------------------- /migrations/2021-03-20-185321_move_matrix_id_to_person/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person 2 | ADD COLUMN matrix_user_id text; 3 | 4 | ALTER TABLE person 5 | ADD COLUMN admin boolean DEFAULT FALSE NOT NULL; 6 | 7 | UPDATE 8 | person p 9 | SET 10 | matrix_user_id = lu.matrix_user_id, 11 | admin = lu.admin 12 | FROM 13 | local_user lu 14 | WHERE 15 | p.id = lu.person_id; 16 | 17 | ALTER TABLE local_user 18 | DROP COLUMN matrix_user_id; 19 | 20 | ALTER TABLE local_user 21 | DROP COLUMN admin; 22 | 23 | -- Regenerate the person_alias views 24 | DROP VIEW person_alias_1, person_alias_2; 25 | 26 | CREATE VIEW person_alias_1 AS 27 | SELECT 28 | * 29 | FROM 30 | person; 31 | 32 | CREATE VIEW person_alias_2 AS 33 | SELECT 34 | * 35 | FROM 36 | person; 37 | 38 | -------------------------------------------------------------------------------- /migrations/2021-03-31-103917_add_show_score_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN show_scores; 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/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-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/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/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/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-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 | -------------------------------------------------------------------------------- /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/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/2021-04-02-021422_remove_community_creator/down.sql: -------------------------------------------------------------------------------- 1 | -- Add the column back 2 | ALTER TABLE community 3 | ADD COLUMN creator_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE; 4 | 5 | -- Recreate the index 6 | CREATE INDEX idx_community_creator ON community (creator_id); 7 | 8 | -- Add the data, selecting the highest mod 9 | UPDATE 10 | community 11 | SET 12 | creator_id = sub.person_id 13 | FROM ( 14 | SELECT 15 | cm.community_id, 16 | cm.person_id 17 | FROM 18 | community_moderator cm 19 | LIMIT 1) AS sub 20 | WHERE 21 | id = sub.community_id; 22 | 23 | -- Set to not null 24 | ALTER TABLE community 25 | ALTER COLUMN creator_id SET NOT NULL; 26 | 27 | -------------------------------------------------------------------------------- /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-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-04-24-174047_add_show_read_post_setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN show_read_posts; 3 | 4 | -------------------------------------------------------------------------------- /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-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-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/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 | -------------------------------------------------------------------------------- /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/2021-08-04-223559_create_user_community_block/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE person_block ( 2 | id serial PRIMARY KEY, 3 | person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 4 | target_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 5 | published timestamp NOT NULL DEFAULT now(), 6 | UNIQUE (person_id, target_id) 7 | ); 8 | 9 | CREATE TABLE community_block ( 10 | id serial PRIMARY KEY, 11 | person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 12 | community_id int REFERENCES community ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 13 | published timestamp NOT NULL DEFAULT now(), 14 | UNIQUE (person_id, community_id) 15 | ); 16 | 17 | -------------------------------------------------------------------------------- /migrations/2021-08-17-210508_create_mod_transfer_community/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE mod_transfer_community; 2 | 3 | -------------------------------------------------------------------------------- /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/2021-09-20-112945_jwt-secret/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE secret; 2 | 3 | -------------------------------------------------------------------------------- /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/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-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/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/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/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-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/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/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/2021-11-23-132840_email_verification/up.sql: -------------------------------------------------------------------------------- 1 | -- use defaults from db for local user init 2 | ALTER TABLE local_user 3 | ALTER COLUMN theme SET DEFAULT 'browser'; 4 | 5 | ALTER TABLE local_user 6 | ALTER COLUMN default_listing_type SET DEFAULT 2; 7 | 8 | -- add tables and columns for optional email verification 9 | ALTER TABLE site 10 | ADD COLUMN require_email_verification boolean NOT NULL DEFAULT FALSE; 11 | 12 | ALTER TABLE local_user 13 | ADD COLUMN email_verified boolean NOT NULL DEFAULT FALSE; 14 | 15 | CREATE TABLE email_verification ( 16 | id serial PRIMARY KEY, 17 | local_user_id int REFERENCES local_user (id) ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 18 | email text NOT NULL, 19 | verification_token text NOT NULL 20 | ); 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 | -------------------------------------------------------------------------------- /migrations/2021-12-09-225529_add_published_to_email_verification/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE email_verification 2 | DROP COLUMN published; 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/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/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/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-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/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/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-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-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/2022-02-01-154240_add_community_title_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_community_title; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-02-01-154240_add_community_title_index/up.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX idx_community_title ON community (title); 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-02-18-210946_default_theme/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN default_theme; 3 | 4 | -------------------------------------------------------------------------------- /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/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/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/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-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-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/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/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 | -------------------------------------------------------------------------------- /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-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-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-05-20-135341_embed-url/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN embed_url; 3 | 4 | ALTER TABLE post 5 | ADD COLUMN embed_video_url 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-06-12-012121_add_site_hide_modlog_names/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN hide_modlog_mod_names; 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/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/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/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/2022-08-04-150644_add_application_email_admins/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP COLUMN application_email_admins; 3 | 4 | -------------------------------------------------------------------------------- /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/2022-08-04-214722_add_distinguished_comment/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | DROP COLUMN distinguished; 3 | 4 | -------------------------------------------------------------------------------- /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/2022-08-05-203502_add_person_post_aggregates/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_post_aggregates; 2 | 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /migrations/2022-08-22-193848_comment-language-tags/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment 2 | DROP COLUMN language_id; 3 | 4 | -------------------------------------------------------------------------------- /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-09-07-113813_drop_ccnew_indexes_function/down.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION drop_ccnew_indexes; 2 | 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /migrations/2022-09-07-114618_pm-reports/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE private_message_report; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2022-09-07-114618_pm-reports/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE private_message_report ( 2 | id serial PRIMARY KEY, 3 | creator_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, -- user reporting comment 4 | private_message_id int REFERENCES private_message ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, -- comment being reported 5 | original_pm_text text NOT NULL, 6 | reason text NOT NULL, 7 | resolved bool NOT NULL DEFAULT FALSE, 8 | resolver_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE, -- user resolving report 9 | published timestamp NOT NULL DEFAULT now(), 10 | updated timestamp NULL, 11 | UNIQUE (private_message_id, creator_id) -- users should only be able to report a pm once 12 | ); 13 | 14 | -------------------------------------------------------------------------------- /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/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/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/2022-11-13-181529_create_taglines/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE tagline; 2 | 3 | -------------------------------------------------------------------------------- /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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/2023-02-05-102549_drop-site-federation-debug/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN federation_debug int DEFAULT 0; 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-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-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/2023-02-11-173347_custom_emojis/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE custom_emoji_keyword; 2 | 3 | DROP TABLE custom_emoji; 4 | 5 | -------------------------------------------------------------------------------- /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-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-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/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/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-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 | -------------------------------------------------------------------------------- /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-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-05-10-095739_force_enable_undetermined_language/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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-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-06-19-055530_add_retry_worker_setting/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN federation_worker_count; 3 | 4 | -------------------------------------------------------------------------------- /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/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-21-153242_add_captcha/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE captcha_answer; 2 | 3 | -------------------------------------------------------------------------------- /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-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-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-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-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 | -------------------------------------------------------------------------------- /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-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-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 | -------------------------------------------------------------------------------- /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-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/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-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/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/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-10-075550_add-infinite-scroll-setting/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN infinite_scroll_enabled; 3 | 4 | -------------------------------------------------------------------------------- /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/2023-07-11-084714_receive_activity_table/down.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE activity ( 2 | id serial PRIMARY KEY, 3 | data jsonb NOT NULL, 4 | local boolean NOT NULL DEFAULT TRUE, 5 | published timestamp NOT NULL DEFAULT now(), 6 | updated timestamp, 7 | ap_id text NOT NULL, 8 | sensitive boolean NOT NULL DEFAULT TRUE 9 | ); 10 | 11 | INSERT INTO activity (ap_id, data, sensitive, published) 12 | SELECT 13 | ap_id, 14 | data, 15 | sensitive, 16 | published 17 | FROM 18 | sent_activity 19 | ORDER BY 20 | id DESC 21 | LIMIT 100000; 22 | 23 | -- We cant copy received_activity entries back into activities table because we dont have data 24 | -- which is mandatory. 25 | DROP TABLE sent_activity; 26 | 27 | DROP TABLE received_activity; 28 | 29 | -------------------------------------------------------------------------------- /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/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/2023-07-18-082614_post_aggregates_community_id/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | CREATE OR REPLACE FUNCTION post_aggregates_post () 3 | RETURNS TRIGGER 4 | LANGUAGE plpgsql 5 | AS $$ 6 | BEGIN 7 | IF (TG_OP = 'INSERT') THEN 8 | INSERT INTO post_aggregates (post_id, published, newest_comment_time, newest_comment_time_necro) 9 | VALUES (NEW.id, NEW.published, NEW.published, NEW.published); 10 | ELSIF (TG_OP = 'DELETE') THEN 11 | DELETE FROM post_aggregates 12 | WHERE post_id = OLD.id; 13 | END IF; 14 | RETURN NULL; 15 | END 16 | $$; 17 | 18 | ALTER TABLE post_aggregates 19 | DROP COLUMN community_id, 20 | DROP COLUMN creator_id; 21 | 22 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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/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/2023-08-09-101305_user_instance_block/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE instance_block; 2 | 3 | ALTER TABLE post_aggregates 4 | DROP COLUMN instance_id; 5 | 6 | CREATE OR REPLACE FUNCTION post_aggregates_post () 7 | RETURNS TRIGGER 8 | LANGUAGE plpgsql 9 | AS $$ 10 | BEGIN 11 | IF (TG_OP = 'INSERT') THEN 12 | INSERT INTO post_aggregates (post_id, published, newest_comment_time, newest_comment_time_necro, community_id, creator_id) 13 | VALUES (NEW.id, NEW.published, NEW.published, NEW.published, NEW.community_id, NEW.creator_id); 14 | ELSIF (TG_OP = 'DELETE') THEN 15 | DELETE FROM post_aggregates 16 | WHERE post_id = OLD.id; 17 | END IF; 18 | RETURN NULL; 19 | END 20 | $$; 21 | 22 | -------------------------------------------------------------------------------- /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-08-31-205559_add_image_upload/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE image_upload; 2 | 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/2023-09-12-194850_add_federation_worker_index/down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX idx_person_local_instance; 2 | 3 | -------------------------------------------------------------------------------- /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/2023-09-18-141700_login-token/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE login_token; 2 | 3 | ALTER TABLE local_user 4 | ADD COLUMN validator_time timestamp NOT NULL DEFAULT now(); 5 | 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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/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-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-10-17-181800_drop_remove_community_expires/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_remove_community 2 | ADD COLUMN expires timestamp; 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-23-184941_hot_rank_greatest_fix/down.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION hot_rank (score numeric, published timestamp with time zone) 2 | RETURNS float 3 | AS $$ 4 | DECLARE 5 | hours_diff numeric := EXTRACT(EPOCH FROM (now() - published)) / 3600; 6 | BEGIN 7 | -- 24 * 7 = 168, so after a week, it will default to 0. 8 | IF (hours_diff > 0 AND hours_diff < 168) THEN 9 | RETURN log(greatest (1, score + 3)) / power((hours_diff + 2), 1.8); 10 | ELSE 11 | -- if the post is from the future, set hot score to 0. otherwise you can game the post to 12 | -- always be on top even with only 1 vote by setting it to the future 13 | RETURN 0.0; 14 | END IF; 15 | END; 16 | $$ 17 | LANGUAGE plpgsql 18 | IMMUTABLE PARALLEL SAFE; 19 | 20 | -------------------------------------------------------------------------------- /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/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/2023-10-24-140438_enable_private_messages/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN enable_private_messages; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2023-10-24-140438_enable_private_messages/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN enable_private_messages boolean DEFAULT TRUE NOT NULL; 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/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/2023-10-27-142514_post_url_content_type/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN url_content_type; 3 | 4 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/2023-11-02-120140_apub-signed-fetch/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN federation_signed_fetch; 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/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 | -------------------------------------------------------------------------------- /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/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/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/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-01-02-094916_site-name-not-unique/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE site 2 | DROP CONSTRAINT site_name_key; 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/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/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/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/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/2024-02-12-211114_add_vote_display_mode_setting/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE local_user_vote_display_mode; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-02-12-211114_add_vote_display_mode_setting/up.sql: -------------------------------------------------------------------------------- 1 | -- Create an extra table to hold local user vote display settings 2 | -- Score and Upvote percentage are turned on by default. 3 | CREATE TABLE local_user_vote_display_mode ( 4 | local_user_id int REFERENCES local_user ON UPDATE CASCADE ON DELETE CASCADE NOT NULL, 5 | score boolean DEFAULT TRUE NOT NULL, 6 | upvotes boolean DEFAULT FALSE NOT NULL, 7 | downvotes boolean DEFAULT FALSE NOT NULL, 8 | upvote_percentage boolean DEFAULT TRUE NOT NULL, 9 | PRIMARY KEY (local_user_id) 10 | ); 11 | 12 | -- Insert rows for every local user 13 | INSERT INTO local_user_vote_display_mode (local_user_id) 14 | SELECT 15 | id 16 | FROM 17 | local_user; 18 | 19 | -------------------------------------------------------------------------------- /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-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/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/2024-02-28-144211_hide_posts/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE post_hide; 2 | 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /migrations/2024-03-04-143245_remove_show_scores_column/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN show_scores boolean NOT NULL DEFAULT TRUE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-03-04-143245_remove_show_scores_column/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN show_scores; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-03-06-104706_local_image_user_opt/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_image 2 | ALTER COLUMN local_user_id SET NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /migrations/2024-04-08-204327_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/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/2024-05-04-140749_separate_triggers/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 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/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/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 | -------------------------------------------------------------------------------- /migrations/2024-06-17-160323_fix_post_aggregates_featured_local/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ; 3 | 4 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /migrations/2024-09-12-130204_drop-enable-nsfw/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN enable_nsfw boolean NOT NULL DEFAULT FALSE; 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 | -------------------------------------------------------------------------------- /migrations/2024-09-12-130204_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 | -------------------------------------------------------------------------------- /migrations/2024-09-16-000000_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/2024-09-16-095656_schedule-post/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN scheduled_publish_time; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-09-16-095656_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/2024-09-16-174833_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/2024-09-23-133038_remove_auto_expand/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | ADD COLUMN auto_expand boolean NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-09-23-133038_remove_auto_expand/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_user 2 | DROP COLUMN auto_expand; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-10-16-141718_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 | -------------------------------------------------------------------------------- /migrations/2024-10-16-141718_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/2024-10-18-074533_no-individual-inboxes/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person 2 | ADD COLUMN shared_inbox_url varchar(255); 3 | 4 | ALTER TABLE community 5 | ADD COLUMN shared_inbox_url varchar(255); 6 | 7 | -------------------------------------------------------------------------------- /migrations/2024-10-23-091053_comment-vote-remote-postid/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment_like 2 | ADD COLUMN post_id int; 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 | -------------------------------------------------------------------------------- /migrations/2024-10-23-091053_comment-vote-remote-postid/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE comment_like 2 | DROP post_id; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-11-01-233231_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/2024-11-01-233231_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/2024-11-12-090437_move-triggers/up.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION community_aggregates_activity, site_aggregates_activity CASCADE; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-11-18-012112_forbid_diesel_cli/down.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION forbid_diesel_cli CASCADE; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-11-18-012113_custom_migration_runner/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE previously_run_sql; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-11-18-012113_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/2024-11-21-195004_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/2024-11-23-234637_oauth_pkce/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE oauth_provider 2 | DROP COLUMN use_pkce; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-11-23-234637_oauth_pkce/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE oauth_provider 2 | ADD COLUMN use_pkce boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-11-25-161129_add_blurhash_to_image_details/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE image_details 2 | DROP COLUMN blurhash; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-11-25-161129_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/2024-11-28-142005_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/2024-12-02-181601_add_report_combined_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE report_combined; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-12-05-233704_add_person_content_combined_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_content_combined; 2 | 3 | DROP TABLE person_saved_combined; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2024-12-10-193418_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/2024-12-12-222846_add_search_combined_table/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE person_aggregates 2 | DROP COLUMN published; 3 | 4 | DROP TABLE search_combined; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2024-12-15-151642_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/2024-12-15-151642_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/2024-12-17-144959_community-post-tags/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE post_tag; 2 | 3 | DROP TABLE tag; 4 | 5 | -------------------------------------------------------------------------------- /migrations/2024-12-18-200602_optimize_get_random_community/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN random_number; 3 | 4 | DROP FUNCTION random_smallint; 5 | 6 | -------------------------------------------------------------------------------- /migrations/2024-12-20-090225_update-replaceable-schema/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-12-20-090225_update-replaceable-schema/up.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2024-12-27-220142_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 | -------------------------------------------------------------------------------- /migrations/2024-12-29-203717_add_post_keyword_block_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE local_user_keyword_block; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2024-12-29-203717_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 | -------------------------------------------------------------------------------- /migrations/2025-01-09-144233_no-image-token/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_image 2 | ADD COLUMN pictrs_delete_token text NOT NULL DEFAULT ''; 3 | 4 | ALTER TABLE local_image 5 | ALTER COLUMN pictrs_delete_token DROP DEFAULT; 6 | 7 | ALTER TABLE local_image 8 | ADD COLUMN published_new timestamp with time zone DEFAULT now() NOT NULL; 9 | 10 | UPDATE 11 | local_image 12 | SET 13 | published_new = published; 14 | 15 | ALTER TABLE local_image 16 | DROP COLUMN published; 17 | 18 | ALTER TABLE local_image RENAME published_new TO published; 19 | 20 | -------------------------------------------------------------------------------- /migrations/2025-01-09-144233_no-image-token/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_image 2 | DROP COLUMN pictrs_delete_token; 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-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-01-14-023145_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-01-14-023145_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-01-21-000000_interactions_per_month_schema/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community_aggregates 2 | DROP COLUMN interactions_month; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-01-21-000000_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-01-23-143621_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/2025-01-23-143621_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/2025-02-05-090155_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-02-05-090155_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 | -------------------------------------------------------------------------------- /migrations/2025-02-11-131045_ban-remove-content-pm/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE private_message 2 | DROP COLUMN removed; 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-02-18-143408_block_nsfw/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN disallow_nsfw_content; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-02-18-143408_block_nsfw/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN disallow_nsfw_content boolean DEFAULT FALSE NOT NULL; 3 | 4 | -------------------------------------------------------------------------------- /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-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-03-07-094522_enable_english_for_all/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | 1; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-03-07-094522_enable_english_for_all/up.sql: -------------------------------------------------------------------------------- 1 | -- enable english for all users on instances with all languages enabled. 2 | -- Fix for https://github.com/LemmyNet/lemmy/pull/5485 3 | DO $$ 4 | BEGIN 5 | IF ( 6 | SELECT 7 | count(*) 8 | FROM 9 | site_language 10 | INNER JOIN local_site ON site_language.site_id = local_site.site_id) = 184 THEN 11 | INSERT INTO local_user_language (local_user_id, language_id) 12 | SELECT 13 | local_user_id, 14 | 37 15 | FROM 16 | local_user_language 17 | GROUP BY 18 | local_user_id 19 | HAVING 20 | NOT (37 = ANY (array_agg(language_id))); 21 | END IF; 22 | END 23 | $$ 24 | -------------------------------------------------------------------------------- /migrations/2025-03-11-015056_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-03-11-015056_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/2025-03-13-112516_community-local-removed/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE community 2 | DROP COLUMN local_removed; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-03-13-112516_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-03-13-112517_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-03-13-112517_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 | -------------------------------------------------------------------------------- /migrations/2025-03-25-221304_remove_post_instance_id/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE post 2 | DROP COLUMN instance_id; 3 | 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /migrations/2025-04-07-141445_disable-email-notifications/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN disable_email_notifications; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-04-07-141445_disable-email-notifications/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | ADD COLUMN disable_email_notifications bool NOT NULL DEFAULT FALSE; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-04-10-234244_add_liked_combined/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE person_liked_combined; 2 | 3 | -------------------------------------------------------------------------------- /migrations/2025-04-25-183519_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 | -------------------------------------------------------------------------------- /migrations/2025-04-25-183519_show_downvotes_for_others_only/up.sql: -------------------------------------------------------------------------------- 1 | -- This changes the local_user.show_downvotes column to an enum, 2 | -- which by default shows all downvotes. 3 | CREATE TYPE vote_show_enum AS ENUM ( 4 | 'Show', 5 | 'ShowForOthers', 6 | 'Hide' 7 | ); 8 | 9 | ALTER TABLE local_user 10 | ALTER COLUMN show_downvotes DROP DEFAULT; 11 | 12 | ALTER TABLE local_user 13 | ALTER COLUMN show_downvotes TYPE vote_show_enum 14 | USING 15 | CASE show_downvotes 16 | WHEN FALSE THEN 17 | 'Hide' 18 | ELSE 19 | 'Show' 20 | END::vote_show_enum; 21 | 22 | -- Make ShowForOthers the default 23 | ALTER TABLE local_user 24 | ALTER COLUMN show_downvotes SET DEFAULT 'Show'; 25 | 26 | -------------------------------------------------------------------------------- /migrations/2025-05-08-161908_lock_reason/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_lock_post 2 | DROP COLUMN reason; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-05-08-161908_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-05-15-143802_remove_hide_modlog_names/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE local_site 2 | DROP COLUMN hide_modlog_mod_names; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-05-26-092442_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/2025-05-26-092442_mod-change-community-vis/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE mod_change_community_visibility 2 | DROP COLUMN reason; 3 | 4 | -------------------------------------------------------------------------------- /migrations/2025-05-30-225731_error_if_code_migrations_needed/down.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ; 3 | 4 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["config:recommended"], 4 | "schedule": ["before 4am on the first day of the month"], 5 | "automerge": true, 6 | "rebaseWhen": "conflicted", 7 | "packageRules": [ 8 | { 9 | "groupName": "docker", 10 | "matchDatasources": ["docker"] 11 | }, 12 | { 13 | "groupName": "npm", 14 | "matchDatasources": ["npm"] 15 | } 16 | ], 17 | "ignoreDeps": ["lemmy-js-client", "pgautoupgrade/pgautoupgrade"], 18 | "ignorePaths": ["(^|/)Cargo\\.toml$"] 19 | } 20 | -------------------------------------------------------------------------------- /scripts/alpine_install_pg_formatter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | version=5.6 5 | wget https://github.com/darold/pgFormatter/archive/refs/tags/v${version}.tar.gz 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /scripts/db_perf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script runs crates/lemmy_db_perf/src/main.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=config/config.hjson 14 | export RUST_BACKTRACE=1 15 | 16 | cargo run --package lemmy_db_perf -- "$@" 17 | 18 | pg_ctl stop --silent 19 | 20 | # $PGDATA directory is kept so log can be seen 21 | -------------------------------------------------------------------------------- /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_server -- migration --all run 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 | -------------------------------------------------------------------------------- /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/db_schema_file/replaceable_schema -type f -name '*.sql' -exec pg_format -i {} + 16 | 17 | cargo clippy --workspace --fix --allow-staged --allow-dirty --tests --all-targets --all-features -- -D warnings 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/db_schema_file/replaceable_schema/. $TMP_DIR/replaceable_schema 14 | 15 | # Format the new files 16 | find $TMP_DIR -type f -name '*.sql' -exec pg_format -i {} + 17 | 18 | # Diff the directories 19 | diff -r migrations $TMP_DIR/migrations 20 | diff -r crates/db_schema_file/replaceable_schema $TMP_DIR/replaceable_schema 21 | -------------------------------------------------------------------------------- /scripts/ts_bindings_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 | # Export the ts-rs bindings 11 | cargo test --workspace export_bindings 12 | 13 | # Make sure no rows are returned 14 | ! grep -nr --include=\*.ts ' | null' ./crates/ 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------