Skip to content

Commit 4213946

Browse files
authored
Merge branch 'mastodon:main' into main
2 parents 9ab3adc + 12cb6ed commit 4213946

File tree

13 files changed

+367
-379
lines changed

13 files changed

+367
-379
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN echo "Etc/UTC" > /etc/localtime && \
1717
ENV PATH="/opt/ruby/bin:/opt/node/bin:/opt/mastodon/bin:${PATH}"
1818

1919
# Install Node v14 (LTS)
20-
ENV NODE_VER="14.17.4"
20+
ENV NODE_VER="14.17.6"
2121
RUN ARCH= && \
2222
dpkgArch="$(dpkg --print-architecture)" && \
2323
case "${dpkgArch##*-}" in \

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ gem 'makara', '~> 0.5'
1717
gem 'pghero', '~> 2.8'
1818
gem 'dotenv-rails', '~> 2.7'
1919

20-
gem 'aws-sdk-s3', '~> 1.100', require: false
20+
gem 'aws-sdk-s3', '~> 1.102', require: false
2121
gem 'fog-core', '<= 2.1.0'
2222
gem 'fog-openstack', '~> 0.3', require: false
2323
gem 'paperclip', '~> 6.0'

Gemfile.lock

+15-14
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,21 @@ GEM
8080
encryptor (~> 3.0.0)
8181
attr_required (1.0.1)
8282
awrence (1.1.1)
83-
aws-eventstream (1.1.1)
84-
aws-partitions (1.492.0)
85-
aws-sdk-core (3.119.1)
83+
aws-eventstream (1.2.0)
84+
aws-partitions (1.496.0)
85+
aws-sdk-core (3.121.0)
8686
aws-eventstream (~> 1, >= 1.0.2)
8787
aws-partitions (~> 1, >= 1.239.0)
8888
aws-sigv4 (~> 1.1)
8989
jmespath (~> 1.0)
90-
aws-sdk-kms (1.47.0)
91-
aws-sdk-core (~> 3, >= 3.119.0)
90+
aws-sdk-kms (1.48.0)
91+
aws-sdk-core (~> 3, >= 3.120.0)
9292
aws-sigv4 (~> 1.1)
93-
aws-sdk-s3 (1.100.0)
94-
aws-sdk-core (~> 3, >= 3.119.0)
93+
aws-sdk-s3 (1.102.0)
94+
aws-sdk-core (~> 3, >= 3.120.0)
9595
aws-sdk-kms (~> 1)
96-
aws-sigv4 (~> 1.1)
97-
aws-sigv4 (1.2.4)
96+
aws-sigv4 (~> 1.4)
97+
aws-sigv4 (1.4.0)
9898
aws-eventstream (~> 1, >= 1.0.2)
9999
bcrypt (3.1.16)
100100
better_errors (2.9.1)
@@ -175,7 +175,7 @@ GEM
175175
railties (>= 4.1.0)
176176
responders
177177
warden (~> 1.2.3)
178-
devise-two-factor (4.0.0)
178+
devise-two-factor (4.0.1)
179179
activesupport (< 6.2)
180180
attr_encrypted (>= 1.3, < 4, != 2)
181181
devise (~> 4.0)
@@ -384,7 +384,7 @@ GEM
384384
concurrent-ruby (~> 1.0, >= 1.0.2)
385385
sidekiq (>= 3.5)
386386
statsd-ruby (~> 1.4, >= 1.4.0)
387-
oj (3.13.2)
387+
oj (3.13.4)
388388
omniauth (1.9.1)
389389
hashie (>= 3.4.6)
390390
rack (>= 1.6.2, < 3)
@@ -565,8 +565,9 @@ GEM
565565
rack (>= 1.1)
566566
rubocop (>= 1.7.0, < 2.0)
567567
ruby-progressbar (1.11.0)
568-
ruby-saml (1.11.0)
569-
nokogiri (>= 1.5.10)
568+
ruby-saml (1.13.0)
569+
nokogiri (>= 1.10.5)
570+
rexml
570571
ruby2_keywords (0.0.4)
571572
rufus-scheduler (3.7.0)
572573
fugit (~> 1.1, >= 1.1.6)
@@ -712,7 +713,7 @@ DEPENDENCIES
712713
active_record_query_trace (~> 1.8)
713714
addressable (~> 2.8)
714715
annotate (~> 3.1)
715-
aws-sdk-s3 (~> 1.100)
716+
aws-sdk-s3 (~> 1.102)
716717
better_errors (~> 2.9)
717718
binding_of_caller (~> 1.0)
718719
blurhash (~> 0.1)

app/lib/activitypub/tag_manager.rb

