Skip to content

Commit

Permalink
Merge commit '20c749bd45286fbf0aca5610562e5dc6f2c616dd' into glitch-s…
Browse files Browse the repository at this point in the history
…oc/merge-upstream
  • Loading branch information
ClearlyClaire committed Jul 3, 2024
2 parents 71375e9 + 20c749b commit 3026757
Show file tree
Hide file tree
Showing 17 changed files with 299 additions and 30 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ gem 'ruby-vips', '~> 2.2', require: false
gem 'active_model_serializers', '~> 0.10'
gem 'addressable', '~> 2.8'
gem 'bootsnap', '~> 1.18.0', require: false
gem 'browser'
gem 'browser', '< 6' # https://github.com/fnando/browser/issues/543
gem 'charlock_holmes', '~> 0.7.7'
gem 'chewy', '~> 7.3'
gem 'devise', '~> 4.9'
Expand Down Expand Up @@ -114,7 +114,7 @@ group :opentelemetry do
gem 'opentelemetry-instrumentation-net_http', '~> 0.22.4', require: false
gem 'opentelemetry-instrumentation-pg', '~> 0.27.1', require: false
gem 'opentelemetry-instrumentation-rack', '~> 0.24.1', require: false
gem 'opentelemetry-instrumentation-rails', '~> 0.30.0', require: false
gem 'opentelemetry-instrumentation-rails', '~> 0.31.0', require: false
gem 'opentelemetry-instrumentation-redis', '~> 0.25.3', require: false
gem 'opentelemetry-instrumentation-sidekiq', '~> 0.25.2', require: false
gem 'opentelemetry-sdk', '~> 1.4', require: false
Expand Down Expand Up @@ -229,3 +229,4 @@ gem 'rubyzip', '~> 2.3'
gem 'hcaptcha', '~> 7.1'

