Skip to content

Commit ccdde93

Browse files
committed
Merge remote-tracking branch 'parent/main' into upstream-20251202
2 parents e25c139 + 6074493 commit ccdde93

File tree

211 files changed

+3587
-1393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+3587
-1393
lines changed

.storybook/preview-body.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<html class="no-reduce-motion">
1+
<html class="no-reduce-motion theme-light">
22
</html>

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ group :opentelemetry do
114114
gem 'opentelemetry-instrumentation-http', '~> 0.27.0', require: false
115115
gem 'opentelemetry-instrumentation-http_client', '~> 0.26.0', require: false
116116
gem 'opentelemetry-instrumentation-net_http', '~> 0.26.0', require: false
117-
gem 'opentelemetry-instrumentation-pg', '~> 0.33.0', require: false
117+
gem 'opentelemetry-instrumentation-pg', '~> 0.34.0', require: false
118118
gem 'opentelemetry-instrumentation-rack', '~> 0.29.0', require: false
119119
gem 'opentelemetry-instrumentation-rails', '~> 0.39.0', require: false
120120
gem 'opentelemetry-instrumentation-redis', '~> 0.28.0', require: false

Gemfile.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ GEM
9696
ast (2.4.3)
9797
attr_required (1.0.2)
9898
aws-eventstream (1.4.0)
99-
aws-partitions (1.1186.0)
99+
aws-partitions (1.1190.0)
100100
aws-sdk-core (3.239.2)
101101
aws-eventstream (~> 1, >= 1.3.0)
102102
aws-partitions (~> 1, >= 1.992.0)
@@ -105,10 +105,10 @@ GEM
105105
bigdecimal
106106
jmespath (~> 1, >= 1.6.1)
107107
logger
108-
aws-sdk-kms (1.117.0)
109-
aws-sdk-core (~> 3, >= 3.234.0)
108+
aws-sdk-kms (1.118.0)
109+
aws-sdk-core (~> 3, >= 3.239.1)
110110
aws-sigv4 (~> 1.5)
111-
aws-sdk-s3 (1.205.0)
111+
aws-sdk-s3 (1.206.0)
112112
aws-sdk-core (~> 3, >= 3.234.0)
113113
aws-sdk-kms (~> 1)
114114
aws-sigv4 (~> 1.5)
@@ -135,8 +135,8 @@ GEM
135135
racc
136136
browser (6.2.0)
137137
builder (3.3.0)
138-
bundler-audit (0.9.2)
139-
bundler (>= 1.2.0, < 3)
138+
bundler-audit (0.9.3)
139+
bundler (>= 1.2.0)
140140
thor (~> 1.0)
141141
capybara (3.40.0)
142142
addressable
@@ -234,7 +234,7 @@ GEM
234234
excon (1.3.0)
235235
logger
236236
fabrication (3.0.0)
237-
faker (3.5.2)
237+
faker (3.5.3)
238238
i18n (>= 1.8.11, < 2)
239239
faraday (2.14.0)
240240
faraday-net_http (>= 2.0, < 3.5)
@@ -518,7 +518,7 @@ GEM
518518
opentelemetry-semantic_conventions
519519
opentelemetry-helpers-sql (0.3.0)
520520
opentelemetry-api (~> 1.7)
521-
opentelemetry-helpers-sql-obfuscation (0.5.0)
521+
opentelemetry-helpers-sql-processor (0.3.1)
522522
opentelemetry-common (~> 0.21)
523523
opentelemetry-instrumentation-action_mailer (0.6.1)
524524
opentelemetry-instrumentation-active_support (~> 0.10)
@@ -552,9 +552,9 @@ GEM
552552
opentelemetry-instrumentation-base (~> 0.25)
553553
opentelemetry-instrumentation-net_http (0.26.1)
554554
opentelemetry-instrumentation-base (~> 0.25)
555-
opentelemetry-instrumentation-pg (0.33.0)
555+
opentelemetry-instrumentation-pg (0.34.1)
556556
opentelemetry-helpers-sql
557-
opentelemetry-helpers-sql-obfuscation
557+
opentelemetry-helpers-sql-processor
558558
opentelemetry-instrumentation-base (~> 0.25)
559559
opentelemetry-instrumentation-rack (0.29.0)
560560
opentelemetry-instrumentation-base (~> 0.25)
@@ -569,7 +569,7 @@ GEM
569569
opentelemetry-instrumentation-concurrent_ruby (~> 0.23)
570570
opentelemetry-instrumentation-redis (0.28.0)
571571
opentelemetry-instrumentation-base (~> 0.25)
572-
opentelemetry-instrumentation-sidekiq (0.28.0)
572+
opentelemetry-instrumentation-sidekiq (0.28.1)
573573
opentelemetry-instrumentation-base (~> 0.25)
574574
opentelemetry-registry (0.4.0)
575575
opentelemetry-api (~> 1.1)
@@ -809,7 +809,7 @@ GEM
809809
securerandom (0.4.1)
810810
shoulda-matchers (7.0.1)
811811
activesupport (>= 7.1)
812-
sidekiq (8.0.9)
812+
sidekiq (8.0.10)
813813
connection_pool (>= 2.5.0)
814814
json (>= 2.9.0)
815815
logger (>= 1.6.2)
@@ -1022,7 +1022,7 @@ DEPENDENCIES
10221022
opentelemetry-instrumentation-http (~> 0.27.0)
10231023
opentelemetry-instrumentation-http_client (~> 0.26.0)
10241024
opentelemetry-instrumentation-net_http (~> 0.26.0)
1025-
opentelemetry-instrumentation-pg (~> 0.33.0)
1025+
opentelemetry-instrumentation-pg (~> 0.34.0)
10261026
opentelemetry-instrumentation-rack (~> 0.29.0)
10271027
opentelemetry-instrumentation-rails (~> 0.39.0)
10281028
opentelemetry-instrumentation-redis (~> 0.28.0)

