diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000000..4ae31f2169 --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,9 @@ +{ + "features": { + "ghcr.io/devcontainers/features/sshd:1": { + "version": "1.1.0", + "resolved": "ghcr.io/devcontainers/features/sshd@sha256:f5251b8e4325f68f7280973c6cd65daff414449c66f240621502d4e8e74eb7ee", + "integrity": "sha256:f5251b8e4325f68f7280973c6cd65daff414449c66f240621502d4e8e74eb7ee" + } + } +} diff --git a/.github/ISSUE_TEMPLATE/2.server_bug_report.yml b/.github/ISSUE_TEMPLATE/2.server_bug_report.yml index baf95e2857..cad697aa5a 100644 --- a/.github/ISSUE_TEMPLATE/2.server_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/2.server_bug_report.yml @@ -59,7 +59,7 @@ body: Any additional technical details you may have, like logs or error traces value: | If this is happening on your own Mastodon server, please fill out those: - - Ruby version: (from `ruby --version`, eg. v4.0.5) + - Ruby version: (from `ruby --version`, eg. v4.0.6) - Node.js version: (from `node --version`, eg. v22.16.0) validations: required: false diff --git a/.github/ISSUE_TEMPLATE/3.troubleshooting.yml b/.github/ISSUE_TEMPLATE/3.troubleshooting.yml index ea1963abc2..09b7afc0f3 100644 --- a/.github/ISSUE_TEMPLATE/3.troubleshooting.yml +++ b/.github/ISSUE_TEMPLATE/3.troubleshooting.yml @@ -60,7 +60,7 @@ body: value: | Please at least include those informations: - Operating system: (eg. Ubuntu 24.04.2) - - Ruby version: (from `ruby --version`, eg. v4.0.5) + - Ruby version: (from `ruby --version`, eg. v4.0.6) - Node.js version: (from `node --version`, eg. v22.16.0) validations: required: false diff --git a/.github/actions/setup-javascript/action.yml b/.github/actions/setup-javascript/action.yml index 0188c2edd9..8c355b6eb2 100644 --- a/.github/actions/setup-javascript/action.yml +++ b/.github/actions/setup-javascript/action.yml @@ -9,7 +9,7 @@ runs: using: 'composite' steps: - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 with: node-version-file: '.nvmrc' @@ -23,7 +23,7 @@ runs: shell: bash run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + - uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 076b2f9b1e..dcf908de87 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -8,16 +8,35 @@ ':enableVulnerabilityAlertsWithLabel(security)', ], rebaseWhen: 'conflicted', - minimumReleaseAge: '3', // Wait 3 days after the package has been published before upgrading it + minimumReleaseAge: '3 days', // Wait 3 days after the package has been published before upgrading it + prCreation: 'not-pending', // packageRules order is important, they are applied from top to bottom and are merged, // meaning the most important ones must be at the bottom, for example grouping rules // If we do not want a package to be grouped with others, we need to set its groupName // to `null` after any other rule set it to something. dependencyDashboardHeader: 'This issue lists Renovate updates and detected dependencies. Read the [Dependency Dashboard](https://docs.renovatebot.com/key-concepts/dashboard/) docs to learn more. Before approving any upgrade: read the description and comments in the [`renovate.json5` file](https://github.com/mastodon/mastodon/blob/main/.github/renovate.json5).', postUpdateOptions: ['yarnDedupeHighest'], + devcontainer: { + managerFilePatterns: [ + '/^\.devcontainer\/devcontainer\.json$/', + '/^\.devcontainer\.json$/', + '/^\.devcontainer\/devcontainer-lock\.json$/', + ], + }, // The types are now included in recent versions,we ignore them here until we upgrade and remove the dependency ignoreDeps: ['@types/emoji-mart'], + lockFileMaintenance: { + enabled: true, + schedule: ['before 8am on monday'], + }, packageRules: [ + { + // Disable lock file maintenance for bundler for now, as we do not yet pin gems to their exact versions + matchManagers: ['bundler'], + lockFileMaintenance: { + enabled: false, + }, + }, { // Require Dependency Dashboard Approval for major version bumps of these node packages matchManagers: ['npm'], @@ -25,9 +44,6 @@ // react-router: Requires manual upgrade 'history', 'react-router-dom', - - // react-spring: Requires manual upgrade when upgrading react - '@react-spring/web', ], matchUpdateTypes: ['major'], dependencyDashboardApproval: true, diff --git a/.github/workflows/build-container-image.yml b/.github/workflows/build-container-image.yml index 8db68a7cda..7924655f34 100644 --- a/.github/workflows/build-container-image.yml +++ b/.github/workflows/build-container-image.yml @@ -35,7 +35,7 @@ jobs: - linux/arm64 steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Prepare env: @@ -120,7 +120,7 @@ jobs: PUSH_TO_IMAGES: ${{ inputs.push_to_images }} steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Download digests uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 diff --git a/.github/workflows/build-push-pr.yml b/.github/workflows/build-push-pr.yml index aa3ca56ce4..252175c2c8 100644 --- a/.github/workflows/build-push-pr.yml +++ b/.github/workflows/build-push-pr.yml @@ -18,7 +18,7 @@ jobs: steps: # Repository needs to be cloned so `git rev-parse` below works - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - id: version_vars run: | echo mastodon_version_metadata=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short ${{github.event.pull_request.head.sha}}) >> $GITHUB_OUTPUT diff --git a/.github/workflows/build-releases.yml b/.github/workflows/build-releases.yml index b07ec8cf77..ca19a529d8 100644 --- a/.github/workflows/build-releases.yml +++ b/.github/workflows/build-releases.yml @@ -16,7 +16,7 @@ jobs: steps: # Repository needs to be cloned to list branches - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: fetch-depth: 0 diff --git a/.github/workflows/bundler-audit.yml b/.github/workflows/bundler-audit.yml index e94aaa1b73..169def3b02 100644 --- a/.github/workflows/bundler-audit.yml +++ b/.github/workflows/bundler-audit.yml @@ -29,7 +29,7 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Ruby uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0 diff --git a/.github/workflows/check-i18n.yml b/.github/workflows/check-i18n.yml index ea5ab4bb7e..bd77ec5dbe 100644 --- a/.github/workflows/check-i18n.yml +++ b/.github/workflows/check-i18n.yml @@ -22,7 +22,7 @@ jobs: timeout-minutes: 15 steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Ruby environment uses: ./.github/actions/setup-ruby diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 7e6514673d..0068fc2d12 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -17,11 +17,11 @@ jobs: changed: ${{ steps.filter.outputs.src }} steps: - name: Checkout code - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: fetch-depth: 0 - - uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3 + - uses: dorny/paths-filter@0e4a8c6effa4802afeda77dc8d303f8176d7dfad # v3 id: filter with: filters: | @@ -44,7 +44,7 @@ jobs: if: github.repository == 'mastodon/mastodon' && needs.pathcheck.outputs.changed == 'true' steps: - name: Checkout code - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: fetch-depth: 0 @@ -55,7 +55,7 @@ jobs: run: yarn build-storybook - name: Run Chromatic - uses: chromaui/action@07791f8243f4cb2698bf4d00426baf4b2d1cb7e0 # v13 + uses: chromaui/action@98132da0fca2211fb41b3af7b49ce85176007851 # v17 with: projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} zip: true diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0ba1d244dd..fea0b4679a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,11 +32,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4 + uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -49,7 +49,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4 + uses: github/codeql-action/autobuild@5595ccaf912efad79be6eef63a5619ff05969be3 # v4 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -62,6 +62,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4 + uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4 with: category: '/language:${{matrix.language}}' diff --git a/.github/workflows/crowdin-download-stable.yml b/.github/workflows/crowdin-download-stable.yml index 684774c238..529bf31bb8 100644 --- a/.github/workflows/crowdin-download-stable.yml +++ b/.github/workflows/crowdin-download-stable.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Increase Git http.postBuffer # This is needed due to a bug in Ubuntu's cURL version? @@ -24,7 +24,7 @@ jobs: # Download the translation files from Crowdin - name: crowdin action - uses: crowdin/github-action@8868a33591d21088edfc398968173a3b98d51706 # v2 + uses: crowdin/github-action@c7af9bc98b01694653031fef2a0dc6c7888ce9bc # v2 with: config: crowdin-glitch.yml upload_sources: false @@ -64,7 +64,7 @@ jobs: This PR will be updated every day with new translations. Due to a limitation in GitHub Actions, checks are not running on this PR without manual action. - If you want to run the checks, then close and re-open it. + If you want to run the checks, then please press “Approve workflows to run”. branch: i18n/crowdin/translations-${{ github.base_ref || github.ref_name }} base: ${{ github.base_ref || github.ref_name }} labels: i18n diff --git a/.github/workflows/crowdin-download.yml b/.github/workflows/crowdin-download.yml index d0dbaf096e..4b040821c9 100644 --- a/.github/workflows/crowdin-download.yml +++ b/.github/workflows/crowdin-download.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Increase Git http.postBuffer # This is needed due to a bug in Ubuntu's cURL version? @@ -26,7 +26,7 @@ jobs: # Download the translation files from Crowdin - name: crowdin action - uses: crowdin/github-action@8868a33591d21088edfc398968173a3b98d51706 # v2 + uses: crowdin/github-action@c7af9bc98b01694653031fef2a0dc6c7888ce9bc # v2 with: config: crowdin-glitch.yml upload_sources: false @@ -66,7 +66,7 @@ jobs: This PR will be updated every day with new translations. Due to a limitation in GitHub Actions, checks are not running on this PR without manual action. - If you want to run the checks, then close and re-open it. + If you want to run the checks, then please press “Approve workflows to run”. branch: i18n/crowdin/translations base: main labels: i18n diff --git a/.github/workflows/crowdin-upload.yml b/.github/workflows/crowdin-upload.yml index f648871d6a..ce20a287af 100644 --- a/.github/workflows/crowdin-upload.yml +++ b/.github/workflows/crowdin-upload.yml @@ -23,10 +23,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: crowdin action - uses: crowdin/github-action@8868a33591d21088edfc398968173a3b98d51706 # v2 + uses: crowdin/github-action@c7af9bc98b01694653031fef2a0dc6c7888ce9bc # v2 with: config: crowdin-glitch.yml upload_sources: true diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 5d06f81ee2..ee4b262acd 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Javascript environment uses: ./.github/actions/setup-javascript diff --git a/.github/workflows/lint-css.yml b/.github/workflows/lint-css.yml index dbd9fc6182..e69fdc15e8 100644 --- a/.github/workflows/lint-css.yml +++ b/.github/workflows/lint-css.yml @@ -31,7 +31,7 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Javascript environment uses: ./.github/actions/setup-javascript diff --git a/.github/workflows/lint-haml.yml b/.github/workflows/lint-haml.yml index a3dba81176..a3ac8a5037 100644 --- a/.github/workflows/lint-haml.yml +++ b/.github/workflows/lint-haml.yml @@ -32,7 +32,7 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Ruby uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0 diff --git a/.github/workflows/lint-js.yml b/.github/workflows/lint-js.yml index 93cbb2d73d..65c305604c 100644 --- a/.github/workflows/lint-js.yml +++ b/.github/workflows/lint-js.yml @@ -37,7 +37,7 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Javascript environment uses: ./.github/actions/setup-javascript diff --git a/.github/workflows/lint-ruby.yml b/.github/workflows/lint-ruby.yml index 9d88cb964d..0c57030baf 100644 --- a/.github/workflows/lint-ruby.yml +++ b/.github/workflows/lint-ruby.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Ruby uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0 diff --git a/.github/workflows/test-js.yml b/.github/workflows/test-js.yml index 5a78fd2997..5a3c578899 100644 --- a/.github/workflows/test-js.yml +++ b/.github/workflows/test-js.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Javascript environment uses: ./.github/actions/setup-javascript diff --git a/.github/workflows/test-migrations.yml b/.github/workflows/test-migrations.yml index 4d0c4b811a..79268f3e60 100644 --- a/.github/workflows/test-migrations.yml +++ b/.github/workflows/test-migrations.yml @@ -73,7 +73,7 @@ jobs: BUNDLE_RETRY: 3 steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Ruby environment uses: ./.github/actions/setup-ruby @@ -104,8 +104,8 @@ jobs: bin/rails db:create SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails tests:migrations:prepare_database - # Migrate up to v4.2.0 breakpoint - bin/rails db:migrate VERSION=20230907150100 + # Migrate up to v4.3.0 breakpoint + bin/rails db:migrate VERSION=20241007071624 # Migrate the rest SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails db:migrate diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index ff236d04c9..117d6df56f 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -18,22 +18,17 @@ concurrency: jobs: build: + name: build (production) runs-on: ubuntu-latest timeout-minutes: 15 - strategy: - fail-fast: true - matrix: - mode: - - production - - test env: - RAILS_ENV: ${{ matrix.mode }} - BUNDLE_WITH: ${{ matrix.mode }} + RAILS_ENV: production + BUNDLE_WITH: production SECRET_KEY_BASE_DUMMY: 1 steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up Ruby environment uses: ./.github/actions/setup-ruby @@ -44,19 +39,19 @@ jobs: onlyProduction: 'true' - name: Cache assets from compilation - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: | public/assets public/packs public/packs-test tmp/cache/vite - key: ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }} + key: assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }} restore-keys: | - ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }} - ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }} - ${{ matrix.mode }}-assets-main - ${{ matrix.mode }}-assets + assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }} + assets-${{ github.head_ref || github.ref_name }} + assets-main + assets - name: Precompile assets run: |- @@ -64,10 +59,9 @@ jobs: - name: Archive asset artifacts run: | - tar --exclude={"*.br","*.gz"} -zcf artifacts.tar.gz public/assets public/packs* tmp/cache/vite/last-build*.json + tar --exclude={"*.br","*.gz"} -zcf artifacts.tar.gz public/assets public/packs* - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 - if: matrix.mode == 'test' with: path: |- ./artifacts.tar.gz @@ -130,7 +124,7 @@ jobs: - '3.4' - '.ruby-version' steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 with: @@ -154,7 +148,7 @@ jobs: bin/flatware fan bin/rails db:test:prepare - name: Cache RSpec persistence file - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: | tmp/rspec/examples.txt @@ -226,7 +220,7 @@ jobs: - '.ruby-version' steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 with: @@ -252,7 +246,7 @@ jobs: - name: Cache Playwright Chromium browser id: playwright-cache - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: ~/.cache/ms-playwright key: playwright-browsers-${{ runner.os }}-${{ hashFiles('yarn.lock') }} @@ -366,7 +360,7 @@ jobs: search-image: opensearchproject/opensearch:2 steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 with: diff --git a/.nvmrc b/.nvmrc index 93b18eeec5..d8e297d13c 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -24.17 +24.19 diff --git a/.rubocop.yml b/.rubocop.yml index 425709187c..3b080fd57f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,7 @@ AllCops: - Vagrantfile - config/initializers/json_ld* - lib/mastodon/migration_helpers.rb + - lib/json-canonicalization/floats_fix.rb ExtraDetails: true NewCops: enable TargetRubyVersion: 3.3 # Oldest supported ruby version @@ -20,7 +21,6 @@ inherit_from: - .rubocop/style.yml - .rubocop/i18n.yml - .rubocop/custom.yml - - .rubocop_todo.yml - .rubocop/strict.yml inherit_mode: diff --git a/.rubocop/style.yml b/.rubocop/style.yml index 1d1c9f9879..e2ded03c8e 100644 --- a/.rubocop/style.yml +++ b/.rubocop/style.yml @@ -15,6 +15,9 @@ Style/FormatStringToken: merge: - AllowedMethods +Style/GuardClause: + Enabled: false + Style/HashAsLastArrayItem: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index 0cc9c8d8fc..0000000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,18 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.80.2. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedVars, DefaultToNil. -Style/FetchEnvVar: - Exclude: - - 'config/initializers/paperclip.rb' - -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. -Style/GuardClause: - Enabled: false diff --git a/.simplecov b/.simplecov index 1f84c71547..442f5abda4 100644 --- a/.simplecov +++ b/.simplecov @@ -12,15 +12,16 @@ SimpleCov.configure do formatter SimpleCov::Formatter::HTMLFormatter end - enable_coverage :branch + enable_coverage :branch, :eval - add_filter 'lib/linter' + skip 'lib/linter' - add_group 'Libraries', 'lib' - add_group 'Policies', 'app/policies' - add_group 'Presenters', 'app/presenters' - add_group 'Search', 'app/chewy' - add_group 'Serializers', 'app/serializers' - add_group 'Services', 'app/services' - add_group 'Validators', 'app/validators' + group 'Libraries', 'lib' + group 'Policies', 'app/policies' + group 'Presenters', 'app/presenters' + group 'Search', 'app/chewy' + group 'Serializers', 'app/serializers' + group 'Services', 'app/services' + group 'Validators', 'app/validators' + group 'Views', 'app/views' end diff --git a/.storybook/manager.ts b/.storybook/manager.ts index 53dfaa15ab..8e1b3233a3 100644 --- a/.storybook/manager.ts +++ b/.storybook/manager.ts @@ -1,7 +1,11 @@ import { addons } from 'storybook/manager-api'; - -import theme from './storybook-theme'; +import { themes } from 'storybook/theming'; addons.setConfig({ - theme, + theme: { + ...themes.normal, + brandTitle: 'Mastodon Storybook', + brandImage: 'logo.svg', + colorSecondary: '#6364FF', + }, }); diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 4fb559ccf9..5e8b4852cb 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -16,6 +16,7 @@ import { importLegacyShortcodes, importEmojiData, } from '@/mastodon/features/emoji/loader'; +import { IdentityContext } from '@/mastodon/identity_context'; import type { LocaleData } from '@/mastodon/locales'; import { reducerWithInitialState } from '@/mastodon/reducers'; import { defaultMiddleware } from '@/mastodon/store/store'; @@ -55,22 +56,35 @@ const preview: Preview = { description: 'Theme for the story', toolbar: { title: 'Theme', - icon: 'circlehollow', - items: [{ value: 'light' }, { value: 'dark' }], - dynamicTitle: true, + items: [ + { value: 'light', icon: 'circlehollow' }, + { value: 'dark', icon: 'circle' }, + ], + }, + }, + loggedIn: { + description: 'Whether a user is logged in', + toolbar: { + title: 'Logged in', + icon: 'user', + items: [ + { value: 'true', title: 'logged in' }, + { value: 'false', title: 'logged out' }, + ], }, }, }, initialGlobals: { locale: 'en', theme: 'light', + loggedIn: 'true', }, decorators: [ (Story, { parameters, globals, args, argTypes }) => { // Get the locale from the global toolbar // and merge it with any parameters or args state. const { locale } = globals as { locale: string }; - const { state = {} } = parameters; + const { state = {}, stateFn } = parameters; const argsState: Record = {}; for (const [key, value] of Object.entries(args)) { @@ -92,13 +106,24 @@ const preview: Preview = { } } + let stateFnState: Record = {}; + if (typeof stateFn === 'function') { + stateFnState = + ( + stateFn as ( + args: Record, + ) => Record | undefined | null + )(args) ?? {}; + } + const reducer = reducerWithInitialState( { meta: { locale, }, }, - state as Record, + state, + stateFnState, argsState, ); @@ -115,7 +140,7 @@ const preview: Preview = { ); }, (Story, { globals }) => { - const currentLocale = (globals.locale as string) || 'en'; + const currentLocale = globals.locale || 'en'; const [messages, setMessages] = useState< Record> >({}); @@ -143,7 +168,7 @@ const preview: Preview = { ); }, (Story, { globals }) => { - const theme = (globals.theme as string) || 'light'; + const theme = globals.theme; useEffect(() => { document.body.setAttribute('data-color-scheme', theme); }, [theme]); @@ -164,12 +189,35 @@ const preview: Preview = { /> ), + (Story, { globals }) => { + const signedIn = globals.loggedIn !== 'false'; + return ( + + + + ); + }, + (Story, { parameters }) => { + useEffect(() => { + document.documentElement.dataset.redesign = parameters.redesign + ? 'true' + : 'false'; + }, [parameters.redesign]); + return ; + }, ], loaders: [ mswLoader, importCustomEmojiData, importLegacyShortcodes, - ({ globals: { locale } }) => importEmojiData(locale as string), + ({ globals: { locale } }) => importEmojiData(locale), ], parameters: { layout: 'centered', diff --git a/.storybook/static/logo.svg b/.storybook/static/logo.svg new file mode 100644 index 0000000000..d85fc9ab76 --- /dev/null +++ b/.storybook/static/logo.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/.storybook/storybook-theme.ts b/.storybook/storybook-theme.ts deleted file mode 100644 index 7a72ba1c75..0000000000 --- a/.storybook/storybook-theme.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { create } from 'storybook/theming'; - -export default create({ - base: 'light', - brandTitle: 'Mastodon Storybook', - brandImage: 'https://joinmastodon.org/logos/wordmark-black-text.svg', -}); diff --git a/.storybook/storybook.d.ts b/.storybook/storybook.d.ts index 47624d1e9c..e9c02f7a1b 100644 --- a/.storybook/storybook.d.ts +++ b/.storybook/storybook.d.ts @@ -1,5 +1,8 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ // The addon package.json incorrectly exports types, so we need to override them here. +import type { PartialDeep } from 'type-fest'; + import type { RootState } from '@/mastodon/store'; // See: https://github.com/storybookjs/storybook/blob/v9.0.4/code/addons/vitest/package.json#L70-L76 @@ -7,13 +10,37 @@ declare module '@storybook/addon-vitest/vitest-plugin' { export * from '@storybook/addon-vitest/dist/vitest-plugin/index'; } -type RootPathKeys = keyof RootState; +type TypedRootState = { + [Key in keyof RootState]?: RootState[Key] extends Immutable.OrderedCollection + ? unknown + : PartialDeep; +}; declare module 'storybook/internal/csf' { export interface InputType { + /** + * Connects an argument value deeply in the Redux state. + * + * Can either be a period separated string or an array. + */ reduxPath?: - | `${RootPathKeys}.${string}` - | [RootPathKeys, ...(string | number)[]]; + | `${keyof TypedRootState}.${string}` + | [keyof TypedRootState, ...(string | number)[]]; + } + + export interface Globals { + locale: string; + theme: 'light' | 'dark'; + loggedIn: 'true' | 'false'; + } + + export interface Parameters { + /** Provides the Redux state as a JS object for the component. */ + state?: TypedRootState; + /** Callback that is run with the story arguments to generate Redux state for the component. */ + stateFn?: (args: any) => TypedRootState; + /** True to set the redesign global settings. */ + redesign?: boolean; } } diff --git a/CHANGELOG.md b/CHANGELOG.md index a3a1fac58d..c24a1a6c99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,11 @@ All notable changes to this project will be documented in this file. -## [4.6.11] - 2026-11-03 +## [4.7.5] - 2026-11-03 +### Security + +- Fix password authentication bypass for inactive accounts ([GHSA-3xjw-gv43-3w62](https://github.com/mastodon/mastodon/security/advisories/GHSA-3xjw-gv43-3w62)) - Fix DoS through JSON-LD compaction (#41482 by @ClearlyClaire, [GHSA-cf49-73r7-rxj6](https://github.com/mastodon/mastodon/security/advisories/GHSA-cf49-73r7-rxj6)) - Fix `Forwarded` header taking precedence over `X-Forwarded-For` (#41481 by @ClearlyClaire, [GHSA-qp4r-p842-mw5c](https://github.com/mastodon/mastodon/security/advisories/GHSA-qp4r-p842-mw5c)) - If your reverse-proxy setup uses `Forwarded` instead of `X-Forwarded-For`, please make sure it ignores user-provided `X-Forwarded-For` headers. @@ -14,11 +17,12 @@ All notable changes to this project will be documented in this file. - Change invites use counts to not decrease if an invited user deletes their account (#41458 by @ClearlyClaire) -## [4.6.10] - 2026-10-29 +## [4.7.4] - 2026-10-29 ### Security - Fix insufficient ActivityPub identifier verification ([GHSA-288h-6j8h-6x5j](https://github.com/mastodon/mastodon/security/advisories/GHSA-288h-6j8h-6x5j)) +- Added security challenge e-mail to users that try to log in after long period of inactivity (#40745 by @jhbabon) - Updated dependencies, in particular to address security advisories in Ruby, NodeJS, `excon`, `css_parser`, `pghero`, and `sanitize` ### Fixed @@ -29,7 +33,7 @@ All notable changes to this project will be documented in this file. - Fix error in `dev:populate_sample_data` task (#40995 and #41051 by @isidzukuri and @mjankowski) - Fix local collection item revocation not being properly federated (#40930 by @oneiros) -## [4.6.9] - 2026-10-01 +## [4.7.3] - 2026-10-01 ### Security @@ -38,6 +42,7 @@ All notable changes to this project will be documented in this file. ### Added - Add logging of account data removal (#40572 by @ClearlyClaire) +- Add link to homepage to 404 error page (#40369 by @diondiondion) ### Changed @@ -45,7 +50,9 @@ All notable changes to this project will be documented in this file. ### Fixed +- Fix error handling for malformed webfinger subjects (#40731 by @ClearlyClaire) - Fix threads leak by updating dependency aws-sdk-s3 +- Fix occasional installation-time error by updating dependency yarn to v4.18.1 (#40722 by @renovate[bot]) - Fix inconsistent horizontal page padding between profile and profile editor (#40700 by @diondiondion) - Fix server error on registration for wrong DOB (#40607 by @sudeeptarlekar) - Fix quotes disclaimer disappearing on posts with no quote (#40587 by @crafkaz) @@ -54,14 +61,17 @@ All notable changes to this project will be documented in this file. - Fix mobile navigation covering up "Next step" button during onboarding (#40634 by @diondiondion) - Fix rate limits not normalizing submitted e-mail addresses (#40658 by @Gargron) - Fix moderators being able to issue a warning on moderators of higher position (#40646 by @ClearlyClaire) +- Fix deleted-because-of-suspension accounts being marked as manually deleted (#40645 by @ClearlyClaire) - Fix description text overflowing on Overview landing page (#40272 by @diondiondion) - Fix account avatar and header descriptions not being deleted when an account is deleted (#40621 by @ClearlyClaire) - Fix deleted accounts not being removed from featured collections (#40623 by @ClearlyClaire) - Fix `PreviewCardsStatus` records not being deleted on account deletion (#40624 by @ClearlyClaire) +- Fix z-index of PIP video player to be above the side panel (#40484 by @tribela) - Fix replies order (#40481 by @OmmyZhang) - Fix missing confirmation when leaving with an unsent post (#40478 by @crafkaz) +- Fix email footer spacing around custom footer text (#40440 by @mjankowski) -## [4.6.8] - 2026-09-15 +## [4.7.2] - 2026-09-15 ### Security @@ -71,29 +81,104 @@ All notable changes to this project will be documented in this file. - Fix relative privacy policy links in subscription emails (#40486 by @crafkaz) - Fix canonical email blocks interfering with freezing or approving users (#40463 by @ClearlyClaire) +- Fix 500 error when trying to upload a non-custom-filter JSON import (#40449 and #40451 by @ClearlyClaire) - Fix 500 error when submitting a status twice (#40439 by @ClearlyClaire) +- Fix self-deleted accounts not being un-deleted when using `tootctl accounts create --reattach` (#40430 by @mjankowski) - Fix account deletion not deleting generated annual reports (#40394 by @ClearlyClaire) - Fix notifications not being cleaned up when notification requests are deleted in bulk (#40393 by @ClearlyClaire) -## [4.6.7] - 2026-09-01 +## [4.7.1] - 2026-09-01 ### Security -- Update dependencies - Fix password authentication bypass in 2FA auth for LDAP/PAM/SSO accounts ([GHSA-vx32-x96w-qq65](https://github.com/mastodon/mastodon/security/advisories/GHSA-vx32-x96w-qq65)) - Fix Denial of Service when processing pathological JSON-LD activities ([GHSA-vgm8-frgh-rh2v](https://github.com/mastodon/mastodon/security/advisories/GHSA-vgm8-frgh-rh2v)) - Fix disabled staff accounts still having access to admin API ([GHSA-62j4-hvj7-px3f](https://github.com/mastodon/mastodon/security/advisories/GHSA-62j4-hvj7-px3f)) ### Fixes +- Fix invited-without-approval-bypass not being asked for a textual reason (#40332 by @ClearlyClaire) +- Fix email blocks domain filter not being kept through pagination (#40254 by @ClearlyClaire) - Fix `config/` directory missing from Bootsnap precompilation options in Dockerfile (#40255 by @ClearlyClaire) +- Fix some of 4.7 migrations not re-running cleanly when interrupted (#40264 by @ClearlyClaire) +- Fix account creation failing on `ActiveRecord::Encryption` configuration in `mastodon:setup` rake task (#40275 by @ClearlyClaire) + +## [4.7.0] - 2026-08-20 + +### Added + +- Add audit logs for Hashtags (#39473, #39337 and #39670 by @arte7) +- Add search field to admin ip blocks (#39404 by @arte7) +- Add notifications for out-of-support versions of Mastodon (#39732 and #39734 by @ClearlyClaire) +- Add Elasticsearch request timeout of 10s (can be overridden through `ES_QUERY_TIMEOUT`) (#40064 by @ClearlyClaire) +- Add ActivityPub attributes to current span when processing Activities (#40041 by @jhbabon) +- Add OTel span attribute to deprecated endpoints (#40030 by @jhbabon) +- Add default permission check to admin area (#39974 by @oneiros) +- Add uniqueness constraint on Account `uri` (#39882, #39999 and #39861 by @ClearlyClaire) +- Add new theme tokens `bg-blend`, `bg-highlight`, and `border-strong` (#39786 by @diondiondion) +- Add support for `Link` objects in `attachment` (FEP-8967) (#36104, #39977 and #39983 by @Gargron, @TheEssem and @shleeable) + - Mastodon will use the first `Link` attachment, if any, as preview card. + - If there is no `Link` attachment, Mastodon will still scan the message content's to populate one. This may change in a later release. + - Mastodon sets a `Link` attachment for outgoing posts with a preview card. +- Add support for remote accounts changing handles (#39785, #39850, #39865 and #40045 by @ClearlyClaire) + - ActivityPub actor `id` is now used as the primary identifier, instead of webfinger handle. + - Remote actors that change handles are now renamed instead of a duplicate account being created then the two merged. + - Mastodon does not offer its users to change handles yet. + - The concept of “invalid handles” has been added to handle some edge cases. An account with an invalid handle + is an account for which the handle cannot be currently verified, but is otherwise valid. + In the REST API, they have their `username` and `domain` attribute overridden and this is made explicit through the [`invalid_handle` attribute](https://docs.joinmastodon.org/entities/Account/#invalid_handle). +- Add outgoing RFC9421 HTTP Message Signatures as fallback to earlier draft (#39756 by @ClearlyClaire) +- Change how local users' keypairs are stored (#39658, #39668, #39662, #39684, #39686, #39690 and #40138 by @ClearlyClaire) + - This moves local users' keypairs to the dedicated table that was created in 4.6. + - Private keys are now encrypted at rest, and the new infrastructure will allow for key rotation in the future. +- Add support for `expires` in Linked Data Signatures and Object Integrity Proofs (#39701 by @ClearlyClaire) +- Add verification of FEP-8b32 Object Integrity Proofs (#39530, #39728, #39754, #39760, #39522 and #39747 by @ClearlyClaire) + - Both `eddsa-jcs-2022` and `mldsa44-jcs-2024` are supported. + - `mldsa44-jcs-2024` verification requires OpenSSL >= 3.5 to be verified. +- Add support for Ed25519 signatures in HTTP Message Signatures (#39518 by @ClearlyClaire) +- Add inbound support for FEP-521a (#39497, #39618, and #39725 by @ClearlyClaire and @shleeable) + +### Fixed + - Fix autosuggestions overstaying their welcome in languages that don't use spaces (#40217 by @Gargron) - Fix error when processing remote actors with `null` public keys (#40194 by @ClearlyClaire) - Fix various off-by-one errors in statistics time ranges (#40193 by @ClearlyClaire) +- Fix `/deck` being removed from path when resizing window (#40180 by @ClearlyClaire) +- Fix error in `tootctl media refresh` when cleaning some incompletely processed files (#40056 by @shleeable) +- Fix plain-text formatter not treating `
` as newline (#40079 by @shleeable) +- Fix performance of listing follow requests by adding appropriate index (#40033 by @ClearlyClaire) +- Fix missing `on_delete: :cascade` on `GeneratedAnnualReport` foreign key (#40063 by @ClearlyClaire) +- Fix `DeleteAccountService#purge_favourites!` only invalidating deprecated cache keys (#40048 by @shleeable) +- Fix spam-filtered scheduled posts raising an error rather than being silently ignored (#40051 by @shleeable) +- Fix error when processing backups for deleted accounts (#40053 by @shleeable) +- Fix notification filter selection after settings change (#39872 by @sharlayan) +- Fix timeline unable to load more when the last item is a `inline-follow-suggestions` (#39773 by @sharlayan) +- Fix embedded videos restarting when interacting with post (or other posts in the same feed) (#39746 by @diondiondion) +- Fix N+1 queries when rendering accounts on the admin collection page (#39738 by @rubys) +- Fix authored posts not immediately appearing in timelines (#39733 by @ChaosExAnima) +- Fix newletter button display on some e-mail clients (#39634 by @diondiondion) +- Fix handling of `rdf:langString` in media `summary` and `name` (#39590 by @ClearlyClaire) +- Fix error when rejecting appeal of already-deleted user (#39490 by @shleeable) +- Fix navigation switching to user “Account” category when viewing appeal for moderation interface (#39476, #39619 and #40026 by @ClearlyClaire and @shleeable) + +### Changed + +- Change follow recommendation materialized views to manually-maintained tables (#40039 by @ClearlyClaire) +- Change database schema to distinguish deleted-but-not-suspended accounts (#23617, #40027, #40029, #40034, #40083 and #40078 by @ClearlyClaire and @shleeable) +- Change reblogs to be deduplicated within the last 80 posts instead of the last 40 (#39784 by @ClearlyClaire) +- Change `AttachmentBatch` to reset retry attempt counter for each S3 batch (#39979 by @shleeable) +- Change featured tag recommendation criteria (#39567 by @renchap) + +### Removed + +- Remove inbox processing of collections of activities (#39932 by @ClearlyClaire) +- Remove support for `Reject` and `Accept` of `QuoteRequest` that cannot be found by `id` (#39833 by @ClearlyClaire) +- Remove deprecated `bin/update` script (#39443 by @mjankowski) +- Remove support for pre-Mastodon 4.3.0 cookies (#38918 by @ClearlyClaire) ## [4.6.6] - 2026-08-13 -### Changed +### Changes - Change `mastodon:setup` task warning about trademark to match `masto` but ignore subdomains (#40143 by @ClearlyClaire) diff --git a/Dockerfile b/Dockerfile index 7b929ad983..3866d91576 100644 --- a/Dockerfile +++ b/Dockerfile @@ -210,7 +210,7 @@ FROM media-build AS libvips # libvips version to compile, change with [--build-arg VIPS_VERSION="8.15.2"] # renovate: datasource=github-releases depName=libvips packageName=libvips/libvips -ARG VIPS_VERSION=8.18.3 +ARG VIPS_VERSION=8.18.5 # libvips download URL, change with [--build-arg VIPS_URL="https://github.com/libvips/libvips/releases/download"] ARG VIPS_URL=https://github.com/libvips/libvips/releases/download @@ -234,7 +234,7 @@ FROM media-build AS ffmpeg # ffmpeg version to compile, change with [--build-arg FFMPEG_VERSION="7.0.x"] # renovate: datasource=github-tags depName=FFmpeg/FFmpeg extractVersion=^n(?\d+\.\d+(\.\d+)?)$ -ARG FFMPEG_VERSION=8.1.2 +ARG FFMPEG_VERSION=9.0.2 # ffmpeg download URL, change with [--build-arg FFMPEG_URL="https://ffmpeg.org/releases"] ARG FFMPEG_URL=https://github.com/FFmpeg/FFmpeg/archive/refs/tags diff --git a/FEDERATION.md b/FEDERATION.md index 22bbb03a0c..4dcdc3dd48 100644 --- a/FEDERATION.md +++ b/FEDERATION.md @@ -15,6 +15,8 @@ - [FEP-5feb: Search indexing consent for actors](https://codeberg.org/fediverse/fep/src/branch/main/fep/5feb/fep-5feb.md) - [FEP-044f: Consent-respecting quote posts](https://codeberg.org/fediverse/fep/src/branch/main/fep/044f/fep-044f.md) - [FEP-3b86: Activity Intents](https://codeberg.org/fediverse/fep/src/branch/main/fep/3b86/fep-3b86.md): offer handlers for `Object` and `Create` (with support for the `content` parameter only), has support for the `Follow`, `Announce`, `Like` and `Object` intents +- [FEP-521a: Representing actor's public keys](https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md): starting with Mastodon 4.7, we support RSA and Ed25519 keys exposed through FEP-521a, but we do not expose our keys this way +- [FEP-8b32: Object Integrity Proofs](https://codeberg.org/fediverse/fep/src/branch/main/fep/8b32/fep-8b32.md): starting with Mastodon 4.7, we support top-level Object Integrity Proofs using the `eddsa-jcs-2022` cryptosuite, but we do not emit any Object Integrity Proof ## ActivityPub in Mastodon @@ -39,13 +41,36 @@ In order to authenticate activities, Mastodon relies on HTTP Signatures, signing Mastodon requires all `POST` requests to be signed, and MAY require `GET` requests to be signed, depending on the configuration of the Mastodon server. +Before Mastodon v4.5.0, Mastodon only supported HTTP Signatures such as defined in the [draft-cavage-http-signatures-12](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures) specification draft. + +Starting with Mastodon v4.5.0, Mastodon supports requests signed using HTTP Message Signatures (RFC9421) with the [`rsa-v1_5-sha256` algorithm](https://datatracker.ietf.org/doc/html/rfc9421#name-rsassa-pkcs1-v1_5-using-sha) in addition to the old `draft-cavage-http-signatures-12` draft. Mastodon v4.7 also supports verifying signatures using the [`ed25519` algorithm](https://datatracker.ietf.org/doc/html/rfc9421#name-eddsa-using-curve-edwards25), and uses RFC 9421 in outbound requests when `draft-cavage-http-signatures-12` requests are met with a 400 or 401 error code. + +| Mastodon version | Support for `draft-cavage-http-signatures-12` | Support for RFC 9421 | +| ----------------------- | --------------------------------------------- | --------------------------------------------------------------------------------- | +| v4.4.0 (EOL 2026-12-17) | `rsa-sha256` inbound and outbound | No | +| v4.5.0 | `rsa-sha256` inbound and outbound | `rsa-v1_5-sha256` inbound | +| v4.6.0 | `rsa-sha256` inbound and outbound | `rsa-v1_5-sha256` inbound | +| v4.7.0 | `rsa-sha256` inbound and outbound | `rsa-v1_5-sha256` and `ed25519` inbound, `rsa-v1_5-sha256` outbound as a fallback | + - [HTTP Signatures information and examples](https://docs.joinmastodon.org/spec/security/#http) +- [HTTP Message Signatures information and examples](https://docs.joinmastodon.org/spec/security/#http-message-signatures) ### Optional extensions - [Linked-Data Signatures](https://docs.joinmastodon.org/spec/security/#ld) - [Bearcaps](https://docs.joinmastodon.org/spec/bearcaps/) +#### Embedded signatures + +Mastodon supports embedded signatures through either [Linked-Data Signatures](https://docs.joinmastodon.org/spec/security/#ld) or [Object Integrity Proofs](https://docs.joinmastodon.org/spec/security/#fep-8b32). + +| Mastodon version | Support for Linked Data Signatures | Support FEP-8b32: Object Integrity Proofs | +| ----------------------- | --------------------------------------- | -------------------------------------------------------- | +| v4.4.0 (EOL 2026-12-17) | `RsaSignature2017` inbound and outbound | No | +| v4.5.0 | `RsaSignature2017` inbound and outbound | No | +| v4.6.0 | `RsaSignature2017` inbound and outbound | No | +| v4.7.0 | `RsaSignature2017` inbound and outbound | top-level `eddsa-jcs-2022` or `mldsa44-jcs-2024` inbound | + ### Additional documentation - [Mastodon documentation](https://docs.joinmastodon.org/) diff --git a/Gemfile b/Gemfile index 61261e8f9b..0383471a78 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'blurhash', '~> 0.1' gem 'fog-core', '<= 2.6.0' gem 'fog-openstack', '~> 1.0', require: false gem 'jd-paperclip-azure', '~> 3.0', require: false -gem 'kt-paperclip', '~> 7.2' +gem 'kt-paperclip', '~> 8.0' gem 'ruby-vips', '~> 2.2', require: false gem 'active_model_serializers', '~> 0.10' @@ -62,7 +62,7 @@ gem 'ipaddr', '~> 1.2' gem 'irb', '~> 1.8' gem 'kaminari', '~> 1.2' gem 'link_header', '~> 0.0' -gem 'linzer', '~> 0.7.7' +gem 'linzer', '~> 0.8.0' gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock' gem 'mime-types', '~> 3.7.0', require: 'mime/types/columnar' gem 'mutex_m' @@ -74,6 +74,7 @@ gem 'public_suffix', '~> 7.0' gem 'pundit', '~> 2.3' gem 'rack-attack', '~> 6.6' gem 'rack-cors', require: 'rack/cors' +gem 'rack-proxy', require: 'rack/proxy' gem 'rails-i18n', '~> 8.0' gem 'redcarpet', '~> 3.6' gem 'redis', '~> 5' @@ -96,17 +97,18 @@ gem 'webauthn', '~> 3.0' gem 'webpush', github: 'mastodon/webpush', ref: '9631ac63045cfabddacc69fc06e919b4c13eb913' gem 'json' +gem 'json-canonicalization', '~> 1.0' gem 'json-ld' gem 'json-ld-preloaded', '~> 3.2' gem 'rdf-normalize', '~> 0.5' gem 'prometheus_exporter', '~> 2.2', require: false -gem 'opentelemetry-api', '~> 1.10.0' +gem 'opentelemetry-api', '~> 1.11.0' group :opentelemetry do gem 'opentelemetry-exporter-otlp', '~> 0.34.0', require: false - gem 'opentelemetry-instrumentation-active_job', '~> 0.12.0', require: false + gem 'opentelemetry-instrumentation-active_job', '~> 0.13.0', require: false gem 'opentelemetry-instrumentation-active_model_serializers', '~> 0.25.0', require: false gem 'opentelemetry-instrumentation-concurrent_ruby', '~> 0.25.0', require: false gem 'opentelemetry-instrumentation-excon', '~> 0.29.0', require: false @@ -114,7 +116,7 @@ group :opentelemetry do gem 'opentelemetry-instrumentation-http', '~> 0.30.0', require: false gem 'opentelemetry-instrumentation-http_client', '~> 0.29.0', require: false gem 'opentelemetry-instrumentation-net_http', '~> 0.29.0', require: false - gem 'opentelemetry-instrumentation-pg', '~> 0.36.0', require: false + gem 'opentelemetry-instrumentation-pg', '~> 0.37.0', require: false gem 'opentelemetry-instrumentation-rack', '~> 0.31.0', require: false gem 'opentelemetry-instrumentation-rails', '~> 0.42.0', require: false gem 'opentelemetry-instrumentation-redis', '~> 0.29.0', require: false @@ -135,7 +137,7 @@ group :test do # Browser integration testing gem 'capybara', '~> 3.39' gem 'capybara-playwright-driver' - gem 'playwright-ruby-client', '1.60.0', require: false # Pinning the exact version as it needs to be kept in sync with the installed npm package + gem 'playwright-ruby-client', require: false # Used to reset the database between system tests gem 'database_cleaner-active_record' @@ -152,7 +154,7 @@ group :test do gem 'shoulda-matchers' # Coverage formatter for RSpec - gem 'simplecov', '~> 0.22', require: false + gem 'simplecov', require: false gem 'simplecov-lcov', '~> 0.8', require: false # Stub web requests for specs @@ -230,4 +232,4 @@ gem 'hcaptcha', '~> 7.1' gem 'mail', '~> 2.8' -gem 'vite_rails' +gem 'base58', '~> 0.2.3' diff --git a/Gemfile.lock b/Gemfile.lock index bcc53c37a0..72ac19242a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,15 +93,15 @@ GEM public_suffix (>= 2.0.2, < 8.0) aes_key_wrap (1.1.0) android_key_attestation (0.3.0) - annotaterb (4.22.0) + annotaterb (4.23.0) activerecord (>= 6.0.0) activesupport (>= 6.0.0) ast (2.4.3) attr_required (1.0.2) - aws-eventstream (1.4.0) - aws-partitions (1.1259.0) - aws-sdk-core (3.257.0) - aws-eventstream (~> 1, >= 1.3.0) + aws-eventstream (1.4.1) + aws-partitions (1.1279.0) + aws-sdk-core (3.261.0) + aws-eventstream (~> 1, >= 1.4.1) aws-partitions (~> 1, >= 1.992.0) aws-sigv4 (~> 1.9) base64 @@ -109,17 +109,18 @@ GEM jmespath (~> 1, >= 1.6.1) logger rexml (~> 3.4, >= 3.4.2) - aws-sdk-kms (1.129.0) - aws-sdk-core (~> 3, >= 3.248.0) + aws-sdk-kms (1.130.0) + aws-sdk-core (~> 3, >= 3.254.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.232.3) - aws-sdk-core (~> 3, >= 3.256.0) + aws-sdk-s3 (1.235.0) + aws-sdk-core (~> 3, >= 3.258.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) aws-sigv4 (1.12.1) aws-eventstream (~> 1, >= 1.0.2) azure-blob (0.5.9.1) rexml + base58 (0.2.3) base64 (0.3.0) bcp47_spec (0.2.1) bcrypt (3.1.22) @@ -133,9 +134,9 @@ GEM binding_of_caller (2.0.0) debug_inspector (>= 1.2.0) blurhash (0.1.8) - bootsnap (1.24.6) - msgpack (~> 1.2) - brakeman (8.0.4) + bootsnap (1.25.0) + msgpack (~> 1.5) + brakeman (8.0.6) racc browser (6.2.0) builder (3.3.0) @@ -151,14 +152,14 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - capybara-playwright-driver (0.5.9) + capybara-playwright-driver (0.5.10) addressable capybara playwright-ruby-client (>= 1.16.0) case_transform (0.2) activesupport - cbor (0.5.10.2) - cgi (0.5.1) + cbor (0.5.10.3) + cgi (0.5.2) charlock_holmes (0.7.9) chewy (8.4.1) activesupport (>= 7.2) @@ -170,7 +171,7 @@ GEM climate_control (1.2.0) cocoon (1.2.15) color_diff (0.2) - concurrent-ruby (1.3.7) + concurrent-ruby (1.3.8) connection_pool (3.0.2) cose (1.3.1) cbor (~> 0.5.9) @@ -183,7 +184,7 @@ GEM addressable base64 ssrf_filter (~> 1.5) - csv (3.3.5) + csv (3.3.6) database_cleaner-active_record (2.2.2) activerecord (>= 5.a) database_cleaner-core (~> 2.0) @@ -210,14 +211,12 @@ GEM diff-lcs (1.6.2) discard (2.0.0) activerecord (>= 7.0, < 9.0) - docile (1.4.1) domain_name (0.6.20240107) doorkeeper (5.9.9) railties (>= 5) dotenv (3.2.0) drb (2.2.3) - dry-cli (1.4.1) - elastic-transport (8.5.2) + elastic-transport (8.5.3) faraday (< 3) multi_json elasticsearch (8.19.3) @@ -227,9 +226,9 @@ GEM elasticsearch-api (8.19.3) multi_json elasticsearch-dsl (0.1.10) - erb (6.0.4) + erb (6.0.7) erubi (1.13.1) - et-orbi (1.4.0) + et-orbi (1.4.1) tzinfo excon (1.8.0) logger @@ -265,35 +264,36 @@ GEM excon (~> 1.0) formatador (>= 0.2, < 2.0) mime-types - fog-json (1.3.0) + fog-json (1.4.0) fog-core - multi_json (~> 1.10) + json (~> 2.19) fog-openstack (1.1.5) fog-core (~> 2.1) fog-json (>= 1.0) formatador (1.2.3) reline forwardable (1.4.0) - fugit (1.12.2) + fugit (1.13.0) et-orbi (~> 1.4) raabro (~> 1.4) - globalid (1.3.0) + globalid (1.4.0) activesupport (>= 6.1) - google-protobuf (4.35.0) + google-protobuf (4.35.1) bigdecimal rake (~> 13.3) googleapis-common-protos-types (1.23.0) google-protobuf (~> 4.26) - haml (7.2.0) + haml (7.3.0) + prism (>= 1.1.0) temple (>= 0.8.2) thor tilt - haml-rails (3.0.0) + haml-rails (3.1.0) actionpack (>= 5.1) activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - haml_lint (0.73.0) + haml_lint (0.77.0) haml (>= 5.0) parallel (>= 1.10) rainbow @@ -306,8 +306,8 @@ GEM json highline (3.1.2) reline - hiredis-client (0.29.0) - redis-client (= 0.29.0) + hiredis-client (0.30.1) + redis-client (= 0.30.1) hkdf (0.3.0) htmlentities (4.4.2) http (5.3.1) @@ -325,7 +325,7 @@ GEM benchmark rack (>= 2.0) rainbow (>= 2.0.0) - i18n (1.15.1) + i18n (1.15.2) concurrent-ruby (~> 1.0) i18n-tasks (1.1.2) activesupport (>= 4.0.2) @@ -355,9 +355,9 @@ GEM azure-blob (~> 0.5.2) hashie (~> 5.0) jmespath (1.6.2) - json (2.19.9) + json (2.21.2) json-canonicalization (1.0.0) - json-jwt (1.17.1) + json-jwt (1.17.2) activesupport (>= 4.2) aes_key_wrap base64 @@ -393,13 +393,13 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - kt-paperclip (7.3.0) + kt-paperclip (8.0.0) activemodel (>= 4.2.0) activesupport (>= 4.2.0) - marcel (~> 1.0.1) + marcel (>= 1.0.1) mime-types - terrapin (>= 0.6.0, < 2.0) - language_server-protocol (3.17.0.5) + terrapin (>= 0.6.0) + language_server-protocol (3.17.0.6) launchy (3.1.1) addressable (~> 2.8) childprocess (~> 5.0) @@ -413,19 +413,17 @@ GEM rexml link_header (0.0.8) lint_roller (1.1.0) - linzer (0.7.9) + linzer (0.8.0) cgi (>= 0.4.2, < 0.6.0) forwardable (~> 1.3, >= 1.3.3) - logger (~> 1.7, >= 1.7.0) net-http (>= 0.6, < 0.10) - rack (>= 2.2, < 4.0) starry (~> 0.2) uri (~> 1.0, >= 1.0.2) llhttp-ffi (0.5.1) ffi-compiler (~> 1.0) rake (~> 13.0) logger (1.7.0) - lograge (0.14.0) + lograge (0.15.0) actionpack (>= 4) activesupport (>= 4) railties (>= 4) @@ -439,7 +437,7 @@ GEM net-imap net-pop net-smtp - marcel (1.0.4) + marcel (1.2.1) mario-redis-lock (1.2.1) redis (>= 3.0.5) matrix (0.4.3) @@ -447,18 +445,18 @@ GEM mime-types (3.7.0) logger mime-types-data (~> 3.2025, >= 3.2025.0507) - mime-types-data (3.2026.0414) + mime-types-data (3.2026.0701) mini_mime (1.1.5) mini_portile2 (2.8.9) minitest (6.0.6) drb (~> 2.0) prism (~> 1.5) - msgpack (1.8.3) + msgpack (1.8.4) multi_json (1.21.1) mutex_m (0.3.0) net-http (0.9.1) uri (>= 0.11.1) - net-imap (0.6.4.1) + net-imap (0.6.6) date net-protocol net-ldap (0.20.0) @@ -507,11 +505,11 @@ GEM openssl (4.0.2) openssl-signature_algorithm (1.3.0) openssl (> 2.0) - opentelemetry-api (1.10.0) + opentelemetry-api (1.11.0) logger - opentelemetry-common (0.25.0) + opentelemetry-common (0.25.1) opentelemetry-api (~> 1.0) - opentelemetry-exporter-otlp (0.34.0) + opentelemetry-exporter-otlp (0.34.1) google-protobuf (>= 3.18) googleapis-common-protos-types (~> 1.3) opentelemetry-api (~> 1.1) @@ -529,7 +527,7 @@ GEM opentelemetry-instrumentation-rack (~> 0.29) opentelemetry-instrumentation-action_view (0.13.0) opentelemetry-instrumentation-active_support (~> 0.10) - opentelemetry-instrumentation-active_job (0.12.0) + opentelemetry-instrumentation-active_job (0.13.0) opentelemetry-instrumentation-base (~> 0.25) opentelemetry-instrumentation-active_model_serializers (0.25.0) opentelemetry-instrumentation-active_support (>= 0.7.0) @@ -537,7 +535,7 @@ GEM opentelemetry-instrumentation-base (~> 0.25) opentelemetry-instrumentation-active_storage (0.5.1) opentelemetry-instrumentation-active_support (~> 0.10) - opentelemetry-instrumentation-active_support (0.12.0) + opentelemetry-instrumentation-active_support (0.12.1) opentelemetry-instrumentation-base (~> 0.25) opentelemetry-instrumentation-base (0.26.1) opentelemetry-api (~> 1.7) @@ -555,7 +553,7 @@ GEM opentelemetry-instrumentation-base (~> 0.25) opentelemetry-instrumentation-net_http (0.29.0) opentelemetry-instrumentation-base (~> 0.25) - opentelemetry-instrumentation-pg (0.36.0) + opentelemetry-instrumentation-pg (0.37.0) opentelemetry-helpers-sql opentelemetry-helpers-sql-processor opentelemetry-instrumentation-base (~> 0.25) @@ -574,22 +572,22 @@ GEM opentelemetry-instrumentation-base (~> 0.25) opentelemetry-instrumentation-sidekiq (0.29.0) opentelemetry-instrumentation-base (~> 0.25) - opentelemetry-registry (0.6.0) + opentelemetry-registry (0.6.3) opentelemetry-api (~> 1.1) - opentelemetry-sdk (1.12.0) + opentelemetry-sdk (1.13.0) logger opentelemetry-api (~> 1.1) opentelemetry-common (~> 0.20) opentelemetry-registry (~> 0.2) opentelemetry-semantic_conventions - opentelemetry-semantic_conventions (1.39.0) + opentelemetry-semantic_conventions (1.43.0) opentelemetry-api (~> 1.0) orm_adapter (0.5.0) ostruct (0.6.3) - ox (2.14.27) + ox (2.14.28) bigdecimal (>= 3.0) parallel (2.1.0) - parser (3.3.11.1) + parser (3.3.12.0) ast (~> 2.4.1) racc parslet (2.0.0) @@ -598,11 +596,11 @@ GEM pg (1.6.3) pghero (4.1.0) activerecord (>= 7.2) - playwright-ruby-client (1.60.0) + playwright-ruby-client (1.62.0) base64 concurrent-ruby (>= 1.1.6) mime-types (>= 3.0) - pp (0.6.3) + pp (0.6.4) prettyprint premailer (1.29.0) addressable @@ -620,15 +618,12 @@ GEM actionpack (>= 7.0.0) activesupport (>= 7.0.0) rack - psych (5.4.0) - date - stringio public_suffix (7.0.5) puma (8.0.2) nio4r (~> 2.0) pundit (2.5.2) activesupport (>= 3.0.0) - raabro (1.4.0) + raabro (1.5.0) racc (1.8.1) rack (3.2.8) rack-attack (6.8.0) @@ -647,7 +642,7 @@ GEM base64 (>= 0.1.0) logger (>= 1.6.0) rack (>= 3.0.0, < 4) - rack-proxy (2.0.1) + rack-proxy (1.0.3) rack (>= 2.0, < 4) rack-session (2.1.2) base64 (>= 0.1.0) @@ -691,6 +686,10 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.4.2) + rbs (4.1.3) + logger + prism (>= 1.6.0) + tsort rdf (3.3.4) bcp47_spec (~> 0.2) bigdecimal (~> 3.1, >= 3.1.5) @@ -700,19 +699,20 @@ GEM readline (~> 0.0) rdf-normalize (0.7.0) rdf (~> 3.3) - rdoc (7.2.0) + rdoc (8.0.0) erb - psych (>= 4.0.0) + prism (>= 1.6.0) + rbs (>= 4.0.0) tsort readline (0.0.4) reline redcarpet (3.6.1) redis (5.4.1) redis-client (>= 0.22.0) - redis-client (0.29.0) + redis-client (0.30.1) connection_pool regexp_parser (2.12.0) - reline (0.6.3) + reline (0.7.0) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) @@ -721,7 +721,7 @@ GEM railties (>= 7.0) rexml (3.4.4) rotp (6.3.0) - rouge (5.0.0) + rouge (5.1.0) strscan (~> 3.1) rpam2 (4.0.2) rqrcode (3.2.0) @@ -756,7 +756,7 @@ GEM rspec-mocks (~> 3.0) sidekiq (>= 5, < 9) rspec-support (3.13.7) - rubocop (1.87.0) + rubocop (1.89.0) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -767,24 +767,24 @@ GEM rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.49.1) + rubocop-ast (1.50.0) parser (>= 3.3.7.2) prism (~> 1.7) - rubocop-capybara (2.23.0) + rubocop-capybara (3.0.0) lint_roller (~> 1.1) rubocop (~> 1.81) rubocop-i18n (3.3.0) lint_roller (~> 1.1) rubocop (>= 1.72.1) - rubocop-performance (1.26.1) + rubocop-performance (1.27.0) lint_roller (~> 1.1) - rubocop (>= 1.75.0, < 2.0) + rubocop (>= 1.89.0, < 2.0) rubocop-ast (>= 1.47.1, < 2.0) - rubocop-rails (2.35.4) + rubocop-rails (2.37.0) activesupport (>= 4.2.0) lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.75.0, < 2.0) + rubocop (>= 1.89.0, < 2.0) rubocop-ast (>= 1.44.0, < 2.0) rubocop-rspec (3.10.2) lint_roller (~> 1.1) @@ -794,7 +794,7 @@ GEM lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) rubocop-rspec (~> 3.5) - ruby-prof (2.0.4) + ruby-prof (2.0.5) base64 ostruct ruby-progressbar (1.13.0) @@ -804,7 +804,7 @@ GEM ruby-vips (2.3.0) ffi (~> 1.12) logger - rubyzip (3.3.1) + rubyzip (3.4.1) rufus-scheduler (3.9.2) fugit (~> 1.1, >= 1.11.1) safety_net_attestation (0.5.0) @@ -816,8 +816,8 @@ GEM activerecord (>= 4.0.0) railties (>= 4.0.0) securerandom (0.4.1) - shoulda-matchers (7.0.1) - activesupport (>= 7.1) + shoulda-matchers (8.0.1) + activesupport (>= 7.2) sidekiq (8.1.6) connection_pool (>= 3.0.0) json (>= 2.16.0) @@ -833,19 +833,15 @@ GEM concurrent-ruby (~> 1.0, >= 1.0.5) sidekiq (>= 7.0.0, < 9.0.0) thor (>= 1.0, < 3.0) - simple-navigation (4.4.1) - activesupport (>= 2.3.2) - ostruct + simple-navigation (4.5.0) + activesupport (>= 6.1.0) + json + zeitwerk simple_form (5.4.1) actionpack (>= 7.0) activemodel (>= 7.0) - simplecov (0.22.0) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.13.2) + simplecov (1.1.1) simplecov-lcov (0.9.0) - simplecov_json_formatter (0.1.4) ssrf_filter (1.5.0) stackprof (0.2.28) starry (0.2.0) @@ -853,7 +849,6 @@ GEM stoplight (5.8.2) concurrent-ruby zeitwerk - stringio (3.2.0) strong_migrations (2.8.0) activerecord (>= 7.2) strscan (3.1.8) @@ -863,14 +858,15 @@ GEM faraday (~> 2.0) faraday-follow_redirects sysexits (1.2.0) - temple (0.10.4) + temple (0.10.6) terminal-table (4.0.0) unicode-display_width (>= 1.1.1, < 4) terrapin (1.1.1) climate_control - test-prof (1.6.1) + test-prof (1.6.3) + logger thor (1.5.0) - tilt (2.7.0) + tilt (2.8.0) timeout (0.6.1) tpm-key_attestation (0.14.1) bindata (~> 2.4) @@ -892,7 +888,7 @@ GEM unf (~> 0.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2026.2) + tzinfo-data (1.2026.3) tzinfo (>= 1.0.0) unf (0.1.4) unf_ext @@ -905,15 +901,6 @@ GEM validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix - vite_rails (3.11.0) - railties (>= 5.1, < 9) - vite_ruby (~> 3.0, >= 3.2.2) - vite_ruby (3.11.1) - dry-cli (>= 0.7, < 2) - logger (~> 1.6) - mutex_m - rack-proxy (>= 0.6.1) - zeitwerk (~> 2.2) warden (1.2.9) rack (>= 2.0.9) webauthn (3.4.3) @@ -941,7 +928,7 @@ GEM xorcist (1.1.3) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.8.2) + zeitwerk (2.8.3) PLATFORMS ruby @@ -952,6 +939,7 @@ DEPENDENCIES annotaterb (~> 4.13) aws-sdk-core aws-sdk-s3 (~> 1.123) + base58 (~> 0.2.3) better_errors (~> 2.9) binding_of_caller blurhash (~> 0.1) @@ -1001,15 +989,16 @@ DEPENDENCIES irb (~> 1.8) jd-paperclip-azure (~> 3.0) json + json-canonicalization (~> 1.0) json-ld json-ld-preloaded (~> 3.2) json-schema (~> 6.0) kaminari (~> 1.2) - kt-paperclip (~> 7.2) + kt-paperclip (~> 8.0) letter_opener (~> 1.8) letter_opener_web (~> 3.0) link_header (~> 0.0) - linzer (~> 0.7.7) + linzer (~> 0.8.0) lograge (~> 0.12) mail (~> 2.8) mario-redis-lock (~> 1.2) @@ -1024,9 +1013,9 @@ DEPENDENCIES omniauth-rails_csrf_protection (~> 2.0) omniauth-saml (~> 2.0) omniauth_openid_connect (~> 0.8.0) - opentelemetry-api (~> 1.10.0) + opentelemetry-api (~> 1.11.0) opentelemetry-exporter-otlp (~> 0.34.0) - opentelemetry-instrumentation-active_job (~> 0.12.0) + opentelemetry-instrumentation-active_job (~> 0.13.0) opentelemetry-instrumentation-active_model_serializers (~> 0.25.0) opentelemetry-instrumentation-concurrent_ruby (~> 0.25.0) opentelemetry-instrumentation-excon (~> 0.29.0) @@ -1034,7 +1023,7 @@ DEPENDENCIES opentelemetry-instrumentation-http (~> 0.30.0) opentelemetry-instrumentation-http_client (~> 0.29.0) opentelemetry-instrumentation-net_http (~> 0.29.0) - opentelemetry-instrumentation-pg (~> 0.36.0) + opentelemetry-instrumentation-pg (~> 0.37.0) opentelemetry-instrumentation-rack (~> 0.31.0) opentelemetry-instrumentation-rails (~> 0.42.0) opentelemetry-instrumentation-redis (~> 0.29.0) @@ -1044,7 +1033,7 @@ DEPENDENCIES parslet pg (~> 1.5) pghero - playwright-ruby-client (= 1.60.0) + playwright-ruby-client premailer-rails prometheus_exporter (~> 2.2) propshaft @@ -1053,6 +1042,7 @@ DEPENDENCIES pundit (~> 2.3) rack-attack (~> 6.6) rack-cors + rack-proxy rack-test (~> 2.1) rails (~> 8.1.0) rails-i18n (~> 8.0) @@ -1083,7 +1073,7 @@ DEPENDENCIES sidekiq-unique-jobs (> 8) simple-navigation (~> 4.4) simple_form (~> 5.2) - simplecov (~> 0.22) + simplecov simplecov-lcov (~> 0.8) stackprof stoplight @@ -1093,7 +1083,6 @@ DEPENDENCIES tty-prompt (~> 0.23) twitter-text (~> 3.1.0) tzinfo-data (~> 1.2023) - vite_rails webauthn (~> 3.0) webmock (~> 3.18) webpush! @@ -1101,7 +1090,7 @@ DEPENDENCIES xorcist (~> 1.1) RUBY VERSION - ruby 4.0.5 + ruby 4.0.6 BUNDLED WITH - 4.0.23 + 4.0.18 diff --git a/Mastodon-Modern b/Mastodon-Modern deleted file mode 160000 index 301d0033f5..0000000000 --- a/Mastodon-Modern +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 301d0033f593a35a289a22f1891a0dfe12245d7f diff --git a/README.md b/README.md index 7d468abbd2..04a2bf524e 100644 --- a/README.md +++ b/README.md @@ -94,12 +94,12 @@ If you would like to help with translations 🌐 you can do so on [Crowdin](http ## LICENSE -Copyright (c) 2016-2025 Eugen Rochko (+ [`mastodon authors`](AUTHORS.md)) +Copyright (c) 2016-2026 Eugen Rochko (+ [`mastodon authors`](AUTHORS.md)) Licensed under GNU Affero General Public License as stated in the [LICENSE](LICENSE): ```text -Copyright (c) 2016-2025 Eugen Rochko & other Mastodon contributors +Copyright (c) 2016-2026 Eugen Rochko & other Mastodon contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free diff --git a/SECURITY.md b/SECURITY.md index 03affa5ade..27b831632f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -15,6 +15,7 @@ A "vulnerability in Mastodon" is a vulnerability in the code distributed through | Version | Supported | | ------- | ---------------- | +| 4.7.0 | Yes | | 4.6.0 | Yes | | 4.5.x | Until 2027-02-20 | | 4.4.x | Until 2026-12-17 | diff --git a/app/controllers/activitypub/base_controller.rb b/app/controllers/activitypub/base_controller.rb index c2563c492e..784604b93a 100644 --- a/app/controllers/activitypub/base_controller.rb +++ b/app/controllers/activitypub/base_controller.rb @@ -13,4 +13,8 @@ class ActivityPub::BaseController < Api::BaseController def skip_temporary_suspension_response? false end + + def skip_pending_deletion_response? + false + end end diff --git a/app/controllers/activitypub/inboxes_controller.rb b/app/controllers/activitypub/inboxes_controller.rb index b5926d94fd..eb4e039dbe 100644 --- a/app/controllers/activitypub/inboxes_controller.rb +++ b/app/controllers/activitypub/inboxes_controller.rb @@ -4,6 +4,7 @@ class ActivityPub::InboxesController < ActivityPub::BaseController include JsonLdHelper before_action :skip_large_payload + before_action :decorate_trace before_action :skip_unknown_actor_activity before_action :require_actor_signature! skip_before_action :authenticate_user! @@ -21,15 +22,19 @@ class ActivityPub::InboxesController < ActivityPub::BaseController head 413 if request.content_length > ActivityPub::Activity::MAX_JSON_SIZE end + def decorate_trace + ActivityPub::OpenTelemetry.decorate_current_span(payload: parsed_body) + end + def skip_unknown_actor_activity head 202 if unknown_affected_account? end def unknown_affected_account? - json = JSON.parse(body) + json = parsed_body + return false if json.nil? + json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.exists?(uri: json['actor']) - rescue JSON::ParserError - false end def account_required? @@ -40,6 +45,10 @@ class ActivityPub::InboxesController < ActivityPub::BaseController true end + def skip_pending_deletion_response? + true + end + def body return @body if defined?(@body) @@ -51,6 +60,14 @@ class ActivityPub::InboxesController < ActivityPub::BaseController @body end + def parsed_body + return @parsed_body if defined?(@parsed_body) + + @parsed_body = JSON.parse(body) + rescue JSON::ParserError + @parsed_body = nil + end + def upgrade_account if signed_request_account&.ostatus? signed_request_account.update(last_webfingered_at: nil) diff --git a/app/controllers/admin/collections_controller.rb b/app/controllers/admin/collections_controller.rb index 78ac9f0e8b..8d6df4eb4d 100644 --- a/app/controllers/admin/collections_controller.rb +++ b/app/controllers/admin/collections_controller.rb @@ -51,7 +51,7 @@ module Admin end def set_collection - @collection = @account.collections.includes(accepted_collection_items: :account).find(params[:id]) + @collection = @account.collections.includes(accepted_collection_items: { account: [:account_stat, user: [:ips, :invite_request]] }).find(params[:id]) end def set_collections diff --git a/app/controllers/admin/disputes/appeals_controller.rb b/app/controllers/admin/disputes/appeals_controller.rb index 7c70603e23..ccdbeda08d 100644 --- a/app/controllers/admin/disputes/appeals_controller.rb +++ b/app/controllers/admin/disputes/appeals_controller.rb @@ -14,7 +14,7 @@ class Admin::Disputes::AppealsController < Admin::BaseController authorize @appeal, :approve? log_action :approve, @appeal ApproveAppealService.new.call(@appeal, current_account) - redirect_to disputes_strike_path(@appeal.strike) + redirect_to admin_disputes_strike_path(@appeal.strike) end def reject @@ -22,7 +22,7 @@ class Admin::Disputes::AppealsController < Admin::BaseController log_action :reject, @appeal @appeal.reject!(current_account) UserMailer.appeal_rejected(@appeal.account.user, @appeal).deliver_later - redirect_to disputes_strike_path(@appeal.strike) + redirect_to admin_disputes_strike_path(@appeal.strike) end private diff --git a/app/controllers/admin/disputes/strikes_controller.rb b/app/controllers/admin/disputes/strikes_controller.rb new file mode 100644 index 0000000000..e57c713564 --- /dev/null +++ b/app/controllers/admin/disputes/strikes_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Admin::Disputes::StrikesController < Disputes::StrikesController +end diff --git a/app/controllers/admin/email_domain_blocks_controller.rb b/app/controllers/admin/email_domain_blocks_controller.rb index d248a04d61..fd810d3f08 100644 --- a/app/controllers/admin/email_domain_blocks_controller.rb +++ b/app/controllers/admin/email_domain_blocks_controller.rb @@ -59,7 +59,7 @@ module Admin def filter_by_domain scope = EmailDomainBlock.parents.includes(:children).order(id: :desc) - scope.merge!(EmailDomainBlock.matches_domain(params[:domain])) if params[:domain].present? + scope.merge!(EmailDomainBlock.matches_domain(params[:by_domain])) if params[:by_domain].present? scope end diff --git a/app/controllers/admin/ip_blocks_controller.rb b/app/controllers/admin/ip_blocks_controller.rb index afabda1b88..5f917b1880 100644 --- a/app/controllers/admin/ip_blocks_controller.rb +++ b/app/controllers/admin/ip_blocks_controller.rb @@ -5,7 +5,7 @@ module Admin def index authorize :ip_block, :index? - @ip_blocks = IpBlock.order(ip: :asc).page(params[:page]) + @ip_blocks = filter_by_ip(IpBlock.order(ip: :asc).page(params[:page])) @form = Form::IpBlockBatch.new end @@ -43,6 +43,11 @@ module Admin private + def filter_by_ip(scope) + scope.merge!(IpBlock.overlapping_with(params[:ip])) if params[:ip].present? + scope + end + def resource_params params .expect(ip_block: [:ip, :severity, :comment, :expires_in]) diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index 2d6bfbe35c..6ae1069715 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -17,12 +17,15 @@ module Admin authorize @tag, :show? @time_period = report_range + @action_logs = Admin::ActionLogFilter.new(target_tag: @tag.formatted_name).results.limit(5) end def update authorize @tag, :update? if @tag.update(tag_params.merge(reviewed_at: Time.now.utc)) + log_action_from_change if @tag.saved_changes? + redirect_to admin_tag_path(@tag.id), notice: I18n.t('admin.tags.updated_msg') else @time_period = report_range @@ -33,6 +36,13 @@ module Admin private + def log_action_from_change + action_log = current_account.action_logs.new(action: 'update', target: @tag) + action_log.recorded_changes = @tag.saved_changes.slice('usable', 'trendable', 'listable').transform_values(&:last) + action_log.recorded_changes_format = 'tags_format_1.0' + action_log.save + end + def set_tag @tag = Tag.find(params[:id]) end diff --git a/app/controllers/admin/users/sign_in_token_authentications_controller.rb b/app/controllers/admin/users/sign_in_token_authentications_controller.rb new file mode 100644 index 0000000000..7c7c5598c9 --- /dev/null +++ b/app/controllers/admin/users/sign_in_token_authentications_controller.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Admin + class Users::SignInTokenAuthenticationsController < BaseController + before_action :set_target_user + + def create + authorize @user, :enable_sign_in_token? + @user.enable_sign_in_token! + log_action :enable_sign_in_token, @user + redirect_to admin_account_path(@user.account_id) + end + + def destroy + authorize @user, :disable_sign_in_token? + @user.disable_sign_in_token! + log_action :disable_sign_in_token, @user + redirect_to admin_account_path(@user.account_id) + end + + private + + def set_target_user + @user = User.find(params[:user_id]) + end + end +end diff --git a/app/controllers/api/fasp/base_controller.rb b/app/controllers/api/fasp/base_controller.rb index a05d0049ba..fc7999c141 100644 --- a/app/controllers/api/fasp/base_controller.rb +++ b/app/controllers/api/fasp/base_controller.rb @@ -4,7 +4,6 @@ class Api::Fasp::BaseController < ApplicationController class Error < ::StandardError; end DIGEST_PATTERN = /sha-256=:(.*?):/ - KEYID_PATTERN = /keyid="(.*?)"/ attr_reader :current_provider diff --git a/app/controllers/api/v1/accounts/base_controller.rb b/app/controllers/api/v1/accounts/base_controller.rb new file mode 100644 index 0000000000..6931d07645 --- /dev/null +++ b/app/controllers/api/v1/accounts/base_controller.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Api::V1::Accounts::BaseController < Api::BaseController + private + + def set_account + @account = Account.without_requested_deletion.find(params[:account_id]) + end +end diff --git a/app/controllers/api/v1/accounts/endorsements_controller.rb b/app/controllers/api/v1/accounts/endorsements_controller.rb index 1e21994a90..eaa48c2c12 100644 --- a/app/controllers/api/v1/accounts/endorsements_controller.rb +++ b/app/controllers/api/v1/accounts/endorsements_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::V1::Accounts::EndorsementsController < Api::BaseController +class Api::V1::Accounts::EndorsementsController < Api::V1::Accounts::BaseController include Authorization before_action -> { authorize_if_got_token! :read, :'read:accounts' }, only: :index @@ -28,10 +28,6 @@ class Api::V1::Accounts::EndorsementsController < Api::BaseController private - def set_account - @account = Account.find(params[:account_id]) - end - def set_endorsed_accounts @endorsed_accounts = @account.unavailable? ? [] : paginated_endorsed_accounts end diff --git a/app/controllers/api/v1/accounts/featured_tags_controller.rb b/app/controllers/api/v1/accounts/featured_tags_controller.rb index f95846366c..40b35cd90a 100644 --- a/app/controllers/api/v1/accounts/featured_tags_controller.rb +++ b/app/controllers/api/v1/accounts/featured_tags_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::V1::Accounts::FeaturedTagsController < Api::BaseController +class Api::V1::Accounts::FeaturedTagsController < Api::V1::Accounts::BaseController before_action :set_account before_action :set_featured_tags @@ -12,10 +12,6 @@ class Api::V1::Accounts::FeaturedTagsController < Api::BaseController private - def set_account - @account = Account.find(params[:account_id]) - end - def set_featured_tags @featured_tags = @account.unavailable? ? [] : @account.featured_tags end diff --git a/app/controllers/api/v1/accounts/follower_accounts_controller.rb b/app/controllers/api/v1/accounts/follower_accounts_controller.rb index 3f2ecb892d..78415bd8e7 100644 --- a/app/controllers/api/v1/accounts/follower_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/follower_accounts_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::V1::Accounts::FollowerAccountsController < Api::BaseController +class Api::V1::Accounts::FollowerAccountsController < Api::V1::Accounts::BaseController before_action -> { authorize_if_got_token! :read, :'read:accounts' } before_action :set_account after_action :insert_pagination_headers @@ -13,10 +13,6 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController private - def set_account - @account = Account.find(params[:account_id]) - end - def load_accounts return [] if hide_results? diff --git a/app/controllers/api/v1/accounts/following_accounts_controller.rb b/app/controllers/api/v1/accounts/following_accounts_controller.rb index 7c16a3487e..138e728991 100644 --- a/app/controllers/api/v1/accounts/following_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/following_accounts_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::V1::Accounts::FollowingAccountsController < Api::BaseController +class Api::V1::Accounts::FollowingAccountsController < Api::V1::Accounts::BaseController before_action -> { authorize_if_got_token! :read, :'read:accounts' } before_action :set_account after_action :insert_pagination_headers @@ -13,10 +13,6 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController private - def set_account - @account = Account.find(params[:account_id]) - end - def load_accounts return [] if hide_results? diff --git a/app/controllers/api/v1/accounts/identity_proofs_controller.rb b/app/controllers/api/v1/accounts/identity_proofs_controller.rb index 02a45e8758..d01a8fb27e 100644 --- a/app/controllers/api/v1/accounts/identity_proofs_controller.rb +++ b/app/controllers/api/v1/accounts/identity_proofs_controller.rb @@ -6,15 +6,8 @@ class Api::V1::Accounts::IdentityProofsController < Api::BaseController deprecate_api '2022-03-30' before_action :require_user! - before_action :set_account def index render json: [] end - - private - - def set_account - @account = Account.find(params[:account_id]) - end end diff --git a/app/controllers/api/v1/accounts/lists_controller.rb b/app/controllers/api/v1/accounts/lists_controller.rb index c92f1f8a08..42a6bdff32 100644 --- a/app/controllers/api/v1/accounts/lists_controller.rb +++ b/app/controllers/api/v1/accounts/lists_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::V1::Accounts::ListsController < Api::BaseController +class Api::V1::Accounts::ListsController < Api::V1::Accounts::BaseController before_action -> { doorkeeper_authorize! :read, :'read:lists' } before_action :require_user! before_action :set_account @@ -9,10 +9,4 @@ class Api::V1::Accounts::ListsController < Api::BaseController @lists = @account.suspended? ? [] : @account.lists.where(account: current_account) render json: @lists, each_serializer: REST::ListSerializer end - - private - - def set_account - @account = Account.find(params[:account_id]) - end end diff --git a/app/controllers/api/v1/accounts/lookup_controller.rb b/app/controllers/api/v1/accounts/lookup_controller.rb index 6d63398781..db93817656 100644 --- a/app/controllers/api/v1/accounts/lookup_controller.rb +++ b/app/controllers/api/v1/accounts/lookup_controller.rb @@ -13,6 +13,7 @@ class Api::V1::Accounts::LookupController < Api::BaseController def set_account @account = ResolveAccountService.new.call(params[:acct], skip_webfinger: true) || raise(ActiveRecord::RecordNotFound) + raise ActiveRecord::RecordNotFound if @account.deleted? rescue Addressable::URI::InvalidURIError raise(ActiveRecord::RecordNotFound) end diff --git a/app/controllers/api/v1/accounts/notes_controller.rb b/app/controllers/api/v1/accounts/notes_controller.rb index b9b58b23d4..03d9a77a64 100644 --- a/app/controllers/api/v1/accounts/notes_controller.rb +++ b/app/controllers/api/v1/accounts/notes_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::V1::Accounts::NotesController < Api::BaseController +class Api::V1::Accounts::NotesController < Api::V1::Accounts::BaseController include Authorization before_action -> { doorkeeper_authorize! :write, :'write:accounts' } @@ -20,10 +20,6 @@ class Api::V1::Accounts::NotesController < Api::BaseController private - def set_account - @account = Account.find(params[:account_id]) - end - def relationships_presenter AccountRelationshipsPresenter.new([@account], current_user.account_id) end diff --git a/app/controllers/api/v1/accounts/relationships_controller.rb b/app/controllers/api/v1/accounts/relationships_controller.rb index d43832177a..b6af5e0291 100644 --- a/app/controllers/api/v1/accounts/relationships_controller.rb +++ b/app/controllers/api/v1/accounts/relationships_controller.rb @@ -5,7 +5,7 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController before_action :require_user! def index - @accounts = Account.where(id: account_ids).select(:id, :domain) + @accounts = Account.without_requested_deletion.where(id: account_ids).select(:id, :domain) @accounts.merge!(Account.without_suspended) unless truthy_param?(:with_suspended) render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships end diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index c42f27776c..a297defd49 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::V1::Accounts::StatusesController < Api::BaseController +class Api::V1::Accounts::StatusesController < Api::V1::Accounts::BaseController before_action -> { authorize_if_got_token! :read, :'read:statuses' } before_action :set_account @@ -14,10 +14,6 @@ class Api::V1::Accounts::StatusesController < Api::BaseController private - def set_account - @account = Account.find(params[:account_id]) - end - def load_statuses @account.unavailable? ? [] : preloaded_account_statuses end diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 9956c1dc1a..bcbd01a606 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -84,11 +84,11 @@ class Api::V1::AccountsController < Api::BaseController private def set_account - @account = Account.find(params[:id]) + @account = Account.without_requested_deletion.find(params[:id]) end def set_accounts - @accounts = Account.where(id: account_ids).without_unapproved + @accounts = Account.where(id: account_ids).without_unapproved.without_requested_deletion end def check_account_approval diff --git a/app/controllers/api/v1/admin/ip_blocks_controller.rb b/app/controllers/api/v1/admin/ip_blocks_controller.rb index e3671ea494..93c2d4afb2 100644 --- a/app/controllers/api/v1/admin/ip_blocks_controller.rb +++ b/app/controllers/api/v1/admin/ip_blocks_controller.rb @@ -34,7 +34,7 @@ class Api::V1::Admin::IpBlocksController < Api::BaseController def update authorize @ip_block, :update? - @ip_block.update(resource_params) + @ip_block.update!(resource_params) log_action :update, @ip_block render json: @ip_block, serializer: REST::Admin::IpBlockSerializer end diff --git a/app/controllers/api/v1/collection_items_controller.rb b/app/controllers/api/v1/collection_items_controller.rb index 6b7db97b06..a142bead8b 100644 --- a/app/controllers/api/v1/collection_items_controller.rb +++ b/app/controllers/api/v1/collection_items_controller.rb @@ -50,7 +50,7 @@ class Api::V1::CollectionItemsController < Api::BaseController def set_account return render(json: { error: '`account_id` parameter is missing' }, status: 422) if params[:account_id].blank? - @account = Account.find(params[:account_id]) + @account = Account.without_requested_deletion.find(params[:account_id]) end def set_collection_item diff --git a/app/controllers/api/v1/collections_controller.rb b/app/controllers/api/v1/collections_controller.rb index 08453a7ed6..b478d4f44e 100644 --- a/app/controllers/api/v1/collections_controller.rb +++ b/app/controllers/api/v1/collections_controller.rb @@ -69,7 +69,7 @@ class Api::V1::CollectionsController < Api::BaseController private def set_account - @account = Account.find(params[:account_id]) + @account = Account.without_requested_deletion.find(params[:account_id]) end def set_collections diff --git a/app/controllers/api/v1/in_collections_controller.rb b/app/controllers/api/v1/in_collections_controller.rb index c34845e463..1fc6639fa6 100644 --- a/app/controllers/api/v1/in_collections_controller.rb +++ b/app/controllers/api/v1/in_collections_controller.rb @@ -25,7 +25,7 @@ class Api::V1::InCollectionsController < Api::BaseController private def set_account - @account = Account.find(params[:account_id]) + @account = Account.without_requested_deletion.find(params[:account_id]) end def set_collections diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 3d757be679..45bf56a28f 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -17,6 +17,7 @@ class Auth::SessionsController < Devise::SessionsController prepend_before_action :check_suspicious!, only: [:create] include Auth::TwoFactorAuthenticationConcern + include Auth::SignInTokenAuthenticationConcern content_security_policy only: :new do |p| p.form_action(false) @@ -62,7 +63,7 @@ class Auth::SessionsController < Devise::SessionsController end def user_params - params.expect(user: [:email, :password, :otp_attempt, credential: {}]) + params.expect(user: [:email, :password, :otp_attempt, :sign_in_token_attempt, credential: {}]) end def after_sign_in_path_for(resource) @@ -169,6 +170,10 @@ class Auth::SessionsController < Devise::SessionsController ) ) + # No need to send a mail for failure to log in with a sign-in token, as that goes throug a mail + # as well + return if security_measure == :sign_in_token + # Only send a notification email every hour at most return if redis.set("2fa_failure_notification:#{user.id}", '1', ex: 1.hour, get: true).present? diff --git a/app/controllers/concerns/account_owned_concern.rb b/app/controllers/concerns/account_owned_concern.rb index 7b3cd4d3ea..6e94e22d96 100644 --- a/app/controllers/concerns/account_owned_concern.rb +++ b/app/controllers/concerns/account_owned_concern.rb @@ -40,7 +40,7 @@ module AccountOwnedConcern def check_account_suspension if @account.permanently_unavailable? permanent_unavailability_response - elsif @account.suspended? && !skip_temporary_suspension_response? + elsif (@account.suspended? && !skip_temporary_suspension_response?) || (@account.deleted? && !skip_pending_deletion_response?) temporary_suspension_response end end @@ -49,6 +49,10 @@ module AccountOwnedConcern false end + def skip_pending_deletion_response? + false + end + def permanent_unavailability_response expires_in(3.minutes, public: true) gone diff --git a/app/controllers/concerns/auth/sign_in_token_authentication_concern.rb b/app/controllers/concerns/auth/sign_in_token_authentication_concern.rb new file mode 100644 index 0000000000..abb55d67e3 --- /dev/null +++ b/app/controllers/concerns/auth/sign_in_token_authentication_concern.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Auth::SignInTokenAuthenticationConcern + extend ActiveSupport::Concern + + included do + prepend_before_action :authenticate_with_sign_in_token, if: :sign_in_token_required?, only: [:create] + end + + def sign_in_token_required? + find_user&.suspicious_inactive_sign_in? + end + + def authenticate_with_sign_in_token + if user_params[:email].present? + user = self.resource = find_user_from_params + prompt_for_sign_in_token(user) if user&.valid_password?(user_params[:password]) + elsif session[:attempt_user_id] + user = self.resource = User.find_by(id: session[:attempt_user_id]) + return if user.nil? + + if session[:attempt_user_updated_at] != user.updated_at.to_s + restart_session + elsif params.key?(:sign_in_token_resend) + prompt_for_sign_in_token(user, resend: true) + elsif user_params[:sign_in_token_attempt].present? + authenticate_with_sign_in_token_attempt(user) + end + end + end + + def authenticate_with_sign_in_token_attempt(user) + if check_second_factor_rate_limits(user) + flash.now[:alert] = I18n.t('users.rate_limited') + return prompt_for_sign_in_token(user) + end + + if user.valid_sign_in_token?(user_params[:sign_in_token_attempt]) + user.clear_sign_in_token! + on_authentication_success(user, :sign_in_token) + else + on_authentication_failure(user, :sign_in_token, :invalid_sign_in_token) + flash.now[:alert] = I18n.t('users.invalid_sign_in_token') + prompt_for_sign_in_token(user) + end + end + + def prompt_for_sign_in_token(user, resend: false) + if resend || user.sign_in_token_expired? + user.generate_sign_in_token && user.save + UserMailer.sign_in_token(user, request.remote_ip, request.user_agent, Time.now.utc.to_s).deliver_later! + end + + register_attempt_in_session(user) + render :sign_in_token + end +end diff --git a/app/controllers/concerns/deprecation_concern.rb b/app/controllers/concerns/deprecation_concern.rb index ad8de724a1..b9c7d286f0 100644 --- a/app/controllers/concerns/deprecation_concern.rb +++ b/app/controllers/concerns/deprecation_concern.rb @@ -11,6 +11,11 @@ module DeprecationConcern before_action(**kwargs) do response.headers['Deprecation'] = deprecation_timestamp response.headers['Sunset'] = sunset if sunset + + span = OpenTelemetry::Trace.current_span + next unless span&.recording? + + span.set_attribute('app.endpoint.deprecated', true) end end end diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index 1a876b0cad..9919da9832 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -7,8 +7,6 @@ module SignatureVerification include DomainControlHelper - EXPIRATION_WINDOW_LIMIT = 12.hours - CLOCK_SKEW_MARGIN = 1.hour STOPLIGHT_COOL_OFF_TIME = 5.minutes.seconds STOPLIGHT_THRESHOLD = 1 @@ -110,7 +108,7 @@ module SignatureVerification end rescue Mastodon::PrivateNetworkAddressError => e raise Mastodon::SignatureVerificationError, "Requests to private network addresses are disallowed (tried to query #{e.host})" - rescue Mastodon::HostValidationError, ActivityPub::FetchRemoteActorService::Error, ActivityPub::FetchRemoteKeyService::Error, Webfinger::Error => e + rescue Mastodon::HostValidationError, ActivityPub::ProcessAccountService::Error, ActivityPub::FetchRemoteActorService::Error, ActivityPub::FetchRemoteKeyService::Error, Webfinger::Error => e raise Mastodon::SignatureVerificationError, e.message end diff --git a/app/controllers/settings/deletes_controller.rb b/app/controllers/settings/deletes_controller.rb index d502c8d4ed..bdbaa92df6 100644 --- a/app/controllers/settings/deletes_controller.rb +++ b/app/controllers/settings/deletes_controller.rb @@ -36,7 +36,7 @@ class Settings::DeletesController < Settings::BaseController end def destroy_account! - current_account.suspend!(origin: :local, block_email: false) + current_account.mark_deleted! AccountDeletionWorker.perform_async(current_user.account_id) sign_out end diff --git a/app/helpers/admin/action_logs_helper.rb b/app/helpers/admin/action_logs_helper.rb index 76edb965a6..2f675aeb7d 100644 --- a/app/helpers/admin/action_logs_helper.rb +++ b/app/helpers/admin/action_logs_helper.rb @@ -37,9 +37,30 @@ module Admin::ActionLogsHelper end when 'Relay' link_to log.human_identifier, admin_relays_path + when 'Tag' + link_to log.human_identifier, admin_tag_path(log.target_id) end end + def chain_multiple_translations(action_log) + case action_log.target_type + when 'Tag' + %i(usable trendable listable).filter_map do |key| + fetch_key = permutation_of_key(action_log, key) + next if fetch_key.nil? + + t "admin.trends.tags.#{fetch_key}" + end.join('; ') + end + end + + def permutation_of_key(log, key) + # we're utilizing the store_accessors here, to get the values from the jsonb like: log.listable => true + return if log.public_send(key).nil? + + log.public_send(key) ? key : :"not_#{key}" + end + def sorted_action_log_types Admin::ActionLogFilter::ACTION_TYPE_MAP .keys diff --git a/app/helpers/context_helper.rb b/app/helpers/context_helper.rb index 5f6fbfafdb..6499da7240 100644 --- a/app/helpers/context_helper.rb +++ b/app/helpers/context_helper.rb @@ -4,6 +4,7 @@ module ContextHelper NAMED_CONTEXT_MAP = { activitystreams: 'https://www.w3.org/ns/activitystreams', security: 'https://w3id.org/security/v1', + controlled_identifiers: 'https://www.w3.org/ns/cid/v1', webfinger: 'https://purl.archive.org/socialweb/webfinger', }.freeze diff --git a/app/helpers/json_ld_helper.rb b/app/helpers/json_ld_helper.rb index 680a9868df..08074b2c17 100644 --- a/app/helpers/json_ld_helper.rb +++ b/app/helpers/json_ld_helper.rb @@ -17,6 +17,22 @@ module JsonLdHelper value.is_a?(Array) ? value.first : value end + # Some attributes we read can be either `xsd:string` or `rdf:langString` + # and will lead to different compacted forms depending on which they are. + # Furthermore, we don't unconditionally compact to our context, so we + # may also find non-compacted forms. + # This is the case of `summary`, `name` and `content` as defined in ActivityStreams. + def first_lang_string(json, name) + if json[name] + value = first_of_value(json[name]) + return value if value.is_a?(String) + + value['@value'] if value.is_a?(Hash) + elsif json["#{name}Map"] + json["#{name}Map"].values.first + end + end + def uri_from_bearcap(str) if str&.start_with?('bear:') Addressable::URI.parse(str).query_values['u'] @@ -106,10 +122,10 @@ module JsonLdHelper graph.dump(:normalize) end - def compact(json) - compacted = JSON::LD::API.compact(json.without('signature'), full_context, documentLoader: method(:load_jsonld_context)) - compacted['signature'] = json['signature'] - compacted + def compact(json, context = full_context) + JSON::LD::API.compact(json.without('signature'), context, documentLoader: method(:load_jsonld_context)).tap do |compacted| + compacted['signature'] = json['signature'] + end end # Checks for unsupported JSON-LD features or too many nodes @@ -241,7 +257,7 @@ module JsonLdHelper # If an error is raised, it contains the response and can be captured for handling like # # begin - # fetch_resource_without_id_validation(uri, raise_on_error: all) + # fetch_resource_without_id_validation(uri, raise_on_error: :all) # rescue Mastodon::UnexpectedResponseError => e # e.response # end diff --git a/app/helpers/routing_helper.rb b/app/helpers/routing_helper.rb index b5d090db49..8c69430eeb 100644 --- a/app/helpers/routing_helper.rb +++ b/app/helpers/routing_helper.rb @@ -4,7 +4,7 @@ module RoutingHelper extend ActiveSupport::Concern include ActionView::Helpers::AssetTagHelper - include ViteRails::TagHelpers + include Vite::TagsHelper included do include Rails.application.routes.url_helpers diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index b99e0023f4..361d51ffa5 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -9,6 +9,12 @@ module SettingsHelper LanguagesHelper.sorted_locale_keys(I18n.available_locales) end + def inline_qrcode_svg(code) + code + .as_svg(padding: 0, module_size: 4, use_path: true) + .html_safe # rubocop:disable Rails/OutputSafety + end + def featured_tags_hint(recently_used_tags) recently_used_tags.present? && safe_join( diff --git a/app/javascript/entrypoints/public.tsx b/app/javascript/entrypoints/public.tsx index 5563b8324e..363ca0fec9 100644 --- a/app/javascript/entrypoints/public.tsx +++ b/app/javascript/entrypoints/public.tsx @@ -15,6 +15,7 @@ import { throttle } from 'lodash'; import { determineEmojiMode } from '@/mastodon/features/emoji/mode'; import { updateHtmlWithEmoji } from '@/mastodon/features/emoji/render'; +import type { InitialState } from '@/mastodon/initial_state'; import loadKeyboardExtensions from '@/mastodon/load_keyboard_extensions'; import { loadLocale, getLocale } from '@/mastodon/locales'; import { loadPolyfills } from '@/mastodon/polyfills'; @@ -83,7 +84,7 @@ async function loaded() { document.getElementById('initial-state')?.textContent; if (initialStateText) { const stateEmojiStyle = getNestedProperty( - JSON.parse(initialStateText) as unknown, + JSON.parse(initialStateText) as InitialState, 'meta', 'emoji_style', ); @@ -522,14 +523,6 @@ on('click', '.rules-list button', ({ target }) => { * don't produce accessible markup (simple-forms & simple-navigation) */ function applyRailsA11yPatches() { - /** - * Mark current navigation item with aria-current - */ - const activeNavLink = document.querySelector( - '.simple-navigation-active-leaf a.selected', - ); - activeNavLink?.setAttribute('aria-current', 'page'); - /** * Hides the asterisk added to labels of required form fields * from assistive tech. (Those fields already have the `required` attribute) diff --git a/app/javascript/flavours/glitch/actions/alerts.ts b/app/javascript/flavours/glitch/actions/alerts.ts index 950d83a3f5..ac81fd7f68 100644 --- a/app/javascript/flavours/glitch/actions/alerts.ts +++ b/app/javascript/flavours/glitch/actions/alerts.ts @@ -7,6 +7,8 @@ import type { AxiosResponse } from 'axios'; import type { Alert } from 'flavours/glitch/models/alert'; +import { createAppThunk } from '../store/typed_functions'; + interface ApiErrorResponse { error?: string; } @@ -74,3 +76,12 @@ export const showAlertForError = (error: unknown, skipNotFound = false) => { message: messages.unexpectedMessage, }); }; + +export const showGenericAlert = createAppThunk((_arg, { dispatch }) => { + dispatch( + showAlert({ + title: messages.unexpectedTitle, + message: messages.unexpectedMessage, + }), + ); +}); diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index a3f1ac6d20..8ba8aac791 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -15,6 +15,7 @@ import { useEmoji } from './emojis'; import { importFetchedAccounts, importFetchedStatus } from './importer'; import { openModal } from './modal'; import { updateTimeline } from './timelines'; +import { insertStatusIntoAccountTimelines } from './timelines_typed'; /** @type {AbortController | undefined} */ let fetchComposeSuggestionsAccountsController; @@ -197,25 +198,16 @@ export function directCompose(account) { }; } -/** - * @callback ComposeSuccessCallback - * @param {Object} status - */ - -/** - * @param {null | string} overridePrivacy - * @param {undefined | ComposeSuccessCallback} successCallback - */ -export function submitCompose(overridePrivacy = null, successCallback = undefined) { +export function submitCompose(successCallback, overridePrivacy) { return function (dispatch, getState) { - let status = getState().getIn(['compose', 'text'], ''); - const media = getState().getIn(['compose', 'media_attachments']); - const statusId = getState().getIn(['compose', 'id'], null); - const hasQuote = !!getState().getIn(['compose', 'quoted_status_id']); - const spoilers = getState().getIn(['compose', 'spoiler']) || getState().getIn(['local_settings', 'always_show_spoilers_field']); + const statusText = getState().getIn(['compose', 'text'], ''); + const media = getState().getIn(['compose', 'media_attachments']); + const statusId = getState().getIn(['compose', 'id'], null); + const hasQuote = !!getState().getIn(['compose', 'quoted_status_id']); + const spoilers = getState().getIn(['compose', 'spoiler']) || getState().getIn(['local_settings', 'always_show_spoilers_field']); const spoiler_text = spoilers ? getState().getIn(['compose', 'spoiler_text'], '') : ''; - const fulltext = `${spoiler_text ?? ''}${countableText(status ?? '')}`; + const fulltext = `${spoiler_text ?? ''}${countableText(statusText ?? '')}`; const hasText = fulltext.trim().length > 0; if (!(hasText || media.size !== 0 || (hasQuote && spoiler_text?.length))) { @@ -254,7 +246,7 @@ export function submitCompose(overridePrivacy = null, successCallback = undefine url: statusId === null ? '/api/v1/statuses' : `/api/v1/statuses/${statusId}`, method: statusId === null ? 'post' : 'put', data: { - status, + status: statusText, spoiler_text, content_type: getState().getIn(['compose', 'content_type']), local_only: getState().getIn(['compose', 'advanced_options', 'do_not_federate']), @@ -278,7 +270,7 @@ export function submitCompose(overridePrivacy = null, successCallback = undefine browserHistory.goBack(); } - dispatch(insertIntoTagHistory(response.data.tags, status)); + dispatch(insertIntoTagHistory(response.data.tags, statusText)); dispatch(submitComposeSuccess({ ...response.data })); if (typeof successCallback === 'function') { successCallback(response.data); @@ -311,6 +303,8 @@ export function submitCompose(overridePrivacy = null, successCallback = undefine insertIfOnline('direct'); } + dispatch(insertStatusIntoAccountTimelines({ ...response.data })); + if (getState().getIn(['local_settings', 'show_published_toast'])) { dispatch(showAlert({ message: statusId === null ? messages.published : messages.saved, diff --git a/app/javascript/flavours/glitch/actions/compose_typed.ts b/app/javascript/flavours/glitch/actions/compose_typed.ts index d89157e534..129d3c66a1 100644 --- a/app/javascript/flavours/glitch/actions/compose_typed.ts +++ b/app/javascript/flavours/glitch/actions/compose_typed.ts @@ -3,24 +3,32 @@ import { defineMessages } from 'react-intl'; import { createAction } from '@reduxjs/toolkit'; import type { List as ImmutableList, Map as ImmutableMap } from 'immutable'; -import { apiUpdateMedia } from 'flavours/glitch/api/compose'; -import { apiGetSearch } from 'flavours/glitch/api/search'; -import type { ApiMediaAttachmentJSON } from 'flavours/glitch/api_types/media_attachments'; -import type { MediaAttachment } from 'flavours/glitch/models/media_attachment'; +import { apiUpdateMedia } from '@/flavours/glitch/api/compose'; +import { apiGetSearch } from '@/flavours/glitch/api/search'; +import type { ApiMediaAttachmentJSON } from '@/flavours/glitch/api_types/media_attachments'; +import type { ApiQuotePolicy } from '@/flavours/glitch/api_types/quotes'; +import type { MediaAttachment } from '@/flavours/glitch/models/media_attachment'; +import type { Status, StatusVisibility } from '@/flavours/glitch/models/status'; +import type { RootState } from '@/flavours/glitch/store'; import { createDataLoadingThunk, createAppThunk, -} from 'flavours/glitch/store/typed_functions'; +} from '@/flavours/glitch/store/typed_functions'; -import type { ApiQuotePolicy } from '../api_types/quotes'; -import type { Status, StatusVisibility } from '../models/status'; -import type { RootState } from '../store'; +import type { ApiStatusJSON } from '../api_types/statuses'; import { showAlert } from './alerts'; -import { changeCompose, focusCompose } from './compose'; +import { + changeCompose, + focusCompose, + submitCompose as submitComposeApi, + uploadCompose, +} from './compose'; import { importFetchedStatuses } from './importer'; import { openModal } from './modal'; +export const PRIVATE_QUOTE_MODAL_ID = 'quote/private_notify'; + const messages = defineMessages({ quoteErrorEdit: { id: 'quote_error.edit', @@ -159,13 +167,11 @@ export const quoteComposeByStatus = createAppThunk( const state = getState(); const composeState = state.compose; const mediaAttachments = composeState.get('media_attachments'); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const wasQuietPostHintModalDismissed: boolean = - // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access - state.settings.getIn( - ['dismissed_banners', 'quote/quiet_post_hint'], - false, - ); + + const wasQuietPostHintModalDismissed = !!state.settings.getIn( + ['dismissed_banners', 'quote/quiet_post_hint'], + false, + ); if (composeState.get('id')) { dispatch(showAlert({ message: messages.quoteErrorEdit })); @@ -278,3 +284,85 @@ export const setComposeQuotePolicy = createAction( export const setDragUploadEnabled = createAction( 'compose/setDragUploadEnabled', ); + +export const submitCompose = createAppThunk( + ( + { + textareaValue = '', + redirectOnSuccess, + }: { textareaValue?: string; redirectOnSuccess?: boolean }, + { getState, dispatch }, + ) => { + if ( + textareaValue && + (getState().compose.get('text') as string) !== textareaValue + ) { + dispatch(changeCompose(textareaValue)); + } + + const { compose, meta, statuses, settings } = getState(); + const privacy = compose.get('privacy') as StatusVisibility; + const missingAltText = ( + compose.get('media_attachments') as unknown as Immutable.List< + Immutable.Map + > + ).some( + (media) => + ['image', 'gifv'].includes(media.get('type') ?? '') && + (media.get('description') ?? '').length === 0, + ); + const me = meta.get('me') as string | null; + const quotedStatusId = compose.get('quoted_status_id') as string | null; + const quoteToPrivate = + !!quotedStatusId && + privacy === 'private' && + statuses.getIn([quotedStatusId, 'account']) !== me && + !settings.getIn(['dismissed_banners', PRIVATE_QUOTE_MODAL_ID]); + + if ( + !!meta.get('missing_alt_text_modal') && + missingAltText && + privacy !== 'direct' + ) { + dispatch( + openModal({ + modalType: 'CONFIRM_MISSING_ALT_TEXT', + modalProps: {}, + }), + ); + } else if (quoteToPrivate) { + dispatch( + openModal({ + modalType: 'CONFIRM_PRIVATE_QUOTE_NOTIFY', + modalProps: {}, + }), + ); + } else { + dispatch( + submitComposeApi((status: ApiStatusJSON) => { + if (redirectOnSuccess) { + window.location.assign(status.url); + } + }), + ); + } + }, +); + +const urlLikeRegex = /^https?:\/\/[^\s]+\/[^\s]+$/i; + +export const processPasteOrDrop = createAppThunk( + (transfer: DataTransfer, { dispatch }) => { + if (transfer.files.length === 1) { + dispatch(uploadCompose(transfer.files)); + } else if (transfer.files.length === 0) { + const data = transfer.getData('text/plain'); + if (!urlLikeRegex.exec(data)) return; + + try { + const url = new URL(data).toString(); + void dispatch(pasteLinkCompose({ url })); + } catch {} + } + }, +); diff --git a/app/javascript/flavours/glitch/actions/importer/statuses.ts b/app/javascript/flavours/glitch/actions/importer/statuses.ts new file mode 100644 index 0000000000..f867827c35 --- /dev/null +++ b/app/javascript/flavours/glitch/actions/importer/statuses.ts @@ -0,0 +1,187 @@ +import escapeTextContentForBrowser from 'escape-html'; + +import type { ApiMediaAttachmentJSON } from '@/flavours/glitch/api_types/media_attachments'; +import type { + ApiFilterResultJSON, + ApiStatusJSON, +} from '@/flavours/glitch/api_types/statuses'; +import type { + FilterResult, + MediaAttachmentShape, + StatusShape, +} from '@/flavours/glitch/models/status'; + +const domParser = new DOMParser(); + +export function normalizeStatus( + status: ApiStatusJSON, + normalOldStatus?: StatusShape, + { bogusQuotePolicy = false, expandSpoilers = false } = {}, +) { + const normalStatus: StatusShape = { + hidden: normalOldStatus?.hidden ?? false, + collapsed: normalOldStatus?.collapsed ?? null, + content: '', + contentHtml: '', + muted: false, + pinned: false, + bookmarked: false, + favourited: false, + quote_approval: null, + reblogged: false, + + ...status, + + account: status.account.id, + media_attachments: [], + poll: status.poll?.id, + reblog: status.reblog?.id, + quote: undefined, + filtered: [], + application: { + name: 'Web', + ...status.application, + }, + }; + + if (bogusQuotePolicy) { + normalStatus.quote_approval = null; + } + + if (status.quote?.quoted_status) { + normalStatus.quote = { + ...status.quote, + quoted_status: status.quote.quoted_status.id, + }; + } + + if (status.card) { + normalStatus.card = { + ...status.card, + authors: status.card.authors.map((author) => ({ + name: author.name, + url: author.url, + accountId: author.account?.id, + })), + }; + } + + if (status.filtered) { + normalStatus.filtered = status.filtered.map(normalizeFilterResult); + } + + // Only calculate these values when status first encountered and + // when the underlying values change. Otherwise keep the ones + // already in the reducer + if ( + normalOldStatus?.content === normalStatus.content && + normalOldStatus.spoiler_text === normalStatus.spoiler_text + ) { + normalStatus.search_index = normalOldStatus.search_index; + normalStatus.contentHtml = normalOldStatus.contentHtml; + normalStatus.spoilerHtml = normalOldStatus.spoilerHtml; + normalStatus.spoiler_text = normalOldStatus.spoiler_text; + normalStatus.hidden = normalOldStatus.hidden; + + if (normalOldStatus.translation) { + normalStatus.translation = normalOldStatus.translation; + } + } else { + // If the status has a CW but no contents, treat the CW as if it were the + // status' contents, to avoid having a CW toggle with seemingly no effect. + if ( + normalStatus.spoiler_text && + !normalStatus.content && + !normalStatus.quote + ) { + normalStatus.content = normalStatus.spoiler_text; + normalStatus.spoiler_text = ''; + } + + const spoilerText = normalStatus.spoiler_text ?? ''; + const searchContent = [spoilerText, status.content] + .concat( + status.poll?.options + ? status.poll.options.map((option) => option.title) + : [], + ) + .concat(status.media_attachments.map((att) => att.description)) + .join('\n\n') + .replace(//g, '\n') + .replace(/<\/p>

