Skip to content

Commit

Permalink
Merge remote-tracking branch 'parent/main' into upstream-20231124
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Nov 24, 2023
2 parents 5038eb2 + 19baf22 commit c5e4020
Show file tree
Hide file tree
Showing 206 changed files with 1,983 additions and 961 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-javascript/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
using: 'composite'
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ gem 'sprockets', '~> 3.7.2'
gem 'thor', '~> 1.2'
gem 'rack', '~> 2.2.7'

# For why irb is in the Gemfile, see: https://ruby.social/@st0012/111444685161478182
gem 'irb', '~> 1.8'

gem 'haml-rails', '~>2.0'
gem 'pg', '~> 1.5'
gem 'pghero'
Expand Down Expand Up @@ -181,6 +184,9 @@ group :development do
end

group :development, :test do
# Interactive Debugging tools
gem 'debug', '~> 1.8'

# Profiling tools
gem 'memory_profiler', require: false
gem 'ruby-prof', require: false
Expand Down
50 changes: 28 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,21 @@ GEM
encryptor (~> 3.0.0)
attr_required (1.0.1)
awrence (1.2.1)
aws-eventstream (1.2.0)
aws-partitions (1.828.0)
aws-sdk-core (3.183.1)
aws-eventstream (1.3.0)
aws-partitions (1.855.0)
aws-sdk-core (3.188.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sdk-kms (1.73.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.136.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-s3 (1.139.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-sigv4 (1.7.0)
aws-eventstream (~> 1, >= 1.0.2)
azure-storage-blob (2.0.3)
azure-storage-common (~> 2.0)
Expand All @@ -154,7 +154,7 @@ GEM
faraday_middleware (~> 1.0, >= 1.0.0.rc1)
net-http-persistent (~> 4.0)
nokogiri (~> 1, >= 1.10.8)
base64 (0.1.1)
base64 (0.2.0)
bcp47_spec (0.2.1)
bcrypt (3.1.19)
better_errors (2.10.1)
Expand Down Expand Up @@ -220,6 +220,9 @@ GEM
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.4)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
debug_inspector (1.1.0)
devise (4.9.3)
bcrypt (~> 3.0)
Expand All @@ -242,13 +245,13 @@ GEM
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
doorkeeper (5.6.6)
doorkeeper (5.6.7)
railties (>= 5)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
drb (2.1.1)
drb (2.2.0)
ruby2_keywords
ed25519 (1.3.0)
elasticsearch (7.13.3)
Expand Down Expand Up @@ -374,7 +377,7 @@ GEM
terminal-table (>= 1.5.1)
idn-ruby (0.1.5)
io-console (0.6.0)
irb (1.8.3)
irb (1.9.1)
rdoc
reline (>= 0.3.8)
jmespath (1.6.2)
Expand Down Expand Up @@ -436,7 +439,7 @@ GEM
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.21.4)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -462,7 +465,7 @@ GEM
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.3.0)
mutex_m (0.1.2)
mutex_m (0.2.0)
net-http (0.4.0)
uri
net-http-persistent (4.0.2)
Expand All @@ -478,7 +481,7 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.4)
nokogiri (1.15.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oj (3.16.1)
Expand Down Expand Up @@ -533,7 +536,7 @@ GEM
private_address_check (0.5.0)
psych (5.1.1.1)
stringio
public_suffix (5.0.3)
public_suffix (5.0.4)
puma (6.4.0)
nio4r (~> 2.0)
pundit (2.3.1)
Expand Down Expand Up @@ -599,13 +602,13 @@ GEM
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.0.6)
rake (13.1.0)
rdf (3.3.1)
bcp47_spec (~> 0.2)
link_header (~> 0.0, >= 0.0.8)
rdf-normalize (0.6.1)
rdf (~> 3.2)
rdoc (6.5.0)
rdoc (6.6.0)
psych (>= 4.0.0)
redcarpet (3.6.0)
redis (4.8.1)
Expand All @@ -614,7 +617,7 @@ GEM
redlock (1.3.2)
redis (>= 3.0.0, < 6.0)
regexp_parser (2.8.2)
reline (0.3.9)
reline (0.4.0)
io-console (~> 0.5)
request_store (1.5.1)
rack (>= 1.4)
Expand All @@ -639,7 +642,7 @@ GEM
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-rails (6.0.3)
rspec-rails (6.1.0)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
Expand Down Expand Up @@ -675,10 +678,11 @@ GEM
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.22.1)
rubocop-rails (2.22.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
Expand Down Expand Up @@ -758,7 +762,7 @@ GEM
unicode-display_width (>= 1.1.1, < 3)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
test-prof (1.2.3)
test-prof (1.3.0)
thor (1.3.0)
tilt (2.3.0)
timeout (0.4.1)
Expand Down Expand Up @@ -852,6 +856,7 @@ DEPENDENCIES
concurrent-ruby
connection_pool
database_cleaner-active_record
debug (~> 1.8)
devise (~> 4.9)
devise-two-factor (~> 4.1)
devise_pam_authenticatable2 (~> 9.2)
Expand All @@ -877,6 +882,7 @@ DEPENDENCIES
httplog (~> 1.6.2)
i18n-tasks (~> 1.0)
idn-ruby
irb (~> 1.8)
json-ld
json-ld-preloaded (~> 3.2)
json-schema (~> 4.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def remove_status
private

def batched_ordered_status_edits
@status.edits.reorder(nil).includes(:account, status: [:account]).find_each(order: :asc)
@status.edits.includes(:account, status: [:account]).find_each(order: :asc)
end
helper_method :batched_ordered_status_edits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def index
private

def set_accounts
@accounts = Account.without_suspended.where(id: account_ids).select('id, hide_collections').index_by(&:id).values_at(*account_ids).compact
@accounts = Account.without_suspended.where(id: account_ids).select('id, hide_collections')
end

def familiar_followers
Expand Down
7 changes: 2 additions & 5 deletions app/controllers/api/v1/accounts/relationships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController
before_action :require_user!

def index
scope = Account.where(id: account_ids).select('id')
scope.merge!(Account.without_suspended) unless truthy_param?(:with_suspended)
# .where doesn't guarantee that our results are in the same order
# we requested them, so return the "right" order to the requestor.
@accounts = scope.index_by(&:id).values_at(*account_ids).compact
@accounts = Account.where(id: account_ids).select('id')
@accounts.merge!(Account.without_suspended) unless truthy_param?(:with_suspended)
render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships
end

Expand Down
47 changes: 33 additions & 14 deletions app/controllers/api/v1/instances/activity_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class Api::V1::Instances::ActivityController < Api::V1::Instances::BaseController
before_action :require_enabled_api!

WEEKS_OF_ACTIVITY = 12

def show
cache_even_if_authenticated!
render_with_cache json: :activity, expires_in: 1.day
Expand All @@ -11,23 +13,40 @@ def show
private

def activity
statuses_tracker = ActivityTracker.new('activity:statuses:local', :basic)
logins_tracker = ActivityTracker.new('activity:logins', :unique)
registrations_tracker = ActivityTracker.new('activity:accounts:local', :basic)

(0...12).map do |i|
start_of_week = i.weeks.ago
end_of_week = start_of_week + 6.days

{
week: start_of_week.to_i.to_s,
statuses: statuses_tracker.sum(start_of_week, end_of_week).to_s,
logins: logins_tracker.sum(start_of_week, end_of_week).to_s,
registrations: registrations_tracker.sum(start_of_week, end_of_week).to_s,
}
activity_weeks.map do |weeks_ago|
activity_json(*week_edge_days(weeks_ago))
end
end

def activity_json(start_of_week, end_of_week)
{
week: start_of_week.to_i.to_s,
statuses: statuses_tracker.sum(start_of_week, end_of_week).to_s,
logins: logins_tracker.sum(start_of_week, end_of_week).to_s,
registrations: registrations_tracker.sum(start_of_week, end_of_week).to_s,
}
end

def activity_weeks
0...WEEKS_OF_ACTIVITY
end

def week_edge_days(num)
[num.weeks.ago, num.weeks.ago + 6.days]
end

def statuses_tracker
ActivityTracker.new('activity:statuses:local', :basic)
end

def logins_tracker
ActivityTracker.new('activity:logins', :unique)
end

def registrations_tracker
ActivityTracker.new('activity:accounts:local', :basic)
end

def require_enabled_api!
head 404 unless Setting.activity_api_enabled && !limited_federation_mode?
end
Expand Down
14 changes: 13 additions & 1 deletion app/controllers/api/v1/instances/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ def index
private

def require_enabled_api!
head 404 unless Setting.show_domain_blocks == 'all' || (Setting.show_domain_blocks == 'users' && user_signed_in?)
head 404 unless api_enabled?
end

def api_enabled?
show_domain_blocks_for_all? || show_domain_blocks_to_user?
end

def show_domain_blocks_for_all?
Setting.show_domain_blocks == 'all'
end

def show_domain_blocks_to_user?
Setting.show_domain_blocks == 'users' && user_signed_in?
end

def set_domain_blocks
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/statuses/histories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def show
private

def status_edits
@status.edits.includes(:account, status: [:account]).to_a.presence || [@status.build_snapshot(at_time: @status.edited_at || @status.created_at)]
@status.edits.ordered.includes(:account, status: [:account]).to_a.presence || [@status.build_snapshot(at_time: @status.edited_at || @status.created_at)]
end
end
14 changes: 12 additions & 2 deletions app/controllers/api/v2/media_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

class Api::V2::MediaController < Api::V1::MediaController
def create
@media_attachment = current_account.media_attachments.create!({ delay_processing: true }.merge(media_attachment_params))
render json: @media_attachment, serializer: REST::MediaAttachmentSerializer, status: @media_attachment.not_processed? ? 202 : 200
@media_attachment = current_account.media_attachments.create!(media_and_delay_params)
render json: @media_attachment, serializer: REST::MediaAttachmentSerializer, status: status_from_media_processing
rescue Paperclip::Errors::NotIdentifiedByImageMagickError
render json: file_type_error, status: 422
rescue Paperclip::Error => e
Rails.logger.error "#{e.class}: #{e.message}"
render json: processing_error, status: 500
end

private

def media_and_delay_params
{ delay_processing: true }.merge(media_attachment_params)
end

def status_from_media_processing
@media_attachment.not_processed? ? 202 : 200
end
end
11 changes: 11 additions & 0 deletions app/javascript/mastodon/locales/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,38 @@
"about.rules": "Normes del sirvidor",
"account.account_note_header": "Nota",
"account.add_or_remove_from_list": "Amestar o quitar de les llistes",
"account.badges.bot": "Automatizáu",
"account.badges.group": "Grupu",
"account.block": "Bloquiar a @{name}",
"account.block_domain": "Bloquiar el dominiu {domain}",
"account.block_short": "Bloquiar",
"account.blocked": "Perfil bloquiáu",
"account.browse_more_on_origin_server": "Restolar más nel perfil orixinal",
"account.cancel_follow_request": "Atayar siguimientu",
"account.copy": "Copiar I'enllaz al perfil",
"account.direct": "Mentar a @{name} per privao",
"account.disable_notifications": "Dexar d'avisame cuando @{name} espublice artículos",
"account.domain_blocked": "Dominiu bloquiáu",
"account.edit_profile": "Editar el perfil",
"account.enable_notifications": "Avisame cuando @{name} espublice artículos",
"account.endorse": "Destacar nel perfil",
"account.featured_tags.last_status_at": "Últimu estáu en {date}",
"account.featured_tags.last_status_never": "Sin estaos",
"account.featured_tags.title": "Etiquetes destacaes de: {name}",
"account.follow": "Siguir",
"account.followers": "Siguidores",
"account.followers.empty": "Naide sigue a esti perfil.",
"account.followers_counter": "{count, plural, one {{counter} Siguíu} other {{counter} Siguíos}}",
"account.following": "Siguiendo",
"account.following_counter": "{count, plural,one {Sigue a {counter}} other {Sigue a {counter}}}",
"account.follows.empty": "Esti perfil nun sigue a naide.",
"account.follows_you": "Síguete",
"account.go_to_profile": "Dir al perfil",
"account.hide_reblogs": "Anubrir los artículos compartíos de @{name}",
"account.in_memoriam": "N'alcordanza.",
"account.joined_short": "Data de xunión",
"account.languages": "Camudar llingües suscrites",
"account.link_verified_on": "La propiedá d'esti enllaz foi comprobada'l {date}",
"account.media": "Multimedia",
"account.mention": "Mentar a @{name}",
"account.moved_to": "{name} indicó qu'agora la so cuenta nueva ye:",
Expand Down
Loading

0 comments on commit c5e4020

Please sign in to comment.