app/controllers/activitypub/likes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def pundit_user
2222
def set_status
2323
@status = @account.statuses.find(params[:status_id])
2424
authorize @status, :show?
25-
rescue Mastodon::NotPermittedError
25+
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
2626
not_found
2727
end
2828

app/controllers/activitypub/quote_authorizations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def set_quote_authorization
2424
return not_found unless @quote.status.present? && @quote.quoted_status.present?
2525

2626
authorize @quote.quoted_status, :show?
27-
rescue Mastodon::NotPermittedError
27+
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
2828
not_found
2929
end
3030
end

app/controllers/activitypub/replies_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def pundit_user
2525
def set_status
2626
@status = @account.statuses.find(params[:status_id])
2727
authorize @status, :show?
28-
rescue Mastodon::NotPermittedError
28+
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
2929
not_found
3030
end
3131

app/controllers/activitypub/shares_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def pundit_user
2222
def set_status
2323
@status = @account.statuses.find(params[:status_id])
2424
authorize @status, :show?
25-
rescue Mastodon::NotPermittedError
25+
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
2626
not_found
2727
end
2828

app/controllers/api/v1/annual_reports_controller.rb

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# frozen_string_literal: true
22

33
class Api::V1::AnnualReportsController < Api::BaseController
4-
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }, only: :index
5-
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, except: :index
4+
include AsyncRefreshesConcern
5+
6+
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }, except: [:read, :generate]
7+
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: [:read, :generate]
68
before_action :require_user!
7-
before_action :set_annual_report, except: :index
9+
before_action :set_annual_report, only: [:show, :read]
810

911
def index
1012
with_read_replica do
@@ -28,14 +30,59 @@ def show
2830
relationships: @relationships
2931
end
3032

33+
def state
34+
render json: { state: report_state }
35+
end
36+
37+
def generate
38+
return render_empty unless year == AnnualReport.current_campaign
39+
return render_empty if GeneratedAnnualReport.exists?(account_id: current_account.id, year: year)
40+
41+
async_refresh = AsyncRefresh.new(refresh_key)
42+
43+
if async_refresh.running?
44+
add_async_refresh_header(async_refresh, retry_seconds: 2)
45+
return head 202
46+
end
47+
48+
add_async_refresh_header(AsyncRefresh.create(refresh_key), retry_seconds: 2)
49+
50+
GenerateAnnualReportWorker.perform_async(current_account.id, year)
51+
52+
head 202
53+
end
54+
3155
def read
3256
@annual_report.view!
3357
render_empty
3458
end
3559

60+
def refresh_key
61+
"wrapstodon:#{current_account.id}:#{year}"
62+
end
63+
3664
private
3765

66+
def report_state
67+
return 'available' if GeneratedAnnualReport.exists?(account_id: current_account.id, year: year)
68+
69+
async_refresh = AsyncRefresh.new(refresh_key)
70+
71+
if async_refresh.running?
72+
add_async_refresh_header(async_refresh, retry_seconds: 2)
73+
'generating'
74+
elsif AnnualReport.current_campaign == year && AnnualReport.new(current_account, year).eligible?
75+
'eligible'
76+
else
77+
'ineligible'
78+
end
79+
end
80+
81+
def year
82+
params[:id]&.to_i
83+
end
84+
3885
def set_annual_report
39-
@annual_report = GeneratedAnnualReport.find_by!(account_id: current_account.id, year: params[:id])
86+
@annual_report = GeneratedAnnualReport.find_by!(account_id: current_account.id, year: year)
4087
end
4188
end

app/controllers/api/v1/polls/votes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def create
1717
def set_poll
1818
@poll = Poll.find(params[:poll_id])
1919
authorize @poll.status, :show?
20-
rescue Mastodon::NotPermittedError
20+
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
2121
not_found
2222
end
2323

app/controllers/api/v1/polls_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def show
1717
def set_poll
1818
@poll = Poll.find(params[:id])
1919
authorize @poll.status, :show?
20-
rescue Mastodon::NotPermittedError
20+
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
2121
not_found
2222
end
2323

0 commit comments

Comments
 (0)