/g, '\n\n'); + + normalStatus.search_index = domParser.parseFromString( + searchContent, + 'text/html', + ).documentElement.textContent; + normalStatus.contentHtml = normalStatus.content; + normalStatus.spoilerHtml = escapeTextContentForBrowser(spoilerText); + normalStatus.hidden = expandSpoilers + ? false + : spoilerText.length > 0 || normalStatus.sensitive; + + // Remove quote fallback link from the DOM so it doesn't mess with paragraph margins + if (normalStatus.quote && normalStatus.contentHtml) { + normalStatus.contentHtml = stripQuoteFallback(normalStatus.contentHtml); + } + + if ( + normalStatus.url && + !( + normalStatus.url.startsWith('http://') || + normalStatus.url.startsWith('https://') + ) + ) { + normalStatus.url = null; + } + + normalStatus.url ??= normalStatus.uri; + + normalStatus.media_attachments = status.media_attachments.map( + (attachment) => + normalizeMediaAttachment( + attachment, + normalOldStatus?.media_attachments, + ), + ); + } + + if (normalOldStatus) { + normalStatus.quote_approval ??= normalOldStatus.quote_approval; + } + + return normalStatus; +} + +function normalizeMediaAttachment( + attachment: ApiMediaAttachmentJSON, + oldAttachments?: MediaAttachmentShape[], +): MediaAttachmentShape { + const { remote_url } = attachment; + return { + ...attachment, + remote_url: + remote_url && /^https?:\/\//.test(remote_url) ? remote_url : null, + translation: oldAttachments?.find( + (oldAttachment) => + oldAttachment.id === attachment.id && + oldAttachment.description === attachment.description, + )?.translation, + }; +} + +function normalizeFilterResult(input: ApiFilterResultJSON): FilterResult { + return { + ...input, + filter: input.filter.id, + }; +} + +function stripQuoteFallback(text: string) { + const wrapper = document.createElement('div'); + wrapper.innerHTML = text; + + wrapper.querySelector('.quote-inline')?.remove(); + + return wrapper.innerHTML; +} diff --git a/app/javascript/flavours/glitch/actions/interactions_typed.ts b/app/javascript/flavours/glitch/actions/interactions_typed.ts index 1679c0551e..26d8ce84d0 100644 --- a/app/javascript/flavours/glitch/actions/interactions_typed.ts +++ b/app/javascript/flavours/glitch/actions/interactions_typed.ts @@ -1,13 +1,279 @@ +import { defineMessages } from 'react-intl'; + import { apiReblog, apiUnreblog, apiRevokeQuote, apiGetQuotes, -} from 'flavours/glitch/api/interactions'; -import type { StatusVisibility } from 'flavours/glitch/models/status'; -import { createDataLoadingThunk } from 'flavours/glitch/store/typed_functions'; +} from '@/flavours/glitch/api/interactions'; +import type { StatusContextType } from '@/flavours/glitch/components/status/types'; +import type { VisibilityModalCallback } from '@/flavours/glitch/features/ui/components/visibility_modal'; +import type { + StatusShape, + StatusVisibility, +} from '@/flavours/glitch/models/status'; +import { + createAppThunk, + createDataLoadingThunk, +} from '@/flavours/glitch/store/typed_functions'; +import { deleteModal } from '../initial_state'; +import { selectStatusInteractions } from '../selectors/statuses'; + +import { showAlert, showGenericAlert } from './alerts'; +import { replyCompose } from './compose'; +import { quoteComposeById } from './compose_typed'; import { importFetchedStatus, importFetchedStatuses } from './importer'; +import { + bookmark, + favourite, + pin, + unbookmark, + unfavourite, + unpin, +} from './interactions'; +import { openModal } from './modal'; +import { + deleteStatus, + editStatus, + muteStatus, + setStatusQuotePolicy, + translateStatus, + undoStatusTranslation, + unmuteStatus, +} from './statuses'; + +export type StatusInteractionIntent = + | 'bookmark' + | 'delete' + | 'editQuotePolicy' + | 'edit' + | 'embed' + | 'favourite' + | 'filter' + | 'mute' + | 'pin' + | 'quote' + | 'reblog' + | 'redraft' + | 'reply' + | 'report' + | 'revokeQuote' + | 'translate'; + +const messages = defineMessages({ + noEdits: { + id: 'status.cannot_edit', + defaultMessage: 'You are not allowed to edit this post', + }, + privateStatus: { + id: 'status.public_only', + defaultMessage: 'This post is private', + }, + notQuoted: { + id: 'status.not_quoted', + defaultMessage: 'You are not quoted in this post', + }, +}); + +export const statusInteraction = createAppThunk( + ( + { + statusId, + contextType, + intent, + }: { + statusId?: string; + contextType?: StatusContextType; + intent: StatusInteractionIntent; + }, + { getState, dispatch }, + ) => { + if (!statusId) { + return; + } + + const state = getState(); + const statusImmutable = state.statuses.get(statusId); + if (!statusImmutable) { + dispatch(showGenericAlert()); + return; + } + const status = statusImmutable.toJS() as unknown as StatusShape; + + // Check the permissions and respond if it's not allowed. + const interactions = selectStatusInteractions(state, statusId); + const permissions = interactions[intent]; + if (!permissions.allowed) { + // Must strictly check for false, as values can be undefined. + if (permissions.isLoggedIn === false) { + dispatch( + openModal({ + modalType: 'INTERACTION', + modalProps: { + intent, + accountId: status.account, + url: status.uri, + }, + }), + ); + } else if (permissions.isMine === false) { + dispatch(showAlert({ message: messages.noEdits })); + } else if ( + permissions.isNotDirect === false || + permissions.isPublic === false + ) { + dispatch(showAlert({ message: messages.privateStatus })); + } else if (permissions.isQuoted === false) { + dispatch(showAlert({ message: messages.notQuoted })); + } + return; + } + + // Handle intents for all statuses. + switch (intent) { + case 'bookmark': + if (status.bookmarked) { + dispatch(unbookmark(statusImmutable)); + } else { + dispatch(bookmark(statusImmutable)); + } + return; + case 'delete': + if (!deleteModal) { + void dispatch(deleteStatus(statusId)); + } else { + dispatch( + openModal({ + modalType: 'CONFIRM_DELETE_STATUS', + modalProps: { statusId }, + }), + ); + } + return; + case 'edit': { + const composerText = state.compose.get('text'); + if (typeof composerText === 'string' && composerText.trim()) { + dispatch( + openModal({ + modalType: 'CONFIRM_EDIT_STATUS', + modalProps: { statusId }, + }), + ); + } else { + dispatch(editStatus(statusId)); + } + return; + } + case 'editQuotePolicy': + dispatch( + openModal({ + modalType: 'COMPOSE_PRIVACY', + modalProps: { + statusId, + onChange: ((_, policy) => { + void dispatch(setStatusQuotePolicy({ statusId, policy })); + }) satisfies VisibilityModalCallback, + }, + }), + ); + return; + case 'embed': + dispatch( + openModal({ + modalType: 'EMBED', + modalProps: { id: statusId }, + }), + ); + return; + case 'filter': + dispatch( + openModal({ + modalType: 'FILTER', + modalProps: { statusId, contextType }, + }), + ); + return; + case 'favourite': + if (status.favourited) { + dispatch(unfavourite(statusImmutable)); + } else { + dispatch(favourite(statusImmutable)); + } + return; + case 'mute': + if (status.muted) { + dispatch(unmuteStatus(statusId)); + } else { + dispatch(muteStatus(statusId)); + } + return; + case 'pin': + if (status.pinned) { + dispatch(unpin(statusImmutable)); + } else { + dispatch(pin(statusImmutable)); + } + return; + case 'quote': + dispatch(quoteComposeById(statusId)); + return; + case 'reblog': + if (status.reblogged) { + void dispatch(unreblog({ statusId })); + } else { + void dispatch(reblog({ statusId, visibility: status.visibility })); + } + return; + case 'redraft': + if (!deleteModal) { + void dispatch(deleteStatus(statusId, true)); + } else { + dispatch( + openModal({ + modalType: 'CONFIRM_DELETE_STATUS', + modalProps: { + statusId, + withRedraft: true, + }, + }), + ); + } + return; + case 'reply': + dispatch(replyCompose(statusImmutable)); + return; + case 'report': + dispatch( + openModal({ + modalType: 'REPORT', + modalProps: { + accountId: status.account, + statusId: statusId, + }, + }), + ); + return; + case 'revokeQuote': + dispatch( + openModal({ + modalType: 'CONFIRM_REVOKE_QUOTE', + modalProps: { + statusId: statusId, + quotedStatusId: status.quote?.quoted_status, + }, + }), + ); + return; + case 'translate': + if (status.translation) { + dispatch(undoStatusTranslation(statusId, status.poll)); + } else { + dispatch(translateStatus(statusId)); + } + } + }, +); export const reblog = createDataLoadingThunk( 'status/reblog', diff --git a/app/javascript/flavours/glitch/actions/picture_in_picture.ts b/app/javascript/flavours/glitch/actions/picture_in_picture.ts index 9ad88ae29b..0f70534842 100644 --- a/app/javascript/flavours/glitch/actions/picture_in_picture.ts +++ b/app/javascript/flavours/glitch/actions/picture_in_picture.ts @@ -29,3 +29,8 @@ export const deployPictureInPicture = createAppAsyncThunk( } }, ); + +export type DeployPictureInPictureCallback = ( + type: 'audio' | 'video', + props: PIPMediaProps, +) => void; diff --git a/app/javascript/flavours/glitch/actions/streaming.js b/app/javascript/flavours/glitch/actions/streaming.js index f4bd0ff373..22dc963fff 100644 --- a/app/javascript/flavours/glitch/actions/streaming.js +++ b/app/javascript/flavours/glitch/actions/streaming.js @@ -36,7 +36,7 @@ const randomUpTo = max => * @typedef {import('flavours/glitch/store').AppDispatch} Dispatch * @typedef {import('flavours/glitch/store').GetState} GetState * @typedef {import('redux').UnknownAction} UnknownAction - * @typedef {function(Dispatch, GetState): Promise} FallbackFunction + * @typedef {(dispatch: Dispatch, getState: GetState) => Promise} FallbackFunction */ /** @@ -45,9 +45,9 @@ const randomUpTo = max => * @param {Object.} params * @param {Object} options * @param {FallbackFunction} [options.fallback] - * @param {function(): UnknownAction} [options.fillGaps] - * @param {function(object): boolean} [options.accept] - * @returns {function(): void} + * @param {() => UnknownAction} [options.fillGaps] + * @param {(status: object) => boolean} [options.accept] + * @returns {() => void} */ export const connectTimelineStream = (timelineId, channelName, params = {}, options = {}) => { const { messages } = getLocale(); @@ -159,7 +159,7 @@ async function refreshHomeTimelineAndNotification(dispatch) { } /** - * @returns {function(): void} + * @returns {() => void} */ export const connectUserStream = () => connectTimelineStream('home', 'user', {}, { @@ -171,7 +171,7 @@ export const connectUserStream = () => /** * @param {Object} options * @param {boolean} [options.onlyMedia] - * @returns {function(): void} + * @returns {() => void} */ export const connectCommunityStream = ({ onlyMedia } = {}) => connectTimelineStream(`community${onlyMedia ? ':media' : ''}`, `public:local${onlyMedia ? ':media' : ''}`, {}, { @@ -184,7 +184,7 @@ export const connectCommunityStream = ({ onlyMedia } = {}) => * @param {boolean} [options.onlyMedia] * @param {boolean} [options.onlyRemote] * @param {boolean} [options.allowLocalOnly] - * @returns {function(): void} + * @returns {() => void} */ export const connectPublicStream = ({ onlyMedia, onlyRemote, allowLocalOnly } = {}) => connectTimelineStream(`public${onlyRemote ? ':remote' : (allowLocalOnly ? ':allow_local_only' : '')}${onlyMedia ? ':media' : ''}`, `public${onlyRemote ? ':remote' : (allowLocalOnly ? ':allow_local_only' : '')}${onlyMedia ? ':media' : ''}`, {}, { @@ -196,21 +196,21 @@ export const connectPublicStream = ({ onlyMedia, onlyRemote, allowLocalOnly } = * @param {string} columnId * @param {string} tagName * @param {boolean} onlyLocal - * @param {function(object): boolean} accept - * @returns {function(): void} + * @param {(status: object) => boolean} accept + * @returns {() => void} */ export const connectHashtagStream = (columnId, tagName, onlyLocal, accept) => connectTimelineStream(`hashtag:${columnId}${onlyLocal ? ':local' : ''}`, `hashtag${onlyLocal ? ':local' : ''}`, { tag: tagName }, { accept }); /** - * @returns {function(): void} + * @returns {() => void} */ export const connectDirectStream = () => connectTimelineStream('direct', 'direct'); /** * @param {string} listId - * @returns {function(): void} + * @returns {() => void} */ export const connectListStream = listId => connectTimelineStream(`list:${listId}`, 'list', { list: listId }, { diff --git a/app/javascript/flavours/glitch/actions/timelines_typed.ts b/app/javascript/flavours/glitch/actions/timelines_typed.ts index a13522c60c..4219f7d348 100644 --- a/app/javascript/flavours/glitch/actions/timelines_typed.ts +++ b/app/javascript/flavours/glitch/actions/timelines_typed.ts @@ -3,6 +3,7 @@ import type { List as ImmutableList, Map as ImmutableMap } from 'immutable'; import { usePendingItems as preferPendingItems } from 'flavours/glitch/initial_state'; +import type { ApiStatusJSON } from '../api_types/statuses'; import type { Status } from '../models/status'; import { createAppThunk } from '../store/typed_functions'; @@ -10,6 +11,7 @@ import { expandTimeline, insertIntoTimeline, TIMELINE_NON_STATUS_MARKERS, + updateTimeline, } from './timelines'; export const expandTimelineByKey = createAppThunk( @@ -208,6 +210,34 @@ export const timelineDeleteStatus = createAction<{ timelineKey: string; }>('timelines/deleteStatus'); +export const insertStatusIntoAccountTimelines = createAppThunk( + (status: ApiStatusJSON, { dispatch, getState }) => { + const currentAccountId = getState().meta.get('me', null) as string | null; + if (!currentAccountId) { + return; + } + + const tags = status.tags.map((tag) => tag.name); + + const timelines = getState().timelines as ImmutableMap; + const accountTimelines = timelines.filter((_, key) => { + if (!key.startsWith(`account:${currentAccountId}:`)) { + return false; + } + const parsed = parseTimelineKey(key); + if (parsed?.type !== 'account' || parsed.pinned) { + return false; + } + + return !parsed.tagged || tags.includes(parsed.tagged); + }); + + accountTimelines.forEach((_, timelineKey) => { + dispatch(updateTimeline(timelineKey, status)); + }); + }, +); + export const insertPinnedStatusIntoTimelines = createAppThunk( (status: Status, { dispatch, getState }) => { const currentAccountId = getState().meta.get('me', null) as string | null; diff --git a/app/javascript/flavours/glitch/api_types/accounts.ts b/app/javascript/flavours/glitch/api_types/accounts.ts index 85ee62ad07..1e4bb8a0ae 100644 --- a/app/javascript/flavours/glitch/api_types/accounts.ts +++ b/app/javascript/flavours/glitch/api_types/accounts.ts @@ -60,7 +60,7 @@ export interface BaseApiAccountJSON { show_featured: boolean; noindex?: boolean; note: string; - roles?: ApiAccountJSON[]; + roles?: ApiAccountRoleJSON[]; statuses_count: number; uri: string; url?: string; @@ -71,6 +71,7 @@ export interface BaseApiAccountJSON { memorial?: boolean; hide_collections: boolean; email_subscriptions?: boolean; + invalid_handle?: boolean; } // See app/serializers/rest/muted_account_serializer.rb diff --git a/app/javascript/flavours/glitch/api_types/media_attachments.ts b/app/javascript/flavours/glitch/api_types/media_attachments.ts index fc027ccd2a..8cb798f760 100644 --- a/app/javascript/flavours/glitch/api_types/media_attachments.ts +++ b/app/javascript/flavours/glitch/api_types/media_attachments.ts @@ -7,16 +7,89 @@ export type MediaAttachmentType = | 'unknown' | 'audio'; -export interface ApiMediaAttachmentJSON { +export interface BaseApiMediaAttachmentJSON { id: string; type: MediaAttachmentType; url: string; preview_url: string; - remoteUrl: string; - preview_remote_url: string; - text_url: string; - // TODO: how to define this? - meta: unknown; + remote_url?: string; + preview_remote_url?: string; + text_url?: string; description?: string; blurhash: string; } + +export interface ApiImageAttachmentJSON extends BaseApiMediaAttachmentJSON { + type: 'image'; + meta: { + original: ApiImageAttachmentMetaJSON; + small: ApiImageAttachmentMetaJSON; + focus?: ApiFocusAttachmentMetaJSON; + }; +} + +export interface ApiAudioAttachmentJSON extends BaseApiMediaAttachmentJSON { + type: 'audio'; + meta: { + colors: ApiColorsAttachmentMetaJSON; + original: ApiVideoAttachmentMetaJSON; + small: ApiImageAttachmentMetaJSON; + }; +} + +export interface ApiVideoAttachmentJSON extends BaseApiMediaAttachmentJSON { + type: 'video'; + meta: { + colors: ApiColorsAttachmentMetaJSON; + original: ApiVideoAttachmentMetaJSON; + small: ApiImageAttachmentMetaJSON; + focus?: ApiFocusAttachmentMetaJSON; + }; +} + +export interface ApiGifvAttachmentJSON extends BaseApiMediaAttachmentJSON { + type: 'gifv'; + meta: { + original: ApiVideoAttachmentMetaJSON; + small: ApiImageAttachmentMetaJSON; + focus?: ApiFocusAttachmentMetaJSON; + }; +} + +export interface ApiUnknownAttachmentJSON extends BaseApiMediaAttachmentJSON { + type: 'unknown'; + meta: unknown; +} + +export type ApiMediaAttachmentJSON = + | ApiImageAttachmentJSON + | ApiAudioAttachmentJSON + | ApiVideoAttachmentJSON + | ApiGifvAttachmentJSON + | ApiUnknownAttachmentJSON; + +export interface ApiImageAttachmentMetaJSON { + width: number; + height: number; + size: string; + aspect: number; +} + +export interface ApiVideoAttachmentMetaJSON { + width: number; + height: number; + frame_rate: string; + duration: number; + bitrate: number; +} + +export interface ApiColorsAttachmentMetaJSON { + background: string; + foreground: string; + accent: string; +} + +export interface ApiFocusAttachmentMetaJSON { + x: number; + y: number; +} diff --git a/app/javascript/flavours/glitch/api_types/quotes.ts b/app/javascript/flavours/glitch/api_types/quotes.ts index f42a3eb728..de69394b98 100644 --- a/app/javascript/flavours/glitch/api_types/quotes.ts +++ b/app/javascript/flavours/glitch/api_types/quotes.ts @@ -19,11 +19,13 @@ interface ApiNestedQuoteJSON { quoted_status_id: string; } +export type ApiQuotedStatusJSON = Omit & { + quote?: ApiNestedQuoteJSON | ApiQuoteEmptyJSON; +}; + interface ApiQuoteAcceptedJSON { state: 'accepted'; - quoted_status: Omit & { - quote: ApiNestedQuoteJSON | ApiQuoteEmptyJSON; - }; + quoted_status: ApiQuotedStatusJSON; } export type ApiQuoteJSON = ApiQuoteAcceptedJSON | ApiQuoteEmptyJSON; diff --git a/app/javascript/flavours/glitch/api_types/statuses.ts b/app/javascript/flavours/glitch/api_types/statuses.ts index 157be8441d..acf192c12d 100644 --- a/app/javascript/flavours/glitch/api_types/statuses.ts +++ b/app/javascript/flavours/glitch/api_types/statuses.ts @@ -1,6 +1,7 @@ // See app/serializers/rest/status_serializer.rb import type { ApiAccountJSON } from './accounts'; +import type { ApiCollectionJSON } from './collections'; import type { ApiCustomEmojiJSON } from './custom_emoji'; import type { ApiMediaAttachmentJSON } from './media_attachments'; import type { ApiPollJSON } from './polls'; @@ -94,11 +95,11 @@ export interface ApiStatusJSON { url: string; replies_count: number; reblogs_count: number; - favorites_count: number; + favourites_count: number; quotes_count: number; edited_at?: string; - favorited?: boolean; + favourited?: boolean; reblogged?: boolean; muted?: boolean; bookmarked?: boolean; @@ -116,6 +117,7 @@ export interface ApiStatusJSON { tags: ApiTagJSON[]; emojis: ApiCustomEmojiJSON[]; + tagged_collections: ApiCollectionJSON[]; card?: ApiPreviewCardJSON; poll?: ApiPollJSON; @@ -138,6 +140,19 @@ export interface ApiStatusSourceJSON { spoiler_text: string; } +export interface ApiStatusTranslationJSON { + detected_source_language: string; + language: string; + provider: string; + contentHtml: string; + spoilerHtml: string; + spoiler_text: string; + poll?: { + id: string; + options: { title: string }[]; + }; +} + export function isStatusVisibility( visibility: string, ): visibility is StatusVisibility { diff --git a/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx b/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx index b7225fc92e..f32bbf27e9 100644 --- a/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx +++ b/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx @@ -1,6 +1,5 @@ -import { fromJS } from 'immutable'; +import { mediaAttachmentFactoryAPI } from '@/testing/factories'; -import type { StatusLike } from '../hashtag_bar'; import { computeHashtagBarForStatus } from '../hashtag_bar'; function createStatus( @@ -9,25 +8,27 @@ function createStatus( hasMedia = false, spoilerText?: string, ) { - return fromJS({ - tags: hashtags.map((name) => ({ name })), + return { + tags: hashtags.map((name) => ({ + name, + url: `https://example.com/tag/${name}`, + })), contentHtml: content, - media_attachments: hasMedia ? ['fakeMedia'] : [], + media_attachments: hasMedia + ? [{ ...mediaAttachmentFactoryAPI(), remote_url: null }] + : [], spoiler_text: spoilerText, - }) as unknown as StatusLike; // need to force the type here, as it is not properly defined + }; } describe('computeHashtagBarForStatus', () => { it('does nothing when there are no tags', () => { const status = createStatus('

