Compare commits

...

5 Commits

Author SHA1 Message Date
Emelia Smith
d3cf53042a
Merge 0c7116d267 into 6d62581da1 2024-11-25 17:05:03 +00:00
Matt Jankowski
6d62581da1
Update binstub templates (#32335)
Some checks are pending
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
2024-11-25 16:49:24 +00:00
Claire
9a7130d6da
Fix direct inbox delivery pushing posts into inactive followers' timelines (#33067) 2024-11-25 15:54:18 +00:00
Emelia Smith
0c7116d267
WIP 2024-08-17 18:48:01 +02:00
Emelia Smith
17ea727950
Split setting for timeline_preview into timeline_preview_local and timeline_preview_remote 2024-08-17 18:46:50 +02:00
20 changed files with 168 additions and 25 deletions

View File

@ -36,4 +36,4 @@ jobs:
bundler-cache: true
- name: Run bundler-audit
run: bundle exec bundler-audit check --update
run: bin/bundler-audit check --update

View File

@ -35,18 +35,18 @@ jobs:
git diff --exit-code
- name: Check locale file normalization
run: bundle exec i18n-tasks check-normalized
run: bin/i18n-tasks check-normalized
- name: Check for unused strings
run: bundle exec i18n-tasks unused
run: bin/i18n-tasks unused
- name: Check for missing strings in English YML
run: |
bundle exec i18n-tasks add-missing -l en
bin/i18n-tasks add-missing -l en
git diff --exit-code
- name: Check for wrong string interpolations
run: bundle exec i18n-tasks check-consistent-interpolations
run: bin/i18n-tasks check-consistent-interpolations
- name: Check that all required locale files exist
run: bundle exec rake repo:check_locales_files
run: bin/rake repo:check_locales_files

View File

@ -46,7 +46,7 @@ jobs:
uses: ./.github/actions/setup-ruby
- name: Run i18n normalize task
run: bundle exec i18n-tasks normalize
run: bin/i18n-tasks normalize
# Create or update the pull request
- name: Create Pull Request

View File

@ -48,7 +48,7 @@ jobs:
uses: ./.github/actions/setup-ruby
- name: Run i18n normalize task
run: bundle exec i18n-tasks normalize
run: bin/i18n-tasks normalize
# Create or update the pull request
- name: Create Pull Request

View File

@ -43,4 +43,4 @@ jobs:
- name: Run haml-lint
run: |
echo "::add-matcher::.github/workflows/haml-lint-problem-matcher.json"
bundle exec haml-lint --reporter github
bin/haml-lint --reporter github

View File

@ -1031,7 +1031,7 @@ DEPENDENCIES
xorcist (~> 1.1)
RUBY VERSION
ruby 3.3.5p100
ruby 3.3.6p108
BUNDLED WITH
2.5.22
2.5.23

View File

@ -8,7 +8,7 @@ class Api::V1::Timelines::BaseController < Api::BaseController
private
def require_auth?
!Setting.timeline_preview
!(Setting.timeline_preview_local && Setting.timeline_preview_remote)
end
def pagination_collection

View File

@ -2,6 +2,7 @@
class Api::V1::Timelines::LinkController < Api::V1::Timelines::BaseController
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
before_action :require_user!, if: :require_auth?
before_action :set_preview_card
before_action :set_statuses
@ -17,6 +18,12 @@ class Api::V1::Timelines::LinkController < Api::V1::Timelines::BaseController
private
# A viewer can only see the link timeline if both timeline_preview_local and
# timeline_preview_remote are true, since it includes remote content
def require_auth?
!(Setting.timeline_preview_local && Setting.timeline_preview_remote)
end
def set_preview_card
@preview_card = PreviewCard.joins(:trend).merge(PreviewCardTrend.allowed).find_by!(url: params[:url])
end

View File

@ -14,10 +14,6 @@ class Api::V1::Timelines::TagController < Api::V1::Timelines::BaseController
private
def require_auth?
!Setting.timeline_preview
end
def load_tag
@tag = Tag.find_normalized(params[:id])
end

View File

@ -58,6 +58,7 @@ class FeedManager
# @param [Boolean] update
# @return [Boolean]
def push_to_home(account, status, update: false)
return false unless account.user&.signed_in_recently?
return false unless add_to_feed(:home, account.id, status, aggregate_reblogs: account.user&.aggregates_reblogs?)
trim(:home, account.id)
@ -83,7 +84,9 @@ class FeedManager
# @param [Boolean] update
# @return [Boolean]
def push_to_list(list, status, update: false)
return false if filter_from_list?(status, list) || !add_to_feed(:list, list.id, status, aggregate_reblogs: list.account.user&.aggregates_reblogs?)
return false if filter_from_list?(status, list)
return false unless list.account.user&.signed_in_recently?
return false unless add_to_feed(:list, list.id, status, aggregate_reblogs: list.account.user&.aggregates_reblogs?)
trim(:list, list.id)
PushUpdateWorker.perform_async(list.account_id, status.id, "timeline:list:#{list.id}", { 'update' => update }) if push_update_required?("timeline:list:#{list.id}")

View File

@ -14,7 +14,8 @@ class Form::AdminSettings
site_terms
registrations_mode
closed_registrations_message
timeline_preview
timeline_preview_local
timeline_preview_remote
bootstrap_timeline_accounts
theme
activity_api_enabled
@ -48,7 +49,8 @@ class Form::AdminSettings
).freeze
BOOLEAN_KEYS = %i(
timeline_preview
timeline_preview_local
timeline_preview_remote
activity_api_enabled
peers_api_enabled
preview_sensitive_media

View File

@ -165,6 +165,10 @@ class User < ApplicationRecord
end
end
def signed_in_recently?
current_sign_in_at.present? && current_sign_in_at >= ACTIVE_DURATION.ago
end
def confirmed?
confirmed_at.present?
end

27
bin/bundler-audit Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'bundler-audit' is installed as part of a gem, and
# this file is here to facilitate running it.
#
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"
load Gem.bin_path("bundler-audit", "bundler-audit")

27
bin/haml-lint Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'haml-lint' is installed as part of a gem, and
# this file is here to facilitate running it.
#
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"
load Gem.bin_path("haml_lint", "haml-lint")

27
bin/i18n-tasks Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'i18n-tasks' is installed as part of a gem, and
# this file is here to facilitate running it.
#
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"
load Gem.bin_path("i18n-tasks", "i18n-tasks")

View File

@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
@ -7,9 +8,18 @@
# this file is here to facilitate running it.
#
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"

View File

@ -12,7 +12,8 @@ defaults: &defaults
registrations_mode: 'none'
profile_directory: true
closed_registrations_message: ''
timeline_preview: true
timeline_preview_local: true
timeline_preview_remote: false
show_staff_badge: true
preview_sensitive_media: false
noindex: false

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
class SplitPublicTimelinesSetting < ActiveRecord::Migration[7.1]
def up
previous_setting = Setting.find_by(var: 'timeline_preview')
unless previous_setting.nil?
Setting['timeline_preview_local'] = previous_setting.value
Setting['timeline_preview_remote'] = previous_setting.value
previous_setting.delete
end
end
def down
preview_local = Setting['timeline_preview_local']
preview_remote = Setting['timeline_preview_remote']
unless preview_local.nil? && preview_remote.nil?
preview_timelines = (!preview_local.nil? && preview_local) && (!preview_remote.nil? && preview_remote)
Setting['timeline_preview'] = preview_timelines
end
Setting.where(var: ['timeline_preview_local', 'timeline_preview_remote']).delete_all
end
end

View File

@ -3,7 +3,7 @@ const config = {
'Capfile|Gemfile|*.{rb,ruby,ru,rake}': 'bin/rubocop --force-exclusion -a',
'*.{js,jsx,ts,tsx}': 'eslint --fix',
'*.{css,scss}': 'stylelint --fix',
'*.haml': 'bundle exec haml-lint -a',
'*.haml': 'bin/haml-lint -a',
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
};

View File

@ -19,6 +19,14 @@ RSpec.describe 'Link' do
end
end
# The default settings are that timeline_preview_local is true but
# timeline_preview_remote is false, which caused this spec to fail because it
# assumes the default visibility is true.
before do
Form::AdminSettings.new(timeline_preview_local: true).save
Form::AdminSettings.new(timeline_preview_remote: true).save
end
describe 'GET /api/v1/timelines/link' do
subject do
get '/api/v1/timelines/link', headers: headers, params: params
@ -87,7 +95,8 @@ RSpec.describe 'Link' do
context 'when the instance does not allow public preview' do
before do
Form::AdminSettings.new(timeline_preview: false).save
Form::AdminSettings.new(timeline_preview_local: false).save
Form::AdminSettings.new(timeline_preview_remote: false).save
end
it_behaves_like 'forbidden for wrong scope', 'profile'
@ -122,6 +131,11 @@ RSpec.describe 'Link' do
end
context 'when the instance allows public preview' do
before do
Form::AdminSettings.new(timeline_preview_local: true).save
Form::AdminSettings.new(timeline_preview_remote: true).save
end
context 'with an authorized user' do
it_behaves_like 'a successful request to the link timeline'
end