gem 'mail', '~> 2.8'
gem 'prism'
38 changes: 20 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ GEM
attr_required (1.0.2)
awrence (1.2.1)
aws-eventstream (1.3.0)
aws-partitions (1.949.0)
aws-sdk-core (3.200.0)
aws-partitions (1.950.0)
aws-sdk-core (3.201.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.87.0)
aws-sdk-core (~> 3, >= 3.199.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.155.0)
aws-sdk-core (~> 3, >= 3.199.0)
aws-sdk-kms (1.88.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.156.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
azure-storage-blob (2.0.3)
Expand Down Expand Up @@ -208,7 +208,7 @@ GEM
activerecord (>= 4.2, < 8)
docile (1.4.0)
domain_name (0.6.20240107)
doorkeeper (5.6.9)
doorkeeper (5.7.1)
railties (>= 5)
dotenv (3.1.2)
drb (2.2.1)
Expand Down Expand Up @@ -431,7 +431,7 @@ GEM
mime-types-data (3.2024.0604)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.23.1)
minitest (5.24.1)
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.4.0)
Expand Down Expand Up @@ -516,7 +516,7 @@ GEM
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-active_support (~> 0.1)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-active_job (0.7.1)
opentelemetry-instrumentation-active_job (0.7.2)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-active_model_serializers (0.20.1)
Expand All @@ -525,7 +525,7 @@ GEM
opentelemetry-instrumentation-active_record (0.7.2)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-active_support (0.5.1)
opentelemetry-instrumentation-active_support (0.6.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-base (0.22.3)
Expand Down Expand Up @@ -556,19 +556,19 @@ GEM
opentelemetry-instrumentation-rack (0.24.5)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-rails (0.30.2)
opentelemetry-instrumentation-rails (0.31.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-action_mailer (~> 0.1.0)
opentelemetry-instrumentation-action_pack (~> 0.9.0)
opentelemetry-instrumentation-action_view (~> 0.7.0)
opentelemetry-instrumentation-active_job (~> 0.7.0)
opentelemetry-instrumentation-active_record (~> 0.7.0)
opentelemetry-instrumentation-active_support (~> 0.5.0)
opentelemetry-instrumentation-active_support (~> 0.6.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-redis (0.25.6)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-sidekiq (0.25.5)
opentelemetry-instrumentation-sidekiq (0.25.6)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-registry (0.3.1)
Expand Down Expand Up @@ -600,6 +600,7 @@ GEM
actionmailer (>= 3)
net-smtp
premailer (~> 1.7, >= 1.7.9)
prism (0.30.0)
propshaft (0.9.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
Expand Down Expand Up @@ -756,7 +757,7 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.0.1)
rubocop-rspec (3.0.2)
rubocop (~> 1.61)
rubocop-rspec_rails (2.30.0)
rubocop (~> 1.61)
Expand Down Expand Up @@ -916,7 +917,7 @@ DEPENDENCIES
blurhash (~> 0.1)
bootsnap (~> 1.18.0)
brakeman (~> 6.0)
browser
browser (< 6)
bundler-audit (~> 0.9)
capybara (~> 3.39)
charlock_holmes (~> 0.7.7)
Expand Down Expand Up @@ -994,7 +995,7 @@ DEPENDENCIES
opentelemetry-instrumentation-net_http (~> 0.22.4)
opentelemetry-instrumentation-pg (~> 0.27.1)
opentelemetry-instrumentation-rack (~> 0.24.1)
opentelemetry-instrumentation-rails (~> 0.30.0)
opentelemetry-instrumentation-rails (~> 0.31.0)
opentelemetry-instrumentation-redis (~> 0.25.3)
opentelemetry-instrumentation-sidekiq (~> 0.25.2)
opentelemetry-sdk (~> 1.4)
Expand All @@ -1003,6 +1004,7 @@ DEPENDENCIES
pg (~> 1.5)
pghero
premailer-rails
prism
propshaft
public_suffix (~> 6.0)
puma (~> 6.3)
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/mastodon/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"account.follow_back": "Follow back",
"account.followers": "Followers",
"account.followers.empty": "No one follows this user yet.",
"account.followers_counter": "{count, plural, one {{counter} follower} other {{counter} followers}}",
"account.following": "Following",
"account.following_counter": "{count, plural, one {{counter} following} other {{counter} following}}",
"account.follows.empty": "This user doesn't follow anyone yet.",
"account.go_to_profile": "Go to profile",
"account.hide_reblogs": "Hide boosts from @{name}",
Expand All @@ -61,6 +63,7 @@
"account.requested_follow": "{name} has requested to follow you",
"account.share": "Share @{name}'s profile",
"account.show_reblogs": "Show boosts from @{name}",
"account.statuses_counter": "{count, plural, one {{counter} post} other {{counter} posts}}",
"account.unblock": "Unblock @{name}",
"account.unblock_domain": "Unblock domain {domain}",
"account.unblock_short": "Unblock",
Expand Down Expand Up @@ -411,6 +414,8 @@
"limited_account_hint.action": "Show profile anyway",
"limited_account_hint.title": "This profile has been hidden by the moderators of {domain}.",
"link_preview.author": "By {name}",
"link_preview.more_from_author": "More from {name}",
"link_preview.shares": "{count, plural, one {{counter} post} other {{counter} posts}}",
"lists.account.add": "Add to list",
"lists.account.remove": "Remove from list",
"lists.delete": "Delete list",
Expand Down Expand Up @@ -691,8 +696,11 @@
"server_banner.about_active_users": "People using this server during the last 30 days (Monthly Active Users)",
"server_banner.active_users": "active users",
"server_banner.administered_by": "Administered by:",
"server_banner.is_one_of_many": "{domain} is one of the many independent Mastodon servers you can use to participate in the fediverse.",
"server_banner.server_stats": "Server stats:",
"sign_in_banner.create_account": "Create account",
"sign_in_banner.follow_anyone": "Follow anyone across the fediverse and see it all in chronological order. No algorithms, ads, or clickbait in sight.",
"sign_in_banner.mastodon_is": "Mastodon is the best way to keep up with what's happening.",
"sign_in_banner.sign_in": "Sign in",
"sign_in_banner.sso_redirect": "Login or Register",
"status.admin_account": "Open moderation interface for @{name}",
Expand Down
3 changes: 3 additions & 0 deletions app/javascript/mastodon/locales/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@
"audio.hide": "Skryť zvuk",
"block_modal.show_less": "Zobraziť menej",
"block_modal.show_more": "Zobraziť viac",
"block_modal.they_cant_mention": "Nemôžu ťa spomenúť, alebo nasledovať.",
"block_modal.they_will_know": "Môžu vidieť, že sú zablokovaní/ý.",
"block_modal.title": "Blokovať užívateľa?",
"block_modal.you_wont_see_mentions": "Neuvidíš príspevky, ktoré ich spomínajú.",
"boost_modal.combo": "Nabudúce môžete preskočiť stlačením {combo}",
"bundle_column_error.copy_stacktrace": "Kopírovať chybovú hlášku",
"bundle_column_error.error.body": "Požadovanú stránku nebolo možné vykresliť. Môže to byť spôsobené chybou v našom kóde alebo problémom s kompatibilitou prehliadača.",
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/mastodon/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"account.follow_back": "Підписатися взаємно",
"account.followers": "Підписники",
"account.followers.empty": "Ніхто ще не підписаний на цього користувача.",
"account.followers_counter": "{count, plural, one {{counter} підписник} few {{counter} підписники} many {{counter} підписників} other {{counter} підписники}}",
"account.following": "Ви стежите",
"account.following_counter": "{count, plural, one {{counter} підписка} few {{counter} підписки} many {{counter} підписок} other {{counter} підписки}}",
"account.follows.empty": "Цей користувач ще ні на кого не підписався.",
"account.go_to_profile": "Перейти до профілю",
"account.hide_reblogs": "Сховати поширення від @{name}",
Expand All @@ -61,6 +63,7 @@
"account.requested_follow": "{name} надсилає запит на стеження",
"account.share": "Поділитися профілем @{name}",
"account.show_reblogs": "Показати поширення від @{name}",
"account.statuses_counter": "{count, plural, one {{counter} допис} few {{counter} дописи} many {{counter} дописів} other {{counter} допис}}",
"account.unblock": "Розблокувати @{name}",
"account.unblock_domain": "Розблокувати {domain}",
"account.unblock_short": "Розблокувати",
Expand Down Expand Up @@ -412,6 +415,7 @@
"limited_account_hint.title": "Цей профіль сховали модератори {domain}.",
"link_preview.author": "Від {name}",
"link_preview.more_from_author": "Більше від {name}",
"link_preview.shares": "{count, plural, one {{counter} допис} few {{counter} дописи} many {{counter} дописів} other {{counter} допис}}",
"lists.account.add": "Додати до списку",
"lists.account.remove": "Вилучити зі списку",
"lists.delete": "Видалити список",
Expand Down Expand Up @@ -695,6 +699,7 @@
"server_banner.is_one_of_many": "{domain} - один з багатьох незалежних серверів Mastodon, які ви можете використати, щоб брати участь у федівері.",
"server_banner.server_stats": "Статистика сервера:",
"sign_in_banner.create_account": "Створити обліковий запис",
"sign_in_banner.follow_anyone": "Слідкуйте за ким завгодно у всьому fediverse і дивіться все це в хронологічному порядку. Немає алгоритмів, реклами чи наживок для натискань при перегляді.",
"sign_in_banner.mastodon_is": "Мастодон - найкращий спосіб продовжувати свою справу.",
"sign_in_banner.sign_in": "Увійти",
"sign_in_banner.sso_redirect": "Увійдіть або зареєструйтесь",
Expand Down
92 changes: 92 additions & 0 deletions app/lib/admin/db/schema_parser.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# frozen_string_literal: true

class Admin::Db::SchemaParser
class Index
attr_reader :name, :table_name, :columns, :options

def initialize(name:, table_name:, columns:, options:)
@name = name
@table_name = table_name
@columns = columns
@options = options
end
end

attr_reader :indexes_by_table

def initialize(source)
parse(source)
end

private

def parse(source)
@indexes_by_table = {}
queue = [Prism.parse(source).value]
while (node = queue.shift)
if node.type == :call_node && node.name == :create_table
parse_create_table(node)
elsif node.type == :call_node && node.name == :add_index
parse_add_index(node)
else
queue.concat(node.compact_child_nodes)
end
end
end

def parse_create_table(node)
table_name = parse_arguments(node).first
queue = node.compact_child_nodes
while (node = queue.shift)
if node.type == :call_node && node.name == :index
parse_index(node, table_name:)
else
queue.concat(node.compact_child_nodes)
end
end
end

def parse_index(node, table_name:)
arguments = parse_arguments(node)
save_index(
name: arguments.last[:name],
table_name: table_name,
columns: arguments.first,
options: arguments.last
)
end

def parse_add_index(node)
arguments = parse_arguments(node)
save_index(
name: arguments.last[:name],
table_name: arguments.first,
columns: arguments[1],
options: arguments.last
)
end

def parse_arguments(node)
node.arguments.arguments.map { |a| parse_argument(a) }
end

def parse_argument(argument)
case argument
when Prism::StringNode
argument.unescaped
when Prism::SymbolNode
argument.unescaped.to_sym
when Prism::ArrayNode
argument.elements.map { |e| parse_argument(e) }
when Prism::KeywordHashNode
argument.elements.to_h do |element|
[element.key.unescaped.to_sym, parse_argument(element.value)]
end
end
end

def save_index(name:, table_name:, columns:, options:)
@indexes_by_table[table_name] ||= []
@indexes_by_table[table_name] << Index.new(name:, table_name:, columns:, options:)
end
end
1 change: 1 addition & 0 deletions app/lib/admin/system_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Admin::SystemCheck
Admin::SystemCheck::SidekiqProcessCheck,
Admin::SystemCheck::RulesCheck,
Admin::SystemCheck::ElasticsearchCheck,
Admin::SystemCheck::MissingIndexesCheck,
].freeze

def self.perform(current_user)
Expand Down
36 changes: 36 additions & 0 deletions app/lib/admin/system_check/missing_indexes_check.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

class Admin::SystemCheck::MissingIndexesCheck < Admin::SystemCheck::BaseCheck
def skip?
!current_user.can?(:view_devops)
end

def pass?
missing_indexes.none?
end

def message
Admin::SystemCheck::Message.new(:missing_indexes_check, missing_indexes.join(', '))
end

private

def missing_indexes
@missing_indexes ||= begin
expected_indexes_by_table.flat_map do |table, indexes|
expected_indexes = indexes.map(&:name)
expected_indexes - existing_indexes_for(table)
end
end
end

def expected_indexes_by_table
schema_rb = Rails.root.join('db', 'schema.rb').read
schema_parser = Admin::Db::SchemaParser.new(schema_rb)
schema_parser.indexes_by_table
end

def existing_indexes_for(table)
ActiveRecord::Base.connection.indexes(table).map(&:name)
end
end
2 changes: 1 addition & 1 deletion config/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ cs:
invite_request_text: Důvody založení
invited_by: Pozván uživatelem
ip: IP adresa
joined: Uživatel založen
joined: Uživatelem od
location:
all: Všechny
local: Místní
Expand Down
2 changes: 2 additions & 0 deletions config/locales/doorkeeper.en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ en-GB:
media: Media attachments
mutes: Mutes
notifications: Notifications
profile: Your Mastodon profile
push: Push notifications
reports: Reports
search: Search
Expand Down Expand Up @@ -165,6 +166,7 @@ en-GB:
admin:write:reports: perform moderation actions on reports
crypto: use end-to-end encryption
follow: modify account relationships
profile: read only your account's profile information
push: receive your push notifications
read: read all your account's data
read:accounts: see accounts information
Expand Down
Loading

0 comments on commit 3026757

Please sign in to comment.