Simple text

', []); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( - `"

Simple text

"`, - ); + expect(statusContent).toMatchInlineSnapshot(`"

Simple text

"`); }); it('displays out of band hashtags in the bar', () => { @@ -36,11 +37,10 @@ describe('computeHashtagBarForStatus', () => { ['hashtag', 'test'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual(['test']); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"

Simple text #hashtag

"`, ); }); @@ -51,11 +51,10 @@ describe('computeHashtagBarForStatus', () => { ['test'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"this is a #test. Some more text"`, ); }); @@ -66,13 +65,10 @@ describe('computeHashtagBarForStatus', () => { ['hashtag'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual(['hashtag']); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( - `"

Simple text

"`, - ); + expect(statusContent).toMatchInlineSnapshot(`"

Simple text

"`); }); it('does not include tags from content', () => { @@ -81,11 +77,10 @@ describe('computeHashtagBarForStatus', () => { ['hashtag'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"

Simple text with a #hashtag

"`, ); }); @@ -96,11 +91,10 @@ describe('computeHashtagBarForStatus', () => { ['hashtag', 'test'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"

#test. And another #hashtag

"`, ); }); @@ -111,13 +105,10 @@ describe('computeHashtagBarForStatus', () => { ['éaa'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual(['Éaa']); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( - `"

