From 2a923aded81588387a7155966505be64bf2a65aa Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 7 Sep 2026 09:29:42 +0000 Subject: [PATCH 1/9] Fix notifications not being cleaned up when notification requests are deleted in bulk (#40393) --- .../api/v1/notifications/requests_controller.rb | 1 + .../filtered_notification_cleanup_worker.rb | 4 ++-- .../api/v1/notifications/requests_spec.rb | 4 +++- .../filtered_notification_cleanup_worker_spec.rb | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/notifications/requests_controller.rb b/app/controllers/api/v1/notifications/requests_controller.rb index 3c90f13ce2..6642725393 100644 --- a/app/controllers/api/v1/notifications/requests_controller.rb +++ b/app/controllers/api/v1/notifications/requests_controller.rb @@ -45,6 +45,7 @@ class Api::V1::Notifications::RequestsController < Api::BaseController end def dismiss_bulk + FilteredNotificationCleanupWorker.perform_async(current_account.id, @requests.map(&:from_account_id)) @requests.each(&:destroy!) render_empty end diff --git a/app/workers/filtered_notification_cleanup_worker.rb b/app/workers/filtered_notification_cleanup_worker.rb index 87ff6a9eb5..d4107bbfda 100644 --- a/app/workers/filtered_notification_cleanup_worker.rb +++ b/app/workers/filtered_notification_cleanup_worker.rb @@ -3,7 +3,7 @@ class FilteredNotificationCleanupWorker include Sidekiq::Worker - def perform(account_id, from_account_id) - Notification.where(account_id: account_id, from_account_id: from_account_id, filtered: true).in_batches(order: :desc).delete_all + def perform(account_id, from_account_ids) + Notification.where(account_id: account_id, from_account_id: from_account_ids, filtered: true).in_batches(order: :desc).delete_all end end diff --git a/spec/requests/api/v1/notifications/requests_spec.rb b/spec/requests/api/v1/notifications/requests_spec.rb index bee9d3a3da..596f910fe9 100644 --- a/spec/requests/api/v1/notifications/requests_spec.rb +++ b/spec/requests/api/v1/notifications/requests_spec.rb @@ -122,7 +122,9 @@ RSpec.describe 'Requests' do it_behaves_like 'forbidden for wrong scope', 'read read:notifications' it 'returns http success and destroys the notification request', :aggregate_failures do - expect { subject }.to change(NotificationRequest, :count).by(-1) + expect { subject } + .to change(NotificationRequest, :count).by(-1) + .and enqueue_sidekiq_job(FilteredNotificationCleanupWorker).with(user.account_id, be_a(Array)) expect(response).to have_http_status(200) expect(response.content_type) diff --git a/spec/workers/filtered_notification_cleanup_worker_spec.rb b/spec/workers/filtered_notification_cleanup_worker_spec.rb index 5ecd4291af..4e839c2682 100644 --- a/spec/workers/filtered_notification_cleanup_worker_spec.rb +++ b/spec/workers/filtered_notification_cleanup_worker_spec.rb @@ -20,5 +20,20 @@ RSpec.describe FilteredNotificationCleanupWorker do .to change { recipient.notifications.where(from_account: sender).count }.from(2).to(0) .and(not_change { recipient.notifications.where(from_account: bystander).count }) end + + context 'when given an array of IDs as parameter' do + let(:other_sender) { Fabricate(:account) } + + before do + Fabricate(:notification, account: recipient, activity: Fabricate(:favourite, account: other_sender), filtered: true) + end + + it 'deletes all filtered notifications to the account' do + expect { described_class.new.perform(recipient.id, [sender.id, other_sender.id]) } + .to change { recipient.notifications.where(from_account: sender).count }.from(2).to(0) + .and change { recipient.notifications.where(from_account: other_sender).count }.from(1).to(0) + .and(not_change { recipient.notifications.where(from_account: bystander).count }) + end + end end end From 82edaee8fcfe35684c7f7e210b0b5ea6d59488d5 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 7 Sep 2026 09:51:46 +0000 Subject: [PATCH 2/9] Fix account deletion not deleting generated annual reports (#40394) --- app/models/concerns/account/associations.rb | 1 + app/services/delete_account_service.rb | 2 ++ spec/services/delete_account_service_spec.rb | 2 ++ 3 files changed, 5 insertions(+) diff --git a/app/models/concerns/account/associations.rb b/app/models/concerns/account/associations.rb index 8c26a4da64..1a3d5f6845 100644 --- a/app/models/concerns/account/associations.rb +++ b/app/models/concerns/account/associations.rb @@ -40,6 +40,7 @@ module Account::Associations has_many :statuses has_many :keypairs has_many :email_subscriptions + has_many :generated_annual_reports has_one :deletion_request, class_name: 'AccountDeletionRequest' has_one :follow_recommendation_suppression diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb index cdd40fb871..c3d08390e2 100644 --- a/app/services/delete_account_service.rb +++ b/app/services/delete_account_service.rb @@ -28,6 +28,7 @@ class DeleteAccountService < BaseService scheduled_statuses status_pins tag_follows + generated_annual_reports ).freeze # The following associations have no important side-effects @@ -53,6 +54,7 @@ class DeleteAccountService < BaseService scheduled_statuses status_pins tag_follows + generated_annual_reports ).freeze ASSOCIATIONS_ON_DESTROY = %w( diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index f3eb0ca70f..291ae8035c 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -26,6 +26,7 @@ RSpec.describe DeleteAccountService do let!(:follow_notification) { Fabricate(:notification, account: local_follower, activity: active_relationship, type: :follow) } let!(:account_note) { Fabricate(:account_note, account: account) } + let!(:generated_annual_report) { Fabricate(:generated_annual_report, account: account) } it 'deletes associated owned and target records and target notifications' do subject @@ -48,6 +49,7 @@ RSpec.describe DeleteAccountService do expect { poll_vote.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { account_note.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { collection.reload }.to raise_error(ActiveRecord::RecordNotFound) + expect { generated_annual_report.reload }.to raise_error(ActiveRecord::RecordNotFound) end def expect_deletion_of_associated_target_records From 99d26cad3d10c2f1e6887d54e84c0a26f864c43b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 9 Sep 2026 06:31:07 +0000 Subject: [PATCH 3/9] Mark requested deletion time nil on accounts CLI reattach (#40430) --- lib/mastodon/cli/accounts.rb | 3 ++- spec/lib/mastodon/cli/accounts_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/mastodon/cli/accounts.rb b/lib/mastodon/cli/accounts.rb index 7f15a3686e..a34024df84 100644 --- a/lib/mastodon/cli/accounts.rb +++ b/lib/mastodon/cli/accounts.rb @@ -100,7 +100,8 @@ module Mastodon::CLI end account.suspended_at = nil - user.account = account + account.requested_deletion_at = nil + user.account = account if user.save if options[:confirmed] diff --git a/spec/lib/mastodon/cli/accounts_spec.rb b/spec/lib/mastodon/cli/accounts_spec.rb index a0e0ed501e..0e46878592 100644 --- a/spec/lib/mastodon/cli/accounts_spec.rb +++ b/spec/lib/mastodon/cli/accounts_spec.rb @@ -194,6 +194,20 @@ RSpec.describe Mastodon::CLI::Accounts do it_behaves_like 'a new user with given email address and username' end + + context "when account's user is not present and account was previously deleted" do + let(:options) { { email: 'tootctl@example.com', reattach: true } } + + before do + Fabricate(:account, username: 'tootctl_username', user: nil, requested_deletion_at: 10.days.ago) + end + + it 'removes requested deletion timestamp' do + expect { subject } + .to output_results('OK') + .and change { Account.find_local('tootctl_username').requested_deletion_at }.to(nil) + end + end end end From e7cf257228b103229e012014b2284950f8e35b02 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Sep 2026 07:04:18 +0000 Subject: [PATCH 4/9] Fix submitting a status twice leading to a 500 error (#40439) --- app/services/post_status_service.rb | 16 +++++++++++++--- spec/services/post_status_service_spec.rb | 8 ++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 788f79535e..239270f6e0 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -20,6 +20,15 @@ class PostStatusService < BaseService end end + class IdempotencyError < StandardError + attr_reader :status + + def initialize(status) + super() + @status = status + end + end + # Post a text status update, fetch and notify remote users mentioned # @param [Account] account Account from which to post # @param [Hash] options @@ -46,9 +55,10 @@ class PostStatusService < BaseService @in_reply_to = @options[:thread] @quoted_status = @options[:quoted_status] + preprocess_attributes! + with_idempotency do validate_media! - preprocess_attributes! if scheduled? schedule_status! @@ -63,7 +73,7 @@ class PostStatusService < BaseService end @status - rescue Antispam::SilentlyDrop => e + rescue Antispam::SilentlyDrop, IdempotencyError => e e.status end @@ -237,7 +247,7 @@ class PostStatusService < BaseService return yield unless idempotency_given? with_redis_lock("idempotency:lock:status:#{@account.id}:#{@options[:idempotency]}") do - return idempotency_duplicate if idempotency_duplicate? + raise IdempotencyError, idempotency_duplicate if idempotency_duplicate? yield diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 66ef93f807..052dc456a5 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -57,8 +57,8 @@ RSpec.describe PostStatusService do it 'returns existing status when used twice with idempotency key' do account = Fabricate(:account) - status1 = subject.call(account, text: 'test', idempotency: 'meepmeep', scheduled_at: future) - status2 = subject.call(account, text: 'test', idempotency: 'meepmeep', scheduled_at: future) + status1 = described_class.new.call(account, text: 'test', idempotency: 'meepmeep', scheduled_at: future) + status2 = described_class.new.call(account, text: 'test', idempotency: 'meepmeep', scheduled_at: future) expect(status2.id).to eq status1.id end @@ -341,8 +341,8 @@ RSpec.describe PostStatusService do it 'returns existing status when used twice with idempotency key' do account = Fabricate(:account) - status1 = subject.call(account, text: 'test', idempotency: 'meepmeep') - status2 = subject.call(account, text: 'test', idempotency: 'meepmeep') + status1 = described_class.new.call(account, text: 'test', idempotency: 'meepmeep') + status2 = described_class.new.call(account, text: 'test', idempotency: 'meepmeep') expect(status2.id).to eq status1.id end From 59e2ef27f812d278aed11a3347a0a927473db5ab Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Sep 2026 12:14:18 +0000 Subject: [PATCH 5/9] Fix 500 error when trying to upload a non-custom-filter JSON import (#40449) --- app/models/form/import.rb | 9 +++++++-- config/locales/en.yml | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/form/import.rb b/app/models/form/import.rb index e3ad5f8f1e..6893cbb340 100644 --- a/app/models/form/import.rb +++ b/app/models/form/import.rb @@ -202,8 +202,10 @@ class Form::Import end def validate_json_data + return errors.add(:data, I18n.t('imports.errors.incompatible_type')) unless allowed_type_for_json? + return errors.add(:date, I18n.t('imports.errors.no_data')) if json_data.empty? + errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if json_data.count > ROWS_PROCESSING_LIMIT - errors.add(:data, I18n.t('imports.errors.incompatible_type')) unless allowed_type_for_json? end def content_type_is_json? @@ -211,7 +213,10 @@ class Form::Import end def json_data - parse_json['custom_filters'].map(&:deep_symbolize_keys) + case type.to_sym + when :custom_filters + parse_json['custom_filters'].map(&:deep_symbolize_keys) + end end def parse_json diff --git a/config/locales/en.yml b/config/locales/en.yml index 0b9115aba1..acaf60f73d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1692,6 +1692,7 @@ en: incompatible_type: Incompatible with the selected import type invalid_csv_file: 'Invalid CSV file. Error: %{error}' invalid_json_file: 'Invalid JSON file. Error: %{error}' + no_data: This file does not contain any data matching the given import type over_rows_processing_limit: contains more than %{count} rows status_not_found_warning: Some of your filters hide specific posts that are not known by this server. These posts will not be automatically filtered if they are discovered later by the server. too_large: File is too large From f89378492d3504c5258d7012e38aedb123454a5d Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Sep 2026 14:16:16 +0000 Subject: [PATCH 6/9] Fix typo in `Form::Import` (#40451) --- app/models/form/import.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/form/import.rb b/app/models/form/import.rb index 6893cbb340..ab5a737a4c 100644 --- a/app/models/form/import.rb +++ b/app/models/form/import.rb @@ -203,7 +203,7 @@ class Form::Import def validate_json_data return errors.add(:data, I18n.t('imports.errors.incompatible_type')) unless allowed_type_for_json? - return errors.add(:date, I18n.t('imports.errors.no_data')) if json_data.empty? + return errors.add(:data, I18n.t('imports.errors.no_data')) if json_data.empty? errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if json_data.count > ROWS_PROCESSING_LIMIT end From 14c80e3673537fabd1a9b46cec2a306cc6f6fd8e Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 11 Sep 2026 15:21:02 +0000 Subject: [PATCH 7/9] Fix canonical email blocks interfering with freezing or approving users (#40463) --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 33decbab32..29f2ab3ba6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,7 +90,7 @@ class User < ApplicationRecord validates :email, presence: true, email_address: true, length: { maximum: 320 } validates :email, email_mx: { attempt_ip: :sign_up_ip }, if: :validate_email_dns? - validates_with UserEmailValidator, if: -> { ENV['EMAIL_DOMAIN_LISTS_APPLY_AFTER_CONFIRMATION'] == 'true' || !confirmed? } + validates_with UserEmailValidator, if: -> { (ENV['EMAIL_DOMAIN_LISTS_APPLY_AFTER_CONFIRMATION'] == 'true' || !confirmed?) && will_save_change_to_email? } validates :agreement, acceptance: { allow_nil: false, accept: [true, 'true', '1'] }, on: :create # Honeypot/anti-spam fields From 7ee2ec692afeb59d0270d265c5d866abd521c734 Mon Sep 17 00:00:00 2001 From: Kazuki Nagasawa <113568707+crafkaz@users.noreply.github.com> Date: Mon, 14 Sep 2026 08:29:12 +0000 Subject: [PATCH 8/9] Fix relative privacy policy links in subscription emails (#40486) --- .../email_subscription_mailer/confirmation.html.haml | 2 +- .../email_subscription_mailer/notification.html.haml | 2 +- spec/mailers/email_subscription_mailer_spec.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/views/email_subscription_mailer/confirmation.html.haml b/app/views/email_subscription_mailer/confirmation.html.haml index 51f414349e..c0c5ceb50d 100644 --- a/app/views/email_subscription_mailer/confirmation.html.haml +++ b/app/views/email_subscription_mailer/confirmation.html.haml @@ -17,6 +17,6 @@ - content_for :footer do %p.email-footer-p= t('email_subscription_mailer.notification.footer.reason_for_email_html', name: display_name(@subscription.account), unsubscribe_path: @unsubscribe_url) - %p.email-footer-p= t('email_subscription_mailer.notification.footer.privacy_html', domain: @instance, privacy_policy_path: privacy_policy_path) + %p.email-footer-p= t('email_subscription_mailer.notification.footer.privacy_html', domain: @instance, privacy_policy_path: privacy_policy_url) - if Setting.email_footer_text.present? %p.email-footer-p= Setting.email_footer_text diff --git a/app/views/email_subscription_mailer/notification.html.haml b/app/views/email_subscription_mailer/notification.html.haml index 2449264140..4bbbe2f3d5 100644 --- a/app/views/email_subscription_mailer/notification.html.haml +++ b/app/views/email_subscription_mailer/notification.html.haml @@ -24,6 +24,6 @@ - content_for :footer do %p.email-footer-p= t('.footer.reason_for_email_html', name: display_name(@subscription.account), unsubscribe_path: @unsubscribe_url) - %p.email-footer-p= t('.footer.privacy_html', domain: @instance, privacy_policy_path: privacy_policy_path) + %p.email-footer-p= t('.footer.privacy_html', domain: @instance, privacy_policy_path: privacy_policy_url) - if Setting.email_footer_text.present? %p.email-footer-p= Setting.email_footer_text diff --git a/spec/mailers/email_subscription_mailer_spec.rb b/spec/mailers/email_subscription_mailer_spec.rb index 4782291145..b4f4e7e375 100644 --- a/spec/mailers/email_subscription_mailer_spec.rb +++ b/spec/mailers/email_subscription_mailer_spec.rb @@ -3,6 +3,13 @@ require 'rails_helper' RSpec.describe EmailSubscriptionMailer do + shared_examples 'an absolute privacy policy link' do + it 'links to the privacy policy with an absolute URL' do + expect(mail.html_part.body.decoded) + .to include(%(href="#{privacy_policy_url}")) + end + end + describe '.confirmation' do let(:email_subscription) { Fabricate(:email_subscription) } let(:mail) { described_class.with(subscription: email_subscription).confirmation } @@ -15,6 +22,8 @@ RSpec.describe EmailSubscriptionMailer do subject: I18n.t('email_subscription_mailer.confirmation.subject') ) end + + it_behaves_like 'an absolute privacy policy link' end describe '.notification' do @@ -33,6 +42,8 @@ RSpec.describe EmailSubscriptionMailer do subject: I18n.t('email_subscription_mailer.notification.subject.singular', name: email_subscription.account.display_name, excerpt: statuses.first.text.truncate(17)) ) end + + it_behaves_like 'an absolute privacy policy link' end context 'with multiple statuses' do From 3987b9fd624010eeeaeb7cad96606b05aa813f6a Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 15 Sep 2026 14:05:45 +0200 Subject: [PATCH 9/9] Bump version to v4.7.2 --- CHANGELOG.md | 18 +++++++++++++++++- config/initializers/vips.rb | 1 - docker-compose.yml | 6 +++--- lib/mastodon/version.rb | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3817ebd5c0..3ae4659e7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,25 @@ All notable changes to this project will be documented in this file. +## [4.7.2] - 2026-09-15 + +### Security + +- Temporarily disable HEIF support + +### Fixes + +- 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.7.1] - 2026-09-01 -## Security +### Security - 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)) diff --git a/config/initializers/vips.rb b/config/initializers/vips.rb index cd8d2410b9..4d68e9023a 100644 --- a/config/initializers/vips.rb +++ b/config/initializers/vips.rb @@ -17,7 +17,6 @@ Vips.block('VipsForeign', true) VipsForeignLoadJpeg VipsForeignLoadPng VipsForeignLoadWebp - VipsForeignLoadHeif VipsForeignSavePng VipsForeignSaveSpng VipsForeignSaveJpeg diff --git a/docker-compose.yml b/docker-compose.yml index 1e69029260..485a687b33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: web: # You can uncomment the following line if you want to not use the prebuilt image, for example if you have local code changes # build: . - image: ghcr.io/mastodon/mastodon:v4.7.1 + image: ghcr.io/mastodon/mastodon:v4.7.2 restart: always env_file: .env.production command: bundle exec puma -C config/puma.rb @@ -83,7 +83,7 @@ services: # build: # dockerfile: ./streaming/Dockerfile # context: . - image: ghcr.io/mastodon/mastodon-streaming:v4.7.1 + image: ghcr.io/mastodon/mastodon-streaming:v4.7.2 restart: always env_file: .env.production command: node ./streaming/index.js @@ -102,7 +102,7 @@ services: sidekiq: # You can uncomment the following line if you want to not use the prebuilt image, for example if you have local code changes # build: . - image: ghcr.io/mastodon/mastodon:v4.7.1 + image: ghcr.io/mastodon/mastodon:v4.7.2 restart: always env_file: .env.production command: bundle exec sidekiq diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 8abdcc8376..f790da2cdc 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -13,7 +13,7 @@ module Mastodon end def patch - 1 + 2 end def default_prerelease