diff --git a/.github/actions/setup-ruby/action.yml b/.github/actions/setup-ruby/action.yml index 8dcdafb7d9..cf487f3093 100644 --- a/.github/actions/setup-ruby/action.yml +++ b/.github/actions/setup-ruby/action.yml @@ -24,7 +24,7 @@ runs: ${{ inputs.additional-system-dependencies }} - name: Set up Ruby - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1 + uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0 with: ruby-version: ${{ inputs.ruby-version }} bundler-cache: true diff --git a/.github/workflows/bundler-audit.yml b/.github/workflows/bundler-audit.yml index e28552f40a..e94aaa1b73 100644 --- a/.github/workflows/bundler-audit.yml +++ b/.github/workflows/bundler-audit.yml @@ -32,7 +32,7 @@ jobs: uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - name: Set up Ruby - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1 + uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0 with: bundler-cache: true diff --git a/.github/workflows/lint-haml.yml b/.github/workflows/lint-haml.yml index d212a280bf..a3dba81176 100644 --- a/.github/workflows/lint-haml.yml +++ b/.github/workflows/lint-haml.yml @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - name: Set up Ruby - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1 + uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0 with: bundler-cache: true diff --git a/.github/workflows/lint-ruby.yml b/.github/workflows/lint-ruby.yml index a308149d61..9d88cb964d 100644 --- a/.github/workflows/lint-ruby.yml +++ b/.github/workflows/lint-ruby.yml @@ -37,7 +37,7 @@ jobs: uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - name: Set up Ruby - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1 + uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0 with: bundler-cache: true diff --git a/.ruby-version b/.ruby-version index 7636e75650..7919852fe1 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -4.0.5 +4.0.9 diff --git a/Dockerfile b/Dockerfile index d850abb5ad..7b929ad983 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ ARG BASE_REGISTRY="docker.io" # Ruby image to use for base image, change with [--build-arg RUBY_VERSION="4.0.x"] # renovate: datasource=docker depName=docker.io/ruby -ARG RUBY_VERSION="4.0.5" +ARG RUBY_VERSION="4.0.9" # # Node.js version to use in base image, change with [--build-arg NODE_MAJOR_VERSION="22"] # renovate: datasource=node-version depName=node ARG NODE_MAJOR_VERSION="24" diff --git a/Gemfile.lock b/Gemfile.lock index 82aee8a7fd..3cc418c68a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,9 +178,10 @@ GEM crack (1.0.1) bigdecimal rexml - crass (1.0.7) - css_parser (3.0.0) + crass (1.0.8) + css_parser (3.3.0) addressable + base64 ssrf_filter (~> 1.5) csv (3.3.5) database_cleaner-active_record (2.2.2) @@ -230,7 +231,7 @@ GEM erubi (1.13.1) et-orbi (1.4.0) tzinfo - excon (1.5.0) + excon (1.8.0) logger fabrication (3.0.0) faker (3.8.0) @@ -595,7 +596,7 @@ GEM pastel (0.8.0) tty-color (~> 0.5) pg (1.6.3) - pghero (3.8.0) + pghero (4.1.0) activerecord (>= 7.2) playwright-ruby-client (1.60.0) base64 @@ -808,8 +809,8 @@ GEM fugit (~> 1.1, >= 1.11.1) safety_net_attestation (0.5.0) jwt (>= 2.0, < 4.0) - sanitize (7.0.0) - crass (~> 1.0.2) + sanitize (7.0.1) + crass (~> 1.0.8) nokogiri (>= 1.16.8) scenic (1.9.0) activerecord (>= 4.0.0) diff --git a/app/javascript/flavours/glitch/features/account_edit/styles.module.scss b/app/javascript/flavours/glitch/features/account_edit/styles.module.scss index c98bbc09a6..e38b01b911 100644 --- a/app/javascript/flavours/glitch/features/account_edit/styles.module.scss +++ b/app/javascript/flavours/glitch/features/account_edit/styles.module.scss @@ -25,7 +25,7 @@ .avatar { margin-top: -64px; - margin-left: calc(var(--space-4) - 2px); + margin-left: calc(16px - 2px); position: relative; width: 82px; @@ -251,7 +251,7 @@ // Section component .section { - padding: var(--space-6) var(--space-4); + padding: 24px 16px; border-bottom: 1px solid var(--color-border-primary); font-size: 15px; diff --git a/app/javascript/mastodon/features/account_edit/styles.module.scss b/app/javascript/mastodon/features/account_edit/styles.module.scss index c98bbc09a6..e38b01b911 100644 --- a/app/javascript/mastodon/features/account_edit/styles.module.scss +++ b/app/javascript/mastodon/features/account_edit/styles.module.scss @@ -25,7 +25,7 @@ .avatar { margin-top: -64px; - margin-left: calc(var(--space-4) - 2px); + margin-left: calc(16px - 2px); position: relative; width: 82px; @@ -251,7 +251,7 @@ // Section component .section { - padding: var(--space-6) var(--space-4); + padding: 24px 16px; border-bottom: 1px solid var(--color-border-primary); font-size: 15px; diff --git a/app/lib/account_statuses_filter.rb b/app/lib/account_statuses_filter.rb index e784bc4abd..06d404877c 100644 --- a/app/lib/account_statuses_filter.rb +++ b/app/lib/account_statuses_filter.rb @@ -48,11 +48,14 @@ class AccountStatusesFilter def filtered_scope scope = account.statuses - if exclude_direct? - scope = scope.where(visibility: follower? ? %i(public unlisted private) : %i(public unlisted)) + if exclude_direct? && follower? + scope = scope.list_eligible_visibility + elsif exclude_direct? + scope = account.statuses.left_outer_joins(:mentions) + scope.merge!(scope.distributable_visibility.or(scope.where(visibility: :private).where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id])) else scope = account.statuses.left_outer_joins(:mentions) - scope.merge!(scope.where(visibility: follower? ? %i(public unlisted private) : %i(public unlisted)).or(scope.where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id])) + scope.merge!(visibility_scope(scope).or(scope.where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id])) end scope.merge!(filtered_reblogs_scope) if reblogs_may_occur? @@ -60,6 +63,14 @@ class AccountStatusesFilter scope end + def visibility_scope(scope) + if follower? + scope.list_eligible_visibility + else + scope.distributable_visibility + end + end + def filtered_reblogs_scope scope = Status.left_outer_joins(reblog: :account) scope diff --git a/app/lib/status_cache_hydrator.rb b/app/lib/status_cache_hydrator.rb index c2cfc9243b..d26751442d 100644 --- a/app/lib/status_cache_hydrator.rb +++ b/app/lib/status_cache_hydrator.rb @@ -53,11 +53,26 @@ class StatusCacheHydrator end def fill_status_payload(payload, status, account, nested: false, fresh: true) - payload[:favourited] = Favourite.exists?(account_id: account.id, status_id: status.id) - payload[:reblogged] = Status.exists?(account_id: account.id, reblog_of_id: status.id) - payload[:muted] = ConversationMute.exists?(account_id: account.id, conversation_id: status.conversation_id) - payload[:bookmarked] = Bookmark.exists?(account_id: account.id, status_id: status.id) - payload[:pinned] = StatusPin.exists?(account_id: account.id, status_id: status.id) if status.account_id == account.id + queries = [ + Favourite.where(account_id: account.id, status_id: status.id).arel.exists.as('favourited'), + Status.where(account_id: account.id, reblog_of_id: status.id).arel.exists.as('reblogged'), + ConversationMute.where(account_id: account.id, conversation_id: status.conversation_id).arel.exists.as('muted'), + Bookmark.where(account_id: account.id, status_id: status.id).arel.exists.as('bookmarked'), + ] + + if status.account_id == account.id + queries.push( + StatusPin.where(account_id: account.id, status_id: status.id).arel.exists.as('pinned') + ) + end + + flags = Status.connection.select_one(Arel::SelectManager.new.project(queries)) + + payload[:favourited] = flags['favourited'] + payload[:reblogged] = flags['reblogged'] + payload[:muted] = flags['muted'] + payload[:bookmarked] = flags['bookmarked'] + payload[:pinned] = flags['pinned'] if status.account_id == account.id payload[:filtered] = mapped_applied_custom_filter(account, status) payload[:quote_approval][:current_user] = status.quote_policy_for_account(account) if payload[:quote_approval] payload[:quote] = hydrate_quote_payload(payload[:quote], status.quote, account, nested:) if payload[:quote] diff --git a/app/models/tag_feed.rb b/app/models/tag_feed.rb index f9ed437994..0c6d09c3ea 100644 --- a/app/models/tag_feed.rb +++ b/app/models/tag_feed.rb @@ -31,6 +31,7 @@ class TagFeed < PublicFeed scope.merge!(tagged_with_any_scope) scope.merge!(tagged_with_all_scope) scope.merge!(tagged_with_none_scope) + scope.merge!(tagged_with_cursor_scope(max_id, since_id, min_id)) scope.merge!(local_only_scope) if local_only? scope.merge!(remote_only_scope) if remote_only? scope.merge!(account_filters_scope) if account? @@ -61,6 +62,14 @@ class TagFeed < PublicFeed Status.group(:id).tagged_with_none(tags_for(options[:none])) end + def tagged_with_cursor_scope(max_id, since_id, min_id) + lower_id = min_id.presence || since_id.presence + scope = Status.all + scope = scope.where(statuses_tags: { status_id: ...max_id }) if max_id.present? + scope = scope.where('statuses_tags.status_id > ?', lower_id) if lower_id.present? + scope + end + def tags_for(names) Tag.matching_name(Array(names).take(LIMIT_PER_MODE)).pluck(:id) if names.present? end diff --git a/app/services/revoke_collection_item_service.rb b/app/services/revoke_collection_item_service.rb index a5222d2b62..fa314fb407 100644 --- a/app/services/revoke_collection_item_service.rb +++ b/app/services/revoke_collection_item_service.rb @@ -10,13 +10,13 @@ class RevokeCollectionItemService < BaseService @collection_item.revoke! - distribute_stamp_deletion! if @collection_item.remote? + distribute_stamp_deletion! end private def distribute_stamp_deletion! - ActivityPub::DeliveryWorker.perform_async(signed_activity_json, @account.id, @collection.account.inbox_url) + ActivityPub::DeliveryWorker.perform_async(signed_activity_json, @account.id, @collection.account.inbox_url) if @collection_item.remote? ActivityPub::CollectionRawDistributionWorker.perform_async(signed_activity_json, @collection.id) end diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 5aefb1fd00..a8201293bb 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -17,6 +17,7 @@ namespace :dev do ).find_or_create_by!(id: 10_000_000) showcase_user.mark_email_as_confirmed! showcase_user.approve! + showcase_account.reload french_post = Status.create_with( text: 'Ceci est un sondage public écrit en Français', @@ -200,6 +201,7 @@ namespace :dev do domain: 'example.org', uri: 'https://example.org/foo/bar', url: 'https://example.org/foo/bar', + inbox_url: 'https://example.org/users/fake.example/inbox', locked: true ).find_or_create_by!(id: 10_000_001) diff --git a/spec/lib/rake/task_devpopulate_sample_data_spec.rb b/spec/lib/rake/task_devpopulate_sample_data_spec.rb new file mode 100644 index 0000000000..bda22798ee --- /dev/null +++ b/spec/lib/rake/task_devpopulate_sample_data_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'rails_helper' +require 'rake' + +RSpec.describe Rake::Task do + describe 'dev:populate_sample_data' do + subject { described_class['dev:populate_sample_data'] } + + before do + Rails.application.load_tasks unless described_class.tasks.any? + subject.reenable + end + + describe '.invoke' do + context 'when the task is invoked successfully' do + it 'runs without aborting' do + expect { subject.invoke }.to_not raise_error + end + + it 'populates accounts and users' do + expect { subject.invoke } + .to change(Account, :count).by(3) + .and change(User, :count).by(2) + end + end + end + end +end diff --git a/spec/models/tag_feed_spec.rb b/spec/models/tag_feed_spec.rb index c4abe079e6..89171ce898 100644 --- a/spec/models/tag_feed_spec.rb +++ b/spec/models/tag_feed_spec.rb @@ -72,6 +72,21 @@ RSpec.describe TagFeed do expect(results).to include(status) end + it 'paginates with max_id' do + results = described_class.new(tag_cats, nil, any: [tag_dogs.name]).get(20, both.id) + expect(results).to contain_exactly(status_tagged_with_cats, status_tagged_with_dogs) + end + + it 'paginates with since_id' do + results = described_class.new(tag_cats, nil, any: [tag_dogs.name]).get(20, nil, status_tagged_with_cats.id) + expect(results).to contain_exactly(status_tagged_with_dogs, both) + end + + it 'paginates with min_id' do + results = described_class.new(tag_cats, nil, any: [tag_dogs.name]).get(20, nil, nil, status_tagged_with_cats.id) + expect(results).to contain_exactly(status_tagged_with_dogs, both) + end + context 'when the feed contains a local-only status' do let!(:status) { Fabricate(:status, tags: [tag_cats], local_only: true) } diff --git a/spec/services/revoke_collection_item_service_spec.rb b/spec/services/revoke_collection_item_service_spec.rb index 760c9038b9..a3defcf53a 100644 --- a/spec/services/revoke_collection_item_service_spec.rb +++ b/spec/services/revoke_collection_item_service_spec.rb @@ -10,6 +10,8 @@ RSpec.describe RevokeCollectionItemService do it 'revokes the collection item and sends a Delete activity' do expect { subject.call(collection_item) } .to change { collection_item.reload.state }.from('accepted').to('revoked') + + expect(ActivityPub::CollectionRawDistributionWorker).to have_enqueued_sidekiq_job end context 'when the collection is remote' do @@ -17,7 +19,7 @@ RSpec.describe RevokeCollectionItemService do let(:collection) { Fabricate(:remote_collection, account:) } let(:collection_item) { Fabricate(:collection_item, collection:, uri: 'https://example.com') } - it 'federates a `Delete` activity' do + it 'federates a `Delete` activity to collection owner as well' do subject.call(collection_item) expect(ActivityPub::DeliveryWorker).to have_enqueued_sidekiq_job.with(instance_of(String), collection_item.account_id, 'https://example.com/actor/1/inbox')