+15-11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def replies_uri_for(target, page_params = nil)
6464
account_status_replies_url(target.account, target, page_params)
6565
end
6666

67+
def followers_uri_for(target)
68+
target.local? ? account_followers_url(target) : target.followers_url.presence
69+
end
70+
6771
# Primary audience of a status
6872
# Public statuses go out to primarily the public collection
6973
# Unlisted and private statuses go out primarily to the followers collection
@@ -80,17 +84,17 @@ def to(status)
8084
account_ids = status.active_mentions.pluck(:account_id)
8185
to = status.account.followers.where(id: account_ids).each_with_object([]) do |account, result|
8286
result << uri_for(account)
83-
result << account_followers_url(account) if account.group?
87+
result << followers_uri_for(account) if account.group?
8488
end
8589
to.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).each_with_object([]) do |request, result|
8690
result << uri_for(request.account)
87-
result << account_followers_url(request.account) if request.account.group?
88-
end)
91+
result << followers_uri_for(request.account) if request.account.group?
92+
end).compact
8993
else
9094
status.active_mentions.each_with_object([]) do |mention, result|
9195
result << uri_for(mention.account)
92-
result << account_followers_url(mention.account) if mention.account.group?
93-
end
96+
result << followers_uri_for(mention.account) if mention.account.group?
97+
end.compact
9498
end
9599
end
96100
end
@@ -118,17 +122,17 @@ def cc(status)
118122
account_ids = status.active_mentions.pluck(:account_id)
119123
cc.concat(status.account.followers.where(id: account_ids).each_with_object([]) do |account, result|
120124
result << uri_for(account)
121-
result << account_followers_url(account) if account.group?
122-
end)
125+
result << followers_uri_for(account) if account.group?
126+
end.compact)
123127
cc.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).each_with_object([]) do |request, result|
124128
result << uri_for(request.account)
125-
result << account_followers_url(request.account) if request.account.group?
126-
end)
129+
result << followers_uri_for(request.account) if request.account.group?
130+
end.compact)
127131
else
128132
cc.concat(status.active_mentions.each_with_object([]) do |mention, result|
129133
result << uri_for(mention.account)
130-
result << account_followers_url(mention.account) if mention.account.group?
131-
end)
134+
result << followers_uri_for(mention.account) if mention.account.group?
135+
end.compact)
132136
end
133137
end
134138

app/models/media_attachment.rb

+2-9
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def delay_processing_for_attachment?(attachment_name)
255255
after_commit :reset_parent_cache, on: :update
256256

257257
before_create :prepare_description, unless: :local?
258-
before_create :set_shortcode
258+
before_create :set_unknown_type
259259
before_create :set_processing
260260

261261
after_post_process :set_meta
@@ -298,15 +298,8 @@ def file_processors(instance)
298298

299299
private
300300

301-
def set_shortcode
301+
def set_unknown_type
302302
self.type = :unknown if file.blank? && !type_changed?
303-
304-
return unless local?
305-
306-
loop do
307-
self.shortcode = SecureRandom.urlsafe_base64(14)
308-
break if MediaAttachment.find_by(shortcode: shortcode).nil?
309-
end
310303
end
311304

312305
def prepare_description

app/serializers/manifest_serializer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def start_url
4848
end
4949

5050
def scope
51-
root_url
51+
'/'
5252
end
5353

5454
def share_target

app/serializers/rest/media_attachment_serializer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def preview_remote_url
4040
end
4141

4242
def text_url
43-
object.local? ? medium_url(object) : nil
43+
object.local? && object.shortcode.present? ? medium_url(object) : nil
4444
end
4545

4646
def meta

app/views/notification_mailer/_status.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
%p
3838
- status.media_attachments.each do |a|
3939
- if status.local?
40-
= link_to medium_url(a), medium_url(a)
40+
= link_to full_asset_url(a.file.url(:original)), full_asset_url(a.file.url(:original))
4141
- else
4242
= link_to a.remote_url, a.remote_url
4343

config/application.rb

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
require_relative 'boot'
22

3-
require 'rails/all'
3+
require 'rails'
4+
5+
require 'active_record/railtie'
6+
#require 'active_storage/engine'
7+
require 'action_controller/railtie'
8+
require 'action_view/railtie'
9+
require 'action_mailer/railtie'
10+
require 'active_job/railtie'
11+
#require 'action_cable/engine'
12+
#require 'action_mailbox/engine'
13+
#require 'action_text/engine'
14+
#require 'rails/test_unit/railtie'
15+
require 'sprockets/railtie'
16+
17+
# Used to be implicitly required in action_mailbox/engine
18+
require 'mail'
419

520
# Require the gems listed in Gemfile, including any gems
621
# you've limited to :test, :development, or :production.

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@
6060
},
6161
"private": true,
6262
"dependencies": {
63-
"@babel/core": "^7.15.0",
64-
"@babel/plugin-proposal-decorators": "^7.14.5",
63+
"@babel/core": "^7.15.5",
64+
"@babel/plugin-proposal-decorators": "^7.15.4",
6565
"@babel/plugin-transform-react-inline-elements": "^7.14.5",
6666
"@babel/plugin-transform-runtime": "^7.15.0",
67-
"@babel/preset-env": "^7.15.0",
67+
"@babel/preset-env": "^7.15.4",
6868
"@babel/preset-react": "^7.14.5",
69-
"@babel/runtime": "^7.15.3",
69+
"@babel/runtime": "^7.15.4",
7070
"@gamestdio/websocket": "^0.3.2",
7171
"@github/webauthn-json": "^0.5.7",
7272
"@rails/ujs": "^6.1.4",
7373
"array-includes": "^3.1.3",
7474
"arrow-key-navigation": "^1.2.0",
7575
"autoprefixer": "^9.8.6",
76-
"axios": "^0.21.1",
76+
"axios": "^0.21.4",
7777
"babel-loader": "^8.2.2",
7878
"babel-plugin-lodash": "^3.3.4",
7979
"babel-plugin-preval": "^5.0.0",
@@ -112,7 +112,7 @@
112112
"marky": "^1.2.2",
113113
"mini-css-extract-plugin": "^1.6.2",
114114
"mkdirp": "^1.0.4",
115-
"npmlog": "^5.0.0",
115+
"npmlog": "^5.0.1",
116116
"object-assign": "^4.1.1",
117117
"object-fit-images": "^3.2.3",
118118
"object.values": "^1.1.3",
@@ -134,7 +134,7 @@
134134
"react-motion": "^0.5.2",
135135
"react-notification": "^6.8.5",
136136
"react-overlays": "^0.9.3",
137-
"react-redux": "^7.2.4",
137+
"react-redux": "^7.2.5",
138138
"react-redux-loading-bar": "^4.0.8",
139139
"react-router-dom": "^4.1.1",
140140
"react-router-scroll-4": "^1.0.0-beta.1",
@@ -152,7 +152,7 @@
152152
"requestidlecallback": "^0.3.0",
153153
"reselect": "^4.0.0",
154154
"rimraf": "^3.0.2",
155-
"sass": "^1.38.2",
155+
"sass": "^1.39.0",
156156
"sass-loader": "^10.2.0",
157157
"stacktrace-js": "^2.0.2",
158158
"stringz": "^2.1.0",

spec/controllers/media_controller_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
describe '#show' do
99
it 'redirects to the file url when attached to a status' do
1010
status = Fabricate(:status)
11-
media_attachment = Fabricate(:media_attachment, status: status)
11+
media_attachment = Fabricate(:media_attachment, status: status, shortcode: 'foo')
1212
get :show, params: { id: media_attachment.to_param }
1313

1414
expect(response).to redirect_to(media_attachment.file.url(:original))
1515
end
1616

1717
it 'responds with missing when there is not an attached status' do
18-
media_attachment = Fabricate(:media_attachment, status: nil)
18+
media_attachment = Fabricate(:media_attachment, status: nil, shortcode: 'foo')
1919
get :show, params: { id: media_attachment.to_param }
2020

2121
expect(response).to have_http_status(404)
@@ -29,7 +29,7 @@
2929

3030
it 'raises when not permitted to view' do
3131
status = Fabricate(:status, visibility: :direct)
32-
media_attachment = Fabricate(:media_attachment, status: status)
32+
media_attachment = Fabricate(:media_attachment, status: status, shortcode: 'foo')
3333
get :show, params: { id: media_attachment.to_param }
3434

3535
expect(response).to have_http_status(404)

spec/lib/activitypub/tag_manager_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
expect(subject.to(status)).to eq [subject.uri_for(mentioned)]
4343
end
4444

45+
it "returns URIs of mentioned group's followers for direct statuses to groups" do
46+
status = Fabricate(:status, visibility: :direct)
47+
mentioned = Fabricate(:account, domain: 'remote.org', uri: 'https://remote.org/group', followers_url: 'https://remote.org/group/followers', actor_type: 'Group')
48+
status.mentions.create(account: mentioned)
49+
expect(subject.to(status)).to include(subject.uri_for(mentioned))
50+
expect(subject.to(status)).to include(subject.followers_uri_for(mentioned))
51+
end
52+
4553
it "returns URIs of mentions for direct silenced author's status only if they are followers or requesting to be" do
4654
bob = Fabricate(:account, username: 'bob')
4755
alice = Fabricate(:account, username: 'alice')

0 commit comments

Comments
 (0)