Text

"`, - ); + expect(statusContent).toMatchInlineSnapshot(`"

Text

"`); }); it('handles server-side normalized tags with accentuated characters', () => { @@ -126,13 +117,10 @@ describe('computeHashtagBarForStatus', () => { ['eaa'], // The server may normalize the hashtags in the `tags` attribute ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual(['Éaa']); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( - `"

Text

"`, - ); + expect(statusContent).toMatchInlineSnapshot(`"

Text

"`); }); it('does not display in bar a hashtag in content with a case difference', () => { @@ -141,11 +129,10 @@ describe('computeHashtagBarForStatus', () => { ['éaa'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"

Text #Éaa

"`, ); }); @@ -156,11 +143,10 @@ describe('computeHashtagBarForStatus', () => { ['test', 'hashtag'], ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"

#test #hashtag

"`, ); }); @@ -172,11 +158,10 @@ describe('computeHashtagBarForStatus', () => { true, ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"

This is my content! #hashtag

"`, ); }); @@ -188,11 +173,10 @@ describe('computeHashtagBarForStatus', () => { true, ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual(['test', 'hashtag']); - expect(statusContentProps.statusContent).toMatchInlineSnapshot(`""`); + expect(statusContent).toMatchInlineSnapshot(`""`); }); it('does not use the hashtag bar if the status content is only hashtags, has a CW and a media', () => { @@ -203,11 +187,10 @@ describe('computeHashtagBarForStatus', () => { 'My CW text', ); - const { hashtagsInBar, statusContentProps } = - computeHashtagBarForStatus(status); + const { hashtagsInBar, statusContent } = computeHashtagBarForStatus(status); expect(hashtagsInBar).toEqual([]); - expect(statusContentProps.statusContent).toMatchInlineSnapshot( + expect(statusContent).toMatchInlineSnapshot( `"

