From f198ec7c1cb9c13fea42ad1b6062ede5d8198fb8 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 4 Mar 2026 12:18:28 +0100 Subject: [PATCH 01/11] Fix existing posts not being removed from lists when a list member is unfollowed (#38048) --- app/services/unfollow_service.rb | 43 +++++++++------- spec/services/unfollow_service_spec.rb | 69 ++++++++++++++------------ 2 files changed, 60 insertions(+), 52 deletions(-) diff --git a/app/services/unfollow_service.rb b/app/services/unfollow_service.rb index 1ea8af6992..385aa0c7b1 100644 --- a/app/services/unfollow_service.rb +++ b/app/services/unfollow_service.rb @@ -6,16 +6,16 @@ class UnfollowService < BaseService include Lockable # Unfollow and notify the remote user - # @param [Account] source_account Where to unfollow from - # @param [Account] target_account Which to unfollow + # @param [Account] follower Where to unfollow from + # @param [Account] followee Which to unfollow # @param [Hash] options # @option [Boolean] :skip_unmerge - def call(source_account, target_account, options = {}) - @source_account = source_account - @target_account = target_account - @options = options + def call(follower, followee, options = {}) + @follower = follower + @followee = followee + @options = options - with_redis_lock("relationship:#{[source_account.id, target_account.id].sort.join(':')}") do + with_redis_lock("relationship:#{[follower.id, followee.id].sort.join(':')}") do unfollow! || undo_follow_request! end end @@ -23,19 +23,25 @@ class UnfollowService < BaseService private def unfollow! - follow = Follow.find_by(account: @source_account, target_account: @target_account) - + follow = Follow.find_by(account: @follower, target_account: @followee) return unless follow + # List members are removed immediately with the follow relationship removal, + # so we need to fetch the list IDs first + list_ids = @follower.owned_lists.with_list_account(@followee).pluck(:list_id) unless @options[:skip_unmerge] + follow.destroy! - create_notification(follow) if !@target_account.local? && @target_account.activitypub? - create_reject_notification(follow) if @target_account.local? && !@source_account.local? && @source_account.activitypub? + if @followee.local? && @follower.remote? && @follower.activitypub? + send_reject_follow(follow) + elsif @followee.remote? && @followee.activitypub? + send_undo_follow(follow) + end unless @options[:skip_unmerge] - UnmergeWorker.perform_async(@target_account.id, @source_account.id, 'home') - UnmergeWorker.push_bulk(@source_account.owned_lists.with_list_account(@target_account).pluck(:list_id)) do |list_id| - [@target_account.id, list_id, 'list'] + UnmergeWorker.perform_async(@followee.id, @follower.id, 'home') + UnmergeWorker.push_bulk(list_ids) do |list_id| + [@followee.id, list_id, 'list'] end end @@ -43,22 +49,21 @@ class UnfollowService < BaseService end def undo_follow_request! - follow_request = FollowRequest.find_by(account: @source_account, target_account: @target_account) - + follow_request = FollowRequest.find_by(account: @follower, target_account: @followee) return unless follow_request follow_request.destroy! - create_notification(follow_request) unless @target_account.local? + send_undo_follow(follow_request) unless @followee.local? follow_request end - def create_notification(follow) + def send_undo_follow(follow) ActivityPub::DeliveryWorker.perform_async(build_json(follow), follow.account_id, follow.target_account.inbox_url) end - def create_reject_notification(follow) + def send_reject_follow(follow) ActivityPub::DeliveryWorker.perform_async(build_reject_json(follow), follow.target_account_id, follow.account.inbox_url) end diff --git a/spec/services/unfollow_service_spec.rb b/spec/services/unfollow_service_spec.rb index 6cf24ca5e1..365468e432 100644 --- a/spec/services/unfollow_service_spec.rb +++ b/spec/services/unfollow_service_spec.rb @@ -5,54 +5,57 @@ require 'rails_helper' RSpec.describe UnfollowService do subject { described_class.new } - let(:sender) { Fabricate(:account, username: 'alice') } + let(:follower) { Fabricate(:account) } + let(:followee) { Fabricate(:account) } - describe 'local' do - let(:bob) { Fabricate(:account, username: 'bob') } + before do + follower.follow!(followee) + end - before { sender.follow!(bob) } + shared_examples 'when the followee is in a list' do + let(:list) { Fabricate(:list, account: follower) } - it 'destroys the following relation' do - subject.call(sender, bob) + before do + list.accounts << followee + end - expect(sender) - .to_not be_following(bob) + it 'schedules removal of posts from this user from the list' do + expect { subject.call(follower, followee) } + .to enqueue_sidekiq_job(UnmergeWorker).with(followee.id, list.id, 'list') end end - describe 'remote ActivityPub', :inline_jobs do - let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } - - before do - sender.follow!(bob) - stub_request(:post, 'http://example.com/inbox').to_return(status: 200) + describe 'a local user unfollowing another local user' do + it 'destroys the following relation and unmerge from home' do + expect { subject.call(follower, followee) } + .to change { follower.following?(followee) }.from(true).to(false) + .and enqueue_sidekiq_job(UnmergeWorker).with(followee.id, follower.id, 'home') end - it 'destroys the following relation and sends unfollow activity' do - subject.call(sender, bob) - - expect(sender) - .to_not be_following(bob) - expect(a_request(:post, 'http://example.com/inbox')) - .to have_been_made.once - end + it_behaves_like 'when the followee is in a list' end - describe 'remote ActivityPub (reverse)', :inline_jobs do - let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } + describe 'a local user unfollowing a remote ActivityPub user' do + let(:followee) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } - before do - bob.follow!(sender) - stub_request(:post, 'http://example.com/inbox').to_return(status: 200) + it 'destroys the following relation, unmerge from home and sends undo activity' do + expect { subject.call(follower, followee) } + .to change { follower.following?(followee) }.from(true).to(false) + .and enqueue_sidekiq_job(UnmergeWorker).with(followee.id, follower.id, 'home') + .and enqueue_sidekiq_job(ActivityPub::DeliveryWorker).with(match_json_values(type: 'Undo'), follower.id, followee.inbox_url) end - it 'destroys the following relation and sends a reject activity' do - subject.call(bob, sender) + it_behaves_like 'when the followee is in a list' + end - expect(sender) - .to_not be_following(bob) - expect(a_request(:post, 'http://example.com/inbox')) - .to have_been_made.once + describe 'a remote ActivityPub user unfollowing a local user' do + let(:follower) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } + + it 'destroys the following relation, unmerge from home and sends a reject activity' do + expect { subject.call(follower, followee) } + .to change { follower.following?(followee) }.from(true).to(false) + .and enqueue_sidekiq_job(UnmergeWorker).with(followee.id, follower.id, 'home') + .and enqueue_sidekiq_job(ActivityPub::DeliveryWorker).with(match_json_values(type: 'Reject'), followee.id, follower.inbox_url) end end end From ba22c3f133599034c2f7b5bf4cbc1596c59399a4 Mon Sep 17 00:00:00 2001 From: diondiondion Date: Tue, 3 Mar 2026 16:26:56 +0100 Subject: [PATCH 02/11] Prevent hover card from showing on touch devices (#38039) --- .../components/hover_card_controller.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/javascript/mastodon/components/hover_card_controller.tsx b/app/javascript/mastodon/components/hover_card_controller.tsx index 38c3306f30..43ca37f50f 100644 --- a/app/javascript/mastodon/components/hover_card_controller.tsx +++ b/app/javascript/mastodon/components/hover_card_controller.tsx @@ -23,6 +23,7 @@ export const HoverCardController: React.FC = () => { const [open, setOpen] = useState(false); const [accountId, setAccountId] = useState(); const [anchor, setAnchor] = useState(null); + const isUsingTouchRef = useRef(false); const cardRef = useRef(null); const [setLeaveTimeout, cancelLeaveTimeout] = useTimeout(); const [setEnterTimeout, cancelEnterTimeout, delayEnterTimeout] = useTimeout(); @@ -60,6 +61,12 @@ export const HoverCardController: React.FC = () => { setAccountId(undefined); }; + const handleTouchStart = () => { + // Keeping track of touch events to prevent the + // hover card from being displayed on touch devices + isUsingTouchRef.current = true; + }; + const handleMouseEnter = (e: MouseEvent) => { const { target } = e; @@ -69,6 +76,11 @@ export const HoverCardController: React.FC = () => { return; } + // Bail out if a touch is active + if (isUsingTouchRef.current) { + return; + } + // We've entered an anchor if (!isScrolling && isHoverCardAnchor(target)) { cancelLeaveTimeout(); @@ -127,9 +139,16 @@ export const HoverCardController: React.FC = () => { }; const handleMouseMove = () => { + if (isUsingTouchRef.current) { + isUsingTouchRef.current = false; + } delayEnterTimeout(enterDelay); }; + document.body.addEventListener('touchstart', handleTouchStart, { + passive: true, + }); + document.body.addEventListener('mouseenter', handleMouseEnter, { passive: true, capture: true, @@ -151,6 +170,7 @@ export const HoverCardController: React.FC = () => { }); return () => { + document.body.removeEventListener('touchstart', handleTouchStart); document.body.removeEventListener('mouseenter', handleMouseEnter); document.body.removeEventListener('mousemove', handleMouseMove); document.body.removeEventListener('mouseleave', handleMouseLeave); From ed521e91e1c780d75374ca5e2ee51bf3bd71f73b Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 25 Feb 2026 15:30:01 +0100 Subject: [PATCH 03/11] Fix username availability check being wrongly applied on race conditions (#37975) --- app/javascript/entrypoints/public.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/javascript/entrypoints/public.tsx b/app/javascript/entrypoints/public.tsx index dd1956446d..ff6819f8ac 100644 --- a/app/javascript/entrypoints/public.tsx +++ b/app/javascript/entrypoints/public.tsx @@ -183,15 +183,25 @@ function loaded() { ({ target }) => { if (!(target instanceof HTMLInputElement)) return; - if (target.value && target.value.length > 0) { + const checkedUsername = target.value; + if (checkedUsername && checkedUsername.length > 0) { axios - .get('/api/v1/accounts/lookup', { params: { acct: target.value } }) + .get('/api/v1/accounts/lookup', { + params: { acct: checkedUsername }, + }) .then(() => { - target.setCustomValidity(formatMessage(messages.usernameTaken)); + // Only update the validity if the result is for the currently-typed username + if (checkedUsername === target.value) { + target.setCustomValidity(formatMessage(messages.usernameTaken)); + } + return true; }) .catch(() => { - target.setCustomValidity(''); + // Only update the validity if the result is for the currently-typed username + if (checkedUsername === target.value) { + target.setCustomValidity(''); + } }); } else { target.setCustomValidity(''); From a3f0a0373dea75080cd471a0aab5fa39f290b53a Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 5 Mar 2026 10:10:49 +0100 Subject: [PATCH 04/11] =?UTF-8?q?Fix=20=E2=80=9CUnblock=E2=80=9D=20and=20?= =?UTF-8?q?=E2=80=9CUnmute=E2=80=9D=20actions=20being=20disabled=20when=20?= =?UTF-8?q?blocked=20(#38075)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/components/follow_button.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/javascript/mastodon/components/follow_button.tsx b/app/javascript/mastodon/components/follow_button.tsx index 97aaecd1aa..6efd37d16e 100644 --- a/app/javascript/mastodon/components/follow_button.tsx +++ b/app/javascript/mastodon/components/follow_button.tsx @@ -129,6 +129,8 @@ export const FollowButton: React.FC<{ : messages.follow; let label; + let disabled = + relationship?.blocked_by || account?.suspended || !!account?.moved; if (!signedIn) { label = intl.formatMessage(followMessage); @@ -138,12 +140,16 @@ export const FollowButton: React.FC<{ label = ; } else if (relationship.muting) { label = intl.formatMessage(messages.unmute); + disabled = false; } else if (relationship.following) { label = intl.formatMessage(messages.unfollow); + disabled = false; } else if (relationship.blocking) { label = intl.formatMessage(messages.unblock); + disabled = false; } else if (relationship.requested) { label = intl.formatMessage(messages.followRequestCancel); + disabled = false; } else if (relationship.followed_by && !account?.locked) { label = intl.formatMessage(messages.followBack); } else { @@ -168,11 +174,7 @@ export const FollowButton: React.FC<{ return (