Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `app/serializers/rest/instance_serializer.rb`:
  Upstream changed the fields returned by /api/v1/instance by adding a
  `configuration` field holding a lot of useful information making our
  `max_toot_chars` and `poll_limits` fields obsolete.
  Keeping those around for now for compatibility.
- `app/validators/status_length_validator.rb`:
  No real conflict, just URL_PLACEHOLDER_CHARS introduced too close to
  MAX_CHARS which is defined differently in glitch-soc.
  Ported upstream changes.
This commit is contained in:
Claire 2021-07-11 21:41:23 +02:00
commit cdf20f4367
12 changed files with 60 additions and 15 deletions

View File

@ -1 +1 @@
2.7.2 2.7.4

View File

@ -26,7 +26,7 @@ RUN ARCH= && \
mv node-v$NODE_VER-linux-$ARCH /opt/node mv node-v$NODE_VER-linux-$ARCH /opt/node
# Install Ruby # Install Ruby
ENV RUBY_VER="2.7.2" ENV RUBY_VER="2.7.4"
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential \ apt-get install -y --no-install-recommends build-essential \
bison libyaml-dev libgdbm-dev libreadline-dev libjemalloc-dev \ bison libyaml-dev libgdbm-dev libreadline-dev libjemalloc-dev \

View File

@ -157,5 +157,3 @@ gem 'concurrent-ruby', require: false
gem 'connection_pool', require: false gem 'connection_pool', require: false
gem 'xorcist', '~> 1.1' gem 'xorcist', '~> 1.1'
gem 'resolv', '~> 0.1.0'

View File

@ -492,7 +492,6 @@ GEM
regexp_parser (2.1.1) regexp_parser (2.1.1)
request_store (1.5.0) request_store (1.5.0)
rack (>= 1.4) rack (>= 1.4)
resolv (0.1.0)
responders (3.0.1) responders (3.0.1)
actionpack (>= 5.0) actionpack (>= 5.0)
railties (>= 5.0) railties (>= 5.0)
@ -525,7 +524,7 @@ GEM
rspec-support (3.10.2) rspec-support (3.10.2)
rspec_junit_formatter (0.4.1) rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0) rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.18.2) rubocop (1.18.3)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.0.0.0) parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
@ -766,7 +765,6 @@ DEPENDENCIES
redcarpet (~> 3.5) redcarpet (~> 3.5)
redis (~> 4.3) redis (~> 4.3)
redis-namespace (~> 1.8) redis-namespace (~> 1.8)
resolv (~> 0.1.0)
rqrcode (~> 2.0) rqrcode (~> 2.0)
rspec-rails (~> 5.0) rspec-rails (~> 5.0)
rspec-sidekiq (~> 3.1) rspec-sidekiq (~> 3.1)

View File

@ -6,6 +6,7 @@ class ReportFilter
account_id account_id
target_account_id target_account_id
by_target_domain by_target_domain
target_origin
).freeze ).freeze
attr_reader :params attr_reader :params
@ -34,8 +35,21 @@ class ReportFilter
Report.where(account_id: value) Report.where(account_id: value)
when :target_account_id when :target_account_id
Report.where(target_account_id: value) Report.where(target_account_id: value)
when :target_origin
target_origin_scope(value)
else else
raise "Unknown filter: #{key}" raise "Unknown filter: #{key}"
end end
end end
def target_origin_scope(value)
case value.to_sym
when :local
Report.where(target_account: Account.local)
when :remote
Report.where(target_account: Account.remote)
else
raise "Unknown value: #{value}"
end
end
end end

View File

@ -5,7 +5,8 @@ class REST::InstanceSerializer < ActiveModel::Serializer
attributes :uri, :title, :short_description, :description, :email, attributes :uri, :title, :short_description, :description, :email,
:version, :urls, :stats, :thumbnail, :max_toot_chars, :poll_limits, :version, :urls, :stats, :thumbnail, :max_toot_chars, :poll_limits,
:languages, :registrations, :approval_required, :invites_enabled :languages, :registrations, :approval_required, :invites_enabled,
:configuration
has_one :contact_account, serializer: REST::AccountSerializer has_one :contact_account, serializer: REST::AccountSerializer
@ -66,6 +67,32 @@ class REST::InstanceSerializer < ActiveModel::Serializer
{ streaming_api: Rails.configuration.x.streaming_api_base_url } { streaming_api: Rails.configuration.x.streaming_api_base_url }
end end
def configuration
{
statuses: {
max_characters: StatusLengthValidator::MAX_CHARS,
max_media_attachments: 4,
characters_reserved_per_url: StatusLengthValidator::URL_PLACEHOLDER_CHARS,
},
media_attachments: {
supported_mime_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES + MediaAttachment::AUDIO_MIME_TYPES,
image_size_limit: MediaAttachment::IMAGE_LIMIT,
image_matrix_limit: Attachmentable::MAX_MATRIX_LIMIT,
video_size_limit: MediaAttachment::VIDEO_LIMIT,
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
},
polls: {
max_options: PollValidator::MAX_OPTIONS,
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
min_expiration: PollValidator::MIN_EXPIRATION,
max_expiration: PollValidator::MAX_EXPIRATION,
},
}
end
def languages def languages
[I18n.default_locale] [I18n.default_locale]
end end

View File

@ -2,7 +2,8 @@
class StatusLengthValidator < ActiveModel::Validator class StatusLengthValidator < ActiveModel::Validator
MAX_CHARS = (ENV['MAX_TOOT_CHARS'] || 500).to_i MAX_CHARS = (ENV['MAX_TOOT_CHARS'] || 500).to_i
URL_PLACEHOLDER = "\1#{'x' * 23}" URL_PLACEHOLDER_CHARS = 23
URL_PLACEHOLDER = "\1#{'x' * URL_PLACEHOLDER_CHARS}"
def validate(status) def validate(status)
return unless status.local? && !status.reblog? return unless status.local? && !status.reblog?

View File

@ -7,6 +7,12 @@
%ul %ul
%li= filter_link_to t('admin.reports.unresolved'), resolved: nil %li= filter_link_to t('admin.reports.unresolved'), resolved: nil
%li= filter_link_to t('admin.reports.resolved'), resolved: '1' %li= filter_link_to t('admin.reports.resolved'), resolved: '1'
.filter-subset
%strong= t('admin.reports.target_origin')
%ul
%li= filter_link_to t('admin.accounts.location.all'), target_origin: nil
%li= filter_link_to t('admin.accounts.location.local'), target_origin: 'local'
%li= filter_link_to t('admin.accounts.location.remote'), target_origin: 'remote'
= form_tag admin_reports_url, method: 'GET', class: 'simple_form' do = form_tag admin_reports_url, method: 'GET', class: 'simple_form' do
.fields-group .fields-group

View File

@ -579,6 +579,7 @@ en:
resolved: Resolved resolved: Resolved
resolved_msg: Report successfully resolved! resolved_msg: Report successfully resolved!
status: Status status: Status
target_origin: Origin of reported account
title: Reports title: Reports
unassign: Unassign unassign: Unassign
unresolved: Unresolved unresolved: Unresolved

View File

@ -14,7 +14,7 @@ services:
redis: redis:
restart: always restart: always
image: redis:6.0-alpine image: redis:6-alpine
networks: networks:
- internal_network - internal_network
healthcheck: healthcheck:

View File

@ -154,7 +154,7 @@
"requestidlecallback": "^0.3.0", "requestidlecallback": "^0.3.0",
"reselect": "^4.0.0", "reselect": "^4.0.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sass": "^1.35.1", "sass": "^1.35.2",
"sass-loader": "^10.2.0", "sass-loader": "^10.2.0",
"stacktrace-js": "^2.0.2", "stacktrace-js": "^2.0.2",
"stringz": "^2.1.0", "stringz": "^2.1.0",

View File

@ -9821,10 +9821,10 @@ sass-loader@^10.2.0:
schema-utils "^3.0.0" schema-utils "^3.0.0"
semver "^7.3.2" semver "^7.3.2"
sass@^1.35.1: sass@^1.35.2:
version "1.35.1" version "1.35.2"
resolved "https://registry.yarnpkg.com/sass/-/sass-1.35.1.tgz#90ecf774dfe68f07b6193077e3b42fb154b9e1cd" resolved "https://registry.yarnpkg.com/sass/-/sass-1.35.2.tgz#b732314fcdaf7ef8d0f1698698adc378043cb821"
integrity sha512-oCisuQJstxMcacOPmxLNiLlj4cUyN2+8xJnG7VanRoh2GOLr9RqkvI4AxA4a6LHVg/rsu+PmxXeGhrdSF9jCiQ== integrity sha512-jhO5KAR+AMxCEwIH3v+4zbB2WB0z67V1X0jbapfVwQQdjHZUGUyukpnoM6+iCMfsIUC016w9OPKQ5jrNOS9uXw==
dependencies: dependencies:
chokidar ">=3.0.0 <4.0.0" chokidar ">=3.0.0 <4.0.0"