#test #hashtag

"`, ); }); diff --git a/app/javascript/flavours/glitch/components/_theme_playground/index.tsx b/app/javascript/flavours/glitch/components/_theme_playground/index.tsx new file mode 100644 index 0000000000..cb3697764a --- /dev/null +++ b/app/javascript/flavours/glitch/components/_theme_playground/index.tsx @@ -0,0 +1,67 @@ +/* eslint-disable jsx-a11y/anchor-is-valid */ + +import type { MouseEvent } from 'react'; +import { useCallback, useState } from 'react'; + +import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react'; + +import { Icon } from '../icon'; + +import classes from './theme_playground.module.scss'; + +/** + * This component is a temporary testing ground for new theme tokens. + * It's not to be used in-app. + */ +export const ThemePlayground: React.FC = () => { + const [activeLink, setActiveLink] = useState('Saved'); + + const handleLinkClick = useCallback((e: MouseEvent) => { + e.preventDefault(); + setActiveLink(e.currentTarget.innerText); + }, []); + + return ( +
+ +
+

Home

+

Test 1 2 3

+

+ This is a bold statement! +

+
+
Hello World
+
+ ); +}; diff --git a/app/javascript/flavours/glitch/components/_theme_playground/theme_playground.module.scss b/app/javascript/flavours/glitch/components/_theme_playground/theme_playground.module.scss new file mode 100644 index 0000000000..4329ede4f4 --- /dev/null +++ b/app/javascript/flavours/glitch/components/_theme_playground/theme_playground.module.scss @@ -0,0 +1,132 @@ +@use '@/styles/mastodon/mixins'; + +.wrapper { + position: relative; + display: grid; + grid-template-columns: 250px 1fr; + gap: var(--space-md); + padding: var(--space-3xl); + font-family: Inter, sans-serif; + font-size: var(--fs-lg); + line-height: var(--lh-normal); + overflow-wrap: break-word; + color: var(--color-text-primary); + background-color: var(--color-bg-blend); + + h1 { + @include mixins.type-heading-lg; + } + + p { + @include mixins.type-body; + } + + strong { + font-weight: bold; + } + + * { + min-width: 0; + } + + nav { + display: block; + grid-template-rows: min-content; + font-size: var(--fs-sm); + + input { + display: block; + box-sizing: border-box; + width: 100%; + margin-block-end: var(--space-md); + padding: var(--space-xs) var(--space-md); + color: var(--color-text-primary); + background: transparent; + border: 1px solid var(--color-border-primary); + border-radius: var(--radius-xs); + font: inherit; + + &:focus { + border-color: var(--color-border-brand); + outline: 1px solid var(--color-border-brand); + } + } + + a { + display: block; + padding: var(--space-xs) var(--space-md); + border-radius: var(--radius-xs); + color: var(--color-text-secondary); + @include mixins.type-body-compact; + + &[aria-current='page'] { + color: var(--color-text-primary); + background-color: var(--color-bg-highlight); + } + } + + aside { + display: grid; + grid-template-areas: + 'title button' + 'subtitle button'; + grid-template-columns: 1fr min-content; + align-items: center; + gap: var(--space-3xs) var(--space-xs); + margin-block-start: var(--space-md); + padding: var(--space-sm) var(--space-md); + border-radius: var(--radius-md); + border: 1px solid var(--color-border-primary); + + h2 { + grid-area: title; + @include mixins.type-body; + + line-height: var(--lh-tighter); + } + + .subtitle { + grid-area: subtitle; + @include mixins.type-label-sm; + + color: var(--color-text-secondary); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .menuButton { + grid-area: button; + display: grid; + place-items: center; + width: 32px; + height: 32px; + border: none; + background-color: transparent; + border-radius: var(--radius-round); + + &:hover { + background-color: var(--color-bg-highlight); + } + } + } + } + + main { + padding: var(--space-3xl); + background-color: var(--color-bg-primary); + border-radius: var(--radius-md); + } + + .overlay { + position: absolute; + inset: auto var(--space-md) var(--space-md) auto; + width: 30%; + height: 35%; + padding: var(--space-md); + background-color: var(--color-bg-primary); + border-radius: var(--radius-xl); + + @include mixins.elevation-2; + } +} diff --git a/app/javascript/flavours/glitch/components/_theme_playground/theme_playground.stories.tsx b/app/javascript/flavours/glitch/components/_theme_playground/theme_playground.stories.tsx new file mode 100644 index 0000000000..ecdf61bd94 --- /dev/null +++ b/app/javascript/flavours/glitch/components/_theme_playground/theme_playground.stories.tsx @@ -0,0 +1,18 @@ +import type { Meta, StoryObj } from '@storybook/react-vite'; + +import { ThemePlayground } from './index'; + +const meta = { + title: 'Components/ThemePlayground', + component: ThemePlayground, + parameters: { + layout: 'fullscreen', + redesign: true, + }, +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/app/javascript/flavours/glitch/components/account_header/buttons.tsx b/app/javascript/flavours/glitch/components/account_header/buttons.tsx index 77003e71e3..9e342943c4 100644 --- a/app/javascript/flavours/glitch/components/account_header/buttons.tsx +++ b/app/javascript/flavours/glitch/components/account_header/buttons.tsx @@ -69,6 +69,7 @@ const AccountButtonsOther: FC< const dispatch = useAppDispatch(); const handleNotifyToggle = useCallback(() => { if (account) { + // @ts-expect-error this action is not typed yet dispatch(followAccount(account.id, { notify: !relationship?.notifying })); } }, [dispatch, account, relationship]); diff --git a/app/javascript/flavours/glitch/components/account_header/fields.tsx b/app/javascript/flavours/glitch/components/account_header/fields.tsx index ab441ba71c..22aba72670 100644 --- a/app/javascript/flavours/glitch/components/account_header/fields.tsx +++ b/app/javascript/flavours/glitch/components/account_header/fields.tsx @@ -220,7 +220,7 @@ const FieldHTML: FC = ({ }; function useColumnWrap() { - const listRef = useRef(null); + const listRef = useRef(null); const handleRecalculate = useCallback(() => { const listEle = listRef.current; @@ -330,7 +330,7 @@ function useFieldOverflow() { const [isLabelOverflowing, setIsLabelOverflowing] = useState(false); const [isValueOverflowing, setIsValueOverflowing] = useState(false); - const wrapperRef = useRef(null); + const wrapperRef = useRef(null); const handleRecalculate = useCallback(() => { const wrapperEle = wrapperRef.current; diff --git a/app/javascript/flavours/glitch/components/account_header/menu.tsx b/app/javascript/flavours/glitch/components/account_header/menu.tsx index 4f113527ee..ef771ebdba 100644 --- a/app/javascript/flavours/glitch/components/account_header/menu.tsx +++ b/app/javascript/flavours/glitch/components/account_header/menu.tsx @@ -229,6 +229,10 @@ const redesignMessages = defineMessages({ id: 'account.menu.open_original_page', defaultMessage: 'View on {domain}', }, + openOriginalPageInvalid: { + id: 'account.menu.open_original_page_no_domain', + defaultMessage: 'View on original server', + }, removeFollower: { id: 'account.menu.remove_follower', defaultMessage: 'Remove follower', @@ -273,32 +277,37 @@ function getMenuItems({ // Open on remote page. if (isRemote) { items.push({ - text: intl.formatMessage(redesignMessages.openOriginalPage, { - domain: remoteDomain, - }), + text: account.invalid_handle + ? intl.formatMessage(redesignMessages.openOriginalPageInvalid) + : intl.formatMessage(redesignMessages.openOriginalPage, { + domain: remoteDomain, + }), href: account.url, }); } // Mention and direct message options if (signedIn && !account.suspended) { - items.push( - null, - { - text: intl.formatMessage(redesignMessages.mention), - action: () => { - dispatch(mentionCompose(account)); + if (account.invalid_handle) items.push(null); + else { + items.push( + null, + { + text: intl.formatMessage(redesignMessages.mention), + action: () => { + dispatch(mentionCompose(account)); + }, }, - }, - { - text: intl.formatMessage(redesignMessages.direct), - action: () => { - dispatch(directCompose(account)); + { + text: intl.formatMessage(redesignMessages.direct), + action: () => { + dispatch(directCompose(account)); + }, }, - }, - null, - ); + null, + ); + } } if (!signedIn) { @@ -389,6 +398,7 @@ function getMenuItems({ ), action: () => { dispatch( + // @ts-expect-error this action is not typed yet followAccount(account.id, { reblogs: !relationship.showing_reblogs, }), @@ -487,7 +497,7 @@ function getMenuItems({ }); } - if (remoteDomain) { + if (remoteDomain && !account.invalid_handle) { items.push(null, { text: intl.formatMessage( relationship?.domain_blocking @@ -527,6 +537,7 @@ function getMenuItems({ } if ( remoteDomain && + !account.invalid_handle && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION ) { diff --git a/app/javascript/flavours/glitch/components/account_header/name.tsx b/app/javascript/flavours/glitch/components/account_header/name.tsx index aca296c311..42aa1c16bb 100644 --- a/app/javascript/flavours/glitch/components/account_header/name.tsx +++ b/app/javascript/flavours/glitch/components/account_header/name.tsx @@ -1,12 +1,10 @@ -import { useCallback, useId, useRef, useState } from 'react'; +import { useCallback, useId, useState } from 'react'; import type { FC } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import classNames from 'classnames'; -import Overlay from 'react-overlays/esm/Overlay'; - import { useAccount } from '@/flavours/glitch/hooks/useAccount'; import { useRelationship } from '@/flavours/glitch/hooks/useRelationship'; import { useAppSelector } from '@/flavours/glitch/store'; @@ -20,6 +18,7 @@ import { CopyButton } from '../copy_button'; import { DisplayName } from '../display_name'; import { Icon } from '../icon'; import { NavigationFocusTarget } from '../navigation_focus_target'; +import { Popover } from '../popover'; import { AccountBadges } from './badges'; import classes from './styles.module.scss'; @@ -63,17 +62,84 @@ export const AccountName: FC<{ accountId: string }> = ({ accountId }) => { {relationship?.followed_by && } - + {account.invalid_handle ? ( + + ) : ( + + )} ); }; +const InvalidAccountHelp: FC = () => { + const accessibilityId = useId(); + const intl = useIntl(); + const [open, setOpen] = useState(false); + const [triggerElement, setTriggerElement] = + useState(null); + + const handleClick = useCallback(() => { + setOpen((prev) => !prev); + }, []); + + return ( + <> + + + + {({ props }) => ( +
+ + +
+ )} +
+ + ); +}; + const AccountNameHelp: FC<{ username: string; domain: string; @@ -82,7 +148,8 @@ const AccountNameHelp: FC<{ const accessibilityId = useId(); const intl = useIntl(); const [open, setOpen] = useState(false); - const triggerRef = useRef(null); + const [triggerElement, setTriggerElement] = + useState(null); const handleClick = useCallback(() => { setOpen((prev) => !prev); @@ -94,7 +161,7 @@ const AccountNameHelp: FC<{ <> - {({ props }) => (
)} -
+ ); }; diff --git a/app/javascript/flavours/glitch/components/account_header/styles.module.scss b/app/javascript/flavours/glitch/components/account_header/styles.module.scss index 56d57bc81c..71062bfa8e 100644 --- a/app/javascript/flavours/glitch/components/account_header/styles.module.scss +++ b/app/javascript/flavours/glitch/components/account_header/styles.module.scss @@ -142,7 +142,8 @@ font-weight: 600; } - > ol { + > ol, + > p { margin: 12px 0; } diff --git a/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx b/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx index 1f27d8a3d1..04ada5d0f4 100644 --- a/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx +++ b/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx @@ -90,7 +90,7 @@ export const AccountSubscriptionForm: React.FC<{ accountId: string }> = ({ [], ); - const handleSubmit = useCallback( + const handleSubmit = useCallback( (e) => { e.preventDefault(); diff --git a/app/javascript/flavours/glitch/components/account_list_item/account_list_item.stories.tsx b/app/javascript/flavours/glitch/components/account_list_item/account_list_item.stories.tsx index 62875b02f6..5b201b4cdf 100644 --- a/app/javascript/flavours/glitch/components/account_list_item/account_list_item.stories.tsx +++ b/app/javascript/flavours/glitch/components/account_list_item/account_list_item.stories.tsx @@ -1,6 +1,9 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; -import { accountFactoryState, relationshipsFactory } from '@/testing/factories'; +import { + accountFactoryImmutable, + relationshipsFactoryAPI, +} from '@/testing/factories'; import { PendingBadge } from '../badge'; @@ -16,7 +19,7 @@ const meta = { parameters: { state: { accounts: { - '1': accountFactoryState(), + '1': accountFactoryImmutable(), }, }, }, @@ -32,7 +35,7 @@ export const FollowsYou: Story = { parameters: { state: { relationships: { - '1': relationshipsFactory({ + '1': relationshipsFactoryAPI({ followed_by: true, }), }, diff --git a/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx b/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx index a6f55af770..ed9ea10b62 100644 --- a/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx +++ b/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx @@ -4,22 +4,14 @@ import { FormattedMessage, useIntl } from 'react-intl'; import classNames from 'classnames'; -import type { - OffsetValue, - UsePopperOptions, -} from 'react-overlays/esm/usePopper'; -import Overlay from 'react-overlays/Overlay'; - import CloseIcon from '@/material-icons/400-24px/close.svg?react'; import { useSelectableClick } from 'flavours/glitch/hooks/useSelectableClick'; import { IconButton } from '../icon_button'; +import { Popover } from '../popover'; import classes from './styles.module.scss'; -const offset = [0, 4] as OffsetValue; -const popperConfig = { strategy: 'fixed' } as UsePopperOptions; - export const AltTextBadge: React.FC<{ description: string; className?: string; @@ -28,7 +20,9 @@ export const AltTextBadge: React.FC<{ const uniqueId = useId(); const popoverId = `${uniqueId}-popover`; const titleId = `${uniqueId}-title`; - const buttonRef = useRef(null); + const [buttonElement, setButtonElement] = useState( + null, + ); const popoverRef = useRef(null); const [open, setOpen] = useState(false); @@ -41,8 +35,8 @@ export const AltTextBadge: React.FC<{ const handleClose = useCallback(() => { setOpen(false); - buttonRef.current?.focus(); - }, [setOpen]); + buttonElement?.focus(); + }, [buttonElement]); const [handleMouseDown, handleMouseUp] = useSelectableClick(handleClose); @@ -50,7 +44,7 @@ export const AltTextBadge: React.FC<{ <>