mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Compare commits
9 Commits
ca10e236ca
...
3df0920531
Author | SHA1 | Date | |
---|---|---|---|
|
3df0920531 | ||
|
6d62581da1 | ||
|
9a7130d6da | ||
|
86c7a3728d | ||
|
bdc6ba4645 | ||
|
1c36a1583d | ||
|
c7c4907085 | ||
|
909f61b6c3 | ||
|
ddbec27414 |
2
.github/workflows/bundler-audit.yml
vendored
2
.github/workflows/bundler-audit.yml
vendored
|
@ -36,4 +36,4 @@ jobs:
|
|||
bundler-cache: true
|
||||
|
||||
- name: Run bundler-audit
|
||||
run: bundle exec bundler-audit check --update
|
||||
run: bin/bundler-audit check --update
|
||||
|
|
10
.github/workflows/check-i18n.yml
vendored
10
.github/workflows/check-i18n.yml
vendored
|
@ -35,18 +35,18 @@ jobs:
|
|||
git diff --exit-code
|
||||
|
||||
- name: Check locale file normalization
|
||||
run: bundle exec i18n-tasks check-normalized
|
||||
run: bin/i18n-tasks check-normalized
|
||||
|
||||
- name: Check for unused strings
|
||||
run: bundle exec i18n-tasks unused
|
||||
run: bin/i18n-tasks unused
|
||||
|
||||
- name: Check for missing strings in English YML
|
||||
run: |
|
||||
bundle exec i18n-tasks add-missing -l en
|
||||
bin/i18n-tasks add-missing -l en
|
||||
git diff --exit-code
|
||||
|
||||
- name: Check for wrong string interpolations
|
||||
run: bundle exec i18n-tasks check-consistent-interpolations
|
||||
run: bin/i18n-tasks check-consistent-interpolations
|
||||
|
||||
- name: Check that all required locale files exist
|
||||
run: bundle exec rake repo:check_locales_files
|
||||
run: bin/rake repo:check_locales_files
|
||||
|
|
|
@ -46,7 +46,7 @@ jobs:
|
|||
uses: ./.github/actions/setup-ruby
|
||||
|
||||
- name: Run i18n normalize task
|
||||
run: bundle exec i18n-tasks normalize
|
||||
run: bin/i18n-tasks normalize
|
||||
|
||||
# Create or update the pull request
|
||||
- name: Create Pull Request
|
||||
|
|
2
.github/workflows/crowdin-download.yml
vendored
2
.github/workflows/crowdin-download.yml
vendored
|
@ -48,7 +48,7 @@ jobs:
|
|||
uses: ./.github/actions/setup-ruby
|
||||
|
||||
- name: Run i18n normalize task
|
||||
run: bundle exec i18n-tasks normalize
|
||||
run: bin/i18n-tasks normalize
|
||||
|
||||
# Create or update the pull request
|
||||
- name: Create Pull Request
|
||||
|
|
2
.github/workflows/lint-haml.yml
vendored
2
.github/workflows/lint-haml.yml
vendored
|
@ -43,4 +43,4 @@ jobs:
|
|||
- name: Run haml-lint
|
||||
run: |
|
||||
echo "::add-matcher::.github/workflows/haml-lint-problem-matcher.json"
|
||||
bundle exec haml-lint --reporter github
|
||||
bin/haml-lint --reporter github
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -65,7 +65,6 @@ gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
|
|||
gem 'mime-types', '~> 3.6.0', require: 'mime/types/columnar'
|
||||
gem 'mutex_m'
|
||||
gem 'nokogiri', '~> 1.15'
|
||||
gem 'oj', '~> 3.14'
|
||||
gem 'ox', '~> 2.14'
|
||||
gem 'parslet'
|
||||
gem 'premailer-rails'
|
||||
|
|
|
@ -428,9 +428,6 @@ GEM
|
|||
nokogiri (1.16.7)
|
||||
mini_portile2 (~> 2.8.2)
|
||||
racc (~> 1.4)
|
||||
oj (3.16.7)
|
||||
bigdecimal (>= 3.0)
|
||||
ostruct (>= 0.2)
|
||||
omniauth (2.1.2)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 2.2.3)
|
||||
|
@ -948,7 +945,6 @@ DEPENDENCIES
|
|||
net-http (~> 0.5.0)
|
||||
net-ldap (~> 0.18)
|
||||
nokogiri (~> 1.15)
|
||||
oj (~> 3.14)
|
||||
omniauth (~> 2.0)
|
||||
omniauth-cas (~> 3.0.0.beta.1)
|
||||
omniauth-rails_csrf_protection (~> 1.0)
|
||||
|
@ -1031,7 +1027,7 @@ DEPENDENCIES
|
|||
xorcist (~> 1.1)
|
||||
|
||||
RUBY VERSION
|
||||
ruby 3.3.5p100
|
||||
ruby 3.3.6p108
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.22
|
||||
2.5.23
|
||||
|
|
|
@ -21,9 +21,9 @@ class ActivityPub::InboxesController < ActivityPub::BaseController
|
|||
end
|
||||
|
||||
def unknown_affected_account?
|
||||
json = Oj.load(body, mode: :strict)
|
||||
json = JSON.parse(body)
|
||||
json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.exists?(uri: json['actor'])
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||
|
||||
headers.merge!(response.headers)
|
||||
|
||||
self.response_body = Oj.dump(response.body)
|
||||
self.response_body = JSON.dump(response.body)
|
||||
self.status = response.status
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: 422
|
||||
|
|
|
@ -38,7 +38,7 @@ class Api::V1::MarkersController < Api::BaseController
|
|||
serialized[key] = ActiveModelSerializers::SerializableResource.new(value, serializer: REST::MarkerSerializer).as_json
|
||||
end
|
||||
|
||||
Oj.dump(serialized)
|
||||
JSON.dump(serialized)
|
||||
end
|
||||
|
||||
def resource_params
|
||||
|
|
|
@ -30,7 +30,7 @@ class Api::V1::Statuses::PinsController < Api::V1::Statuses::BaseController
|
|||
adapter: ActivityPub::Adapter
|
||||
).as_json
|
||||
|
||||
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id)
|
||||
ActivityPub::RawDistributionWorker.perform_async(JSON.dump(json), current_account.id)
|
||||
end
|
||||
|
||||
def distribute_remove_activity!
|
||||
|
@ -40,6 +40,6 @@ class Api::V1::Statuses::PinsController < Api::V1::Statuses::BaseController
|
|||
adapter: ActivityPub::Adapter
|
||||
).as_json
|
||||
|
||||
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id)
|
||||
ActivityPub::RawDistributionWorker.perform_async(JSON.dump(json), current_account.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -191,12 +191,12 @@ module JsonLdHelper
|
|||
end
|
||||
|
||||
def body_to_json(body, compare_id: nil)
|
||||
json = body.is_a?(String) ? Oj.load(body, mode: :strict) : body
|
||||
json = body.is_a?(String) ? JSON.parse(body) : body
|
||||
|
||||
return if compare_id.present? && json['id'] != compare_id
|
||||
|
||||
json
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module ReactComponentHelper
|
||||
def react_component(name, props = {}, &block)
|
||||
data = { component: name.to_s.camelcase, props: Oj.dump(props) }
|
||||
data = { component: name.to_s.camelcase, props: JSON.dump(props) }
|
||||
if block.nil?
|
||||
div_tag_with_data(data)
|
||||
else
|
||||
|
@ -11,7 +11,7 @@ module ReactComponentHelper
|
|||
end
|
||||
|
||||
def react_admin_component(name, props = {})
|
||||
data = { 'admin-component': name.to_s.camelcase, props: Oj.dump(props) }
|
||||
data = { 'admin-component': name.to_s.camelcase, props: JSON.dump(props) }
|
||||
div_tag_with_data(data)
|
||||
end
|
||||
|
||||
|
|
|
@ -24,6 +24,6 @@ module AccessTokenExtension
|
|||
end
|
||||
|
||||
def push_to_streaming_api
|
||||
redis.publish("timeline:access_token:#{id}", Oj.dump(event: :kill)) if revoked? || destroyed?
|
||||
redis.publish("timeline:access_token:#{id}", JSON.dump(event: :kill)) if revoked? || destroyed?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -416,7 +416,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
def forward_for_reply
|
||||
return unless @status.distributable? && @json['signature'].present? && reply_to_local?
|
||||
|
||||
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(@json), replied_to_status.account_id, [@account.preferred_inbox_url])
|
||||
ActivityPub::RawDistributionWorker.perform_async(JSON.dump(@json), replied_to_status.account_id, [@account.preferred_inbox_url])
|
||||
end
|
||||
|
||||
def increment_voters_count!
|
||||
|
|
|
@ -39,7 +39,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
|||
end
|
||||
|
||||
def reject_follow_request!(target_account)
|
||||
json = Oj.dump(serialize_payload(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), ActivityPub::RejectFollowSerializer))
|
||||
json = JSON.dump(serialize_payload(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), ActivityPub::RejectFollowSerializer))
|
||||
ActivityPub::DeliveryWorker.perform_async(json, target_account.id, @account.inbox_url)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ class ActivityPub::Forwarder
|
|||
private
|
||||
|
||||
def payload
|
||||
@payload ||= Oj.dump(@json)
|
||||
@payload ||= JSON.dump(@json)
|
||||
end
|
||||
|
||||
def reblogged_by_account_ids
|
||||
|
|
|
@ -106,7 +106,7 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim
|
|||
|
||||
def ffmpeg_version
|
||||
version_output = Terrapin::CommandLine.new(Rails.configuration.x.ffprobe_binary, '-show_program_version -v 0 -of json').run
|
||||
version = Oj.load(version_output, mode: :strict, symbol_keys: true).dig(:program_version, :version)
|
||||
version = JSON.parse(version_output, symbolize_names: true).dig(:program_version, :version)
|
||||
|
||||
{
|
||||
key: 'ffmpeg',
|
||||
|
@ -114,7 +114,7 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim
|
|||
value: version,
|
||||
human_value: version,
|
||||
}
|
||||
rescue Terrapin::CommandNotFoundError, Terrapin::ExitStatusError, Oj::ParseError
|
||||
rescue Terrapin::CommandNotFoundError, Terrapin::ExitStatusError, JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ module ApplicationExtension
|
|||
|
||||
def close_streaming_sessions(resource_owner = nil)
|
||||
# TODO: #28793 Combine into a single topic
|
||||
payload = Oj.dump(event: :kill)
|
||||
payload = JSON.dump(event: :kill)
|
||||
scope = access_tokens
|
||||
scope = scope.where(resource_owner_id: resource_owner.id) unless resource_owner.nil?
|
||||
scope.in_batches do |tokens|
|
||||
|
|
|
@ -58,6 +58,7 @@ class FeedManager
|
|||
# @param [Boolean] update
|
||||
# @return [Boolean]
|
||||
def push_to_home(account, status, update: false)
|
||||
return false unless account.user&.signed_in_recently?
|
||||
return false unless add_to_feed(:home, account.id, status, aggregate_reblogs: account.user&.aggregates_reblogs?)
|
||||
|
||||
trim(:home, account.id)
|
||||
|
@ -73,7 +74,7 @@ class FeedManager
|
|||
def unpush_from_home(account, status, update: false)
|
||||
return false unless remove_from_feed(:home, account.id, status, aggregate_reblogs: account.user&.aggregates_reblogs?)
|
||||
|
||||
redis.publish("timeline:#{account.id}", Oj.dump(event: :delete, payload: status.id.to_s)) unless update
|
||||
redis.publish("timeline:#{account.id}", JSON.dump(event: :delete, payload: status.id.to_s)) unless update
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -83,7 +84,9 @@ class FeedManager
|
|||
# @param [Boolean] update
|
||||
# @return [Boolean]
|
||||
def push_to_list(list, status, update: false)
|
||||
return false if filter_from_list?(status, list) || !add_to_feed(:list, list.id, status, aggregate_reblogs: list.account.user&.aggregates_reblogs?)
|
||||
return false if filter_from_list?(status, list)
|
||||
return false unless list.account.user&.signed_in_recently?
|
||||
return false unless add_to_feed(:list, list.id, status, aggregate_reblogs: list.account.user&.aggregates_reblogs?)
|
||||
|
||||
trim(:list, list.id)
|
||||
PushUpdateWorker.perform_async(list.account_id, status.id, "timeline:list:#{list.id}", { 'update' => update }) if push_update_required?("timeline:list:#{list.id}")
|
||||
|
@ -98,7 +101,7 @@ class FeedManager
|
|||
def unpush_from_list(list, status, update: false)
|
||||
return false unless remove_from_feed(:list, list.id, status, aggregate_reblogs: list.account.user&.aggregates_reblogs?)
|
||||
|
||||
redis.publish("timeline:list:#{list.id}", Oj.dump(event: :delete, payload: status.id.to_s)) unless update
|
||||
redis.publish("timeline:list:#{list.id}", JSON.dump(event: :delete, payload: status.id.to_s)) unless update
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class LinkDetailsExtractor
|
|||
end
|
||||
|
||||
def json
|
||||
@json ||= root_array(Oj.load(@data)).compact.find { |obj| SUPPORTED_TYPES.include?(obj['@type']) } || {}
|
||||
@json ||= root_array(JSON.parse(@data)).compact.find { |obj| SUPPORTED_TYPES.include?(obj['@type']) } || {}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -265,7 +265,7 @@ class LinkDetailsExtractor
|
|||
next unless structured_data.valid?
|
||||
|
||||
structured_data
|
||||
rescue Oj::ParseError, EncodingError
|
||||
rescue JSON::ParserError, EncodingError
|
||||
Rails.logger.debug { "Invalid JSON-LD in #{@original_url}" }
|
||||
next
|
||||
end.first
|
||||
|
|
|
@ -31,7 +31,7 @@ class TranslationService::DeepL < TranslationService
|
|||
|
||||
def fetch_languages(type)
|
||||
request(:get, "/v2/languages?type=#{type}") do |res|
|
||||
Oj.load(res.body_with_limit).map { |language| normalize_language(language['language']) }
|
||||
JSON.parse(res.body_with_limit).map { |language| normalize_language(language['language']) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -68,7 +68,7 @@ class TranslationService::DeepL < TranslationService
|
|||
end
|
||||
|
||||
def transform_response(json)
|
||||
data = Oj.load(json, mode: :strict)
|
||||
data = JSON.parse(json)
|
||||
raise UnexpectedResponseError unless data.is_a?(Hash)
|
||||
|
||||
data['translations'].map do |translation|
|
||||
|
@ -78,7 +78,7 @@ class TranslationService::DeepL < TranslationService
|
|||
provider: 'DeepL.com'
|
||||
)
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise UnexpectedResponseError
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class TranslationService::LibreTranslate < TranslationService
|
|||
end
|
||||
|
||||
def translate(texts, source_language, target_language)
|
||||
body = Oj.dump(q: texts, source: source_language.presence || 'auto', target: target_language, format: 'html', api_key: @api_key)
|
||||
body = JSON.dump(q: texts, source: source_language.presence || 'auto', target: target_language, format: 'html', api_key: @api_key)
|
||||
request(:post, '/translate', body: body) do |res|
|
||||
transform_response(res.body_with_limit, source_language)
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class TranslationService::LibreTranslate < TranslationService
|
|||
|
||||
def languages
|
||||
request(:get, '/languages') do |res|
|
||||
languages = Oj.load(res.body_with_limit).to_h do |language|
|
||||
languages = JSON.parse(res.body_with_limit).to_h do |language|
|
||||
[language['code'], language['targets'].without(language['code'])]
|
||||
end
|
||||
languages[nil] = languages.values.flatten.uniq.sort
|
||||
|
@ -45,7 +45,7 @@ class TranslationService::LibreTranslate < TranslationService
|
|||
end
|
||||
|
||||
def transform_response(json, source_language)
|
||||
data = Oj.load(json, mode: :strict)
|
||||
data = JSON.parse(json)
|
||||
raise UnexpectedResponseError unless data.is_a?(Hash)
|
||||
|
||||
data['translatedText'].map.with_index do |text, index|
|
||||
|
@ -55,7 +55,7 @@ class TranslationService::LibreTranslate < TranslationService
|
|||
provider: 'LibreTranslate'
|
||||
)
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise UnexpectedResponseError
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class UserSettingsSerializer
|
|||
if value.blank?
|
||||
{}
|
||||
else
|
||||
Oj.load(value, symbol_keys: true)
|
||||
JSON.parse(value, symbolize_names: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,6 +14,6 @@ class UserSettingsSerializer
|
|||
end
|
||||
|
||||
def self.dump(value)
|
||||
Oj.dump(value.as_json)
|
||||
JSON.dump(value.as_json)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,10 +6,10 @@ class VideoMetadataExtractor
|
|||
|
||||
def initialize(path)
|
||||
@path = path
|
||||
@metadata = Oj.load(ffmpeg_command_output, mode: :strict, symbol_keys: true)
|
||||
@metadata = JSON.parse(ffmpeg_command_output, symbolize_names: true)
|
||||
|
||||
parse_metadata
|
||||
rescue Terrapin::ExitStatusError, Oj::ParseError
|
||||
rescue Terrapin::ExitStatusError, JSON::ParserError
|
||||
@invalid = true
|
||||
rescue Terrapin::CommandNotFoundError
|
||||
raise Paperclip::Errors::CommandNotFoundError, 'Could not run the `ffprobe` command. Please install ffmpeg.'
|
||||
|
|
|
@ -12,7 +12,7 @@ class Webfinger
|
|||
|
||||
def initialize(uri, body)
|
||||
@uri = uri
|
||||
@json = Oj.load(body, mode: :strict)
|
||||
@json = JSON.parse(body)
|
||||
|
||||
validate_response!
|
||||
end
|
||||
|
@ -57,7 +57,7 @@ class Webfinger
|
|||
|
||||
def perform
|
||||
Response.new(@uri, body_from_webfinger)
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise Webfinger::Error, "Invalid JSON in response for #{@uri}"
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
raise Webfinger::Error, "Invalid URI for #{@uri}"
|
||||
|
|
|
@ -10,7 +10,7 @@ class Webhooks::PayloadRenderer
|
|||
|
||||
def get(path)
|
||||
value = @document.dig(*parse_path(path))
|
||||
string = Oj.dump(value)
|
||||
string = JSON.dump(value)
|
||||
|
||||
# We want to make sure people can use the variable inside
|
||||
# other strings, so it can't be wrapped in quotes.
|
||||
|
@ -58,7 +58,7 @@ class Webhooks::PayloadRenderer
|
|||
/iox
|
||||
|
||||
def initialize(json)
|
||||
@document = DocumentTraverser.new(Oj.load(json))
|
||||
@document = DocumentTraverser.new(JSON.parse(json))
|
||||
end
|
||||
|
||||
def render(template)
|
||||
|
|
|
@ -112,8 +112,8 @@ class CustomFilter < ApplicationRecord
|
|||
@should_invalidate_cache = false
|
||||
|
||||
Rails.cache.delete("filters:v3:#{account_id}")
|
||||
redis.publish("timeline:#{account_id}", Oj.dump(event: :filters_changed))
|
||||
redis.publish("timeline:system:#{account_id}", Oj.dump(event: :filters_changed))
|
||||
redis.publish("timeline:#{account_id}", JSON.dump(event: :filters_changed))
|
||||
redis.publish("timeline:system:#{account_id}", JSON.dump(event: :filters_changed))
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -31,7 +31,7 @@ class Relay < ApplicationRecord
|
|||
|
||||
def enable!
|
||||
activity_id = ActivityPub::TagManager.instance.generate_uri_for(nil)
|
||||
payload = Oj.dump(follow_activity(activity_id))
|
||||
payload = JSON.dump(follow_activity(activity_id))
|
||||
|
||||
update!(state: :pending, follow_activity_id: activity_id)
|
||||
DeliveryFailureTracker.reset!(inbox_url)
|
||||
|
@ -40,7 +40,7 @@ class Relay < ApplicationRecord
|
|||
|
||||
def disable!
|
||||
activity_id = ActivityPub::TagManager.instance.generate_uri_for(nil)
|
||||
payload = Oj.dump(unfollow_activity(activity_id))
|
||||
payload = JSON.dump(unfollow_activity(activity_id))
|
||||
|
||||
update!(state: :idle, follow_activity_id: nil)
|
||||
DeliveryFailureTracker.reset!(inbox_url)
|
||||
|
|
|
@ -165,6 +165,10 @@ class User < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def signed_in_recently?
|
||||
current_sign_in_at.present? && current_sign_in_at >= ACTIVE_DURATION.ago
|
||||
end
|
||||
|
||||
def confirmed?
|
||||
confirmed_at.present?
|
||||
end
|
||||
|
@ -355,7 +359,7 @@ class User < ApplicationRecord
|
|||
# Revoke each access token for the Streaming API, since `update_all``
|
||||
# doesn't trigger ActiveRecord Callbacks:
|
||||
# TODO: #28793 Combine into a single topic
|
||||
payload = Oj.dump(event: :kill)
|
||||
payload = JSON.dump(event: :kill)
|
||||
redis.pipelined do |pipeline|
|
||||
batch.ids.each do |id|
|
||||
pipeline.publish("timeline:access_token:#{id}", payload)
|
||||
|
|
|
@ -19,7 +19,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
|||
else
|
||||
body_to_json(prefetched_body, compare_id: uri)
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise Error, "Error parsing JSON-LD document #{uri}"
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
end
|
||||
|
||||
@account
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class ActivityPub::ProcessCollectionService < BaseService
|
|||
|
||||
def call(body, actor, **options)
|
||||
@account = actor
|
||||
@json = original_json = Oj.load(body, mode: :strict)
|
||||
@json = original_json = JSON.parse(body)
|
||||
@options = options
|
||||
|
||||
return unless @json.is_a?(Hash)
|
||||
|
@ -38,7 +38,7 @@ class ActivityPub::ProcessCollectionService < BaseService
|
|||
else
|
||||
process_items [@json]
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class ActivityPub::SynchronizeFollowersService < BaseService
|
|||
end
|
||||
|
||||
def build_undo_follow_json(follow)
|
||||
Oj.dump(serialize_payload(follow, ActivityPub::UndoFollowSerializer))
|
||||
JSON.dump(serialize_payload(follow, ActivityPub::UndoFollowSerializer))
|
||||
end
|
||||
|
||||
def collection_items(collection_or_uri)
|
||||
|
|
|
@ -54,7 +54,7 @@ class AfterBlockDomainFromAccountService < BaseService
|
|||
|
||||
return unless follow.account.activitypub?
|
||||
|
||||
ActivityPub::DeliveryWorker.perform_async(Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), @account.id, follow.account.inbox_url)
|
||||
ActivityPub::DeliveryWorker.perform_async(JSON.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), @account.id, follow.account.inbox_url)
|
||||
end
|
||||
|
||||
def notify_of_severed_relationships!
|
||||
|
|
|
@ -22,6 +22,6 @@ class AuthorizeFollowService < BaseService
|
|||
end
|
||||
|
||||
def build_json(follow_request)
|
||||
Oj.dump(serialize_payload(follow_request, ActivityPub::AcceptFollowSerializer))
|
||||
JSON.dump(serialize_payload(follow_request, ActivityPub::AcceptFollowSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class BackupService < BaseService
|
|||
skeleton = serialize(collection_presenter, ActivityPub::CollectionSerializer)
|
||||
skeleton[:@context] = full_context
|
||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
||||
skeleton = Oj.dump(skeleton)
|
||||
skeleton = JSON.dump(skeleton)
|
||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
||||
add_comma = false
|
||||
|
||||
|
@ -41,7 +41,7 @@ class BackupService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
Oj.dump(item)
|
||||
JSON.dump(item)
|
||||
end.join(','))
|
||||
|
||||
GC.start
|
||||
|
@ -104,7 +104,7 @@ class BackupService < BaseService
|
|||
download_to_zip(zipfile, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists?
|
||||
download_to_zip(zipfile, account.header, "header#{File.extname(account.header.path)}") if account.header.exists?
|
||||
|
||||
json = Oj.dump(actor)
|
||||
json = JSON.dump(actor)
|
||||
|
||||
zipfile.get_output_stream('actor.json') do |io|
|
||||
io.write(json)
|
||||
|
@ -115,7 +115,7 @@ class BackupService < BaseService
|
|||
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'likes.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
||||
skeleton.delete(:totalItems)
|
||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
||||
skeleton = Oj.dump(skeleton)
|
||||
skeleton = JSON.dump(skeleton)
|
||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
||||
|
||||
zipfile.get_output_stream('likes.json') do |io|
|
||||
|
@ -128,7 +128,7 @@ class BackupService < BaseService
|
|||
add_comma = true
|
||||
|
||||
io.write(statuses.map do |status|
|
||||
Oj.dump(ActivityPub::TagManager.instance.uri_for(status))
|
||||
JSON.dump(ActivityPub::TagManager.instance.uri_for(status))
|
||||
end.join(','))
|
||||
|
||||
GC.start
|
||||
|
@ -142,7 +142,7 @@ class BackupService < BaseService
|
|||
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'bookmarks.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
||||
skeleton.delete(:totalItems)
|
||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
||||
skeleton = Oj.dump(skeleton)
|
||||
skeleton = JSON.dump(skeleton)
|
||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
||||
|
||||
zipfile.get_output_stream('bookmarks.json') do |io|
|
||||
|
@ -154,7 +154,7 @@ class BackupService < BaseService
|
|||
add_comma = true
|
||||
|
||||
io.write(statuses.map do |status|
|
||||
Oj.dump(ActivityPub::TagManager.instance.uri_for(status))
|
||||
JSON.dump(ActivityPub::TagManager.instance.uri_for(status))
|
||||
end.join(','))
|
||||
|
||||
GC.start
|
||||
|
|
|
@ -82,7 +82,7 @@ class BatchedRemoveStatusService < BaseService
|
|||
def unpush_from_public_timelines(status, pipeline)
|
||||
return unless status.public_visibility? && status.id > @status_id_cutoff
|
||||
|
||||
payload = Oj.dump(event: :delete, payload: status.id.to_s)
|
||||
payload = JSON.dump(event: :delete, payload: status.id.to_s)
|
||||
|
||||
pipeline.publish('timeline:public', payload)
|
||||
pipeline.publish(status.local? ? 'timeline:public:local' : 'timeline:public:remote', payload)
|
||||
|
|
|
@ -26,6 +26,6 @@ class BlockService < BaseService
|
|||
end
|
||||
|
||||
def build_json(block)
|
||||
Oj.dump(serialize_payload(block, ActivityPub::BlockSerializer))
|
||||
JSON.dump(serialize_payload(block, ActivityPub::BlockSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,6 @@ class CreateFeaturedTagService < BaseService
|
|||
private
|
||||
|
||||
def build_json(featured_tag)
|
||||
Oj.dump(serialize_payload(featured_tag, ActivityPub::AddSerializer, signer: @account))
|
||||
JSON.dump(serialize_payload(featured_tag, ActivityPub::AddSerializer, signer: @account))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -114,7 +114,7 @@ class DeleteAccountService < BaseService
|
|||
# we have to force it to unfollow them.
|
||||
|
||||
ActivityPub::DeliveryWorker.push_bulk(Follow.where(account: @account)) do |follow|
|
||||
[Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url]
|
||||
[JSON.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -126,7 +126,7 @@ class DeleteAccountService < BaseService
|
|||
# if the remote account gets un-suspended.
|
||||
|
||||
ActivityPub::DeliveryWorker.push_bulk(Follow.where(target_account: @account)) do |follow|
|
||||
[Oj.dump(serialize_payload(follow, ActivityPub::UndoFollowSerializer)), follow.account_id, @account.inbox_url]
|
||||
[JSON.dump(serialize_payload(follow, ActivityPub::UndoFollowSerializer)), follow.account_id, @account.inbox_url]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -285,7 +285,7 @@ class DeleteAccountService < BaseService
|
|||
end
|
||||
|
||||
def delete_actor_json
|
||||
@delete_actor_json ||= Oj.dump(serialize_payload(@account, ActivityPub::DeleteActorSerializer, signer: @account, always_sign: true))
|
||||
@delete_actor_json ||= JSON.dump(serialize_payload(@account, ActivityPub::DeleteActorSerializer, signer: @account, always_sign: true))
|
||||
end
|
||||
|
||||
def delivery_inboxes
|
||||
|
|
|
@ -154,7 +154,7 @@ class FanOutOnWriteService < BaseService
|
|||
end
|
||||
|
||||
def anonymous_payload
|
||||
@anonymous_payload ||= Oj.dump(
|
||||
@anonymous_payload ||= JSON.dump(
|
||||
event: update? ? :'status.update' : :update,
|
||||
payload: rendered_status
|
||||
)
|
||||
|
|
|
@ -42,6 +42,6 @@ class FavouriteService < BaseService
|
|||
end
|
||||
|
||||
def build_json(favourite)
|
||||
Oj.dump(serialize_payload(favourite, ActivityPub::LikeSerializer))
|
||||
JSON.dump(serialize_payload(favourite, ActivityPub::LikeSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -86,14 +86,14 @@ class FetchOEmbedService
|
|||
end
|
||||
|
||||
validate(parse_for_format(body)) if body.present?
|
||||
rescue Oj::ParseError, Ox::ParseError
|
||||
rescue JSON::ParserError, Ox::ParseError
|
||||
nil
|
||||
end
|
||||
|
||||
def parse_for_format(body)
|
||||
case @format
|
||||
when :json
|
||||
Oj.load(body, mode: :strict)&.with_indifferent_access
|
||||
JSON.parse(body)&.with_indifferent_access
|
||||
when :xml
|
||||
Ox.load(body, mode: :hash_no_attrs)&.with_indifferent_access&.dig(:oembed)
|
||||
end
|
||||
|
|
|
@ -90,7 +90,7 @@ class FollowService < BaseService
|
|||
end
|
||||
|
||||
def build_json(follow_request)
|
||||
Oj.dump(serialize_payload(follow_request, ActivityPub::FollowSerializer))
|
||||
JSON.dump(serialize_payload(follow_request, ActivityPub::FollowSerializer))
|
||||
end
|
||||
|
||||
def follow_options
|
||||
|
|
|
@ -258,7 +258,7 @@ class NotifyService < BaseService
|
|||
end
|
||||
|
||||
def push_to_streaming_api!
|
||||
redis.publish("timeline:#{@recipient.id}:notifications", Oj.dump(event: :notification, payload: InlineRenderer.render(@notification, @recipient, :notification)))
|
||||
redis.publish("timeline:#{@recipient.id}:notifications", JSON.dump(event: :notification, payload: InlineRenderer.render(@notification, @recipient, :notification)))
|
||||
end
|
||||
|
||||
def subscribed_to_streaming_api?
|
||||
|
|
|
@ -51,6 +51,6 @@ class ReblogService < BaseService
|
|||
end
|
||||
|
||||
def build_json(reblog)
|
||||
Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(reblog), ActivityPub::ActivitySerializer, signer: reblog.account))
|
||||
JSON.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(reblog), ActivityPub::ActivitySerializer, signer: reblog.account))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,6 @@ class RejectFollowService < BaseService
|
|||
end
|
||||
|
||||
def build_json(follow_request)
|
||||
Oj.dump(serialize_payload(follow_request, ActivityPub::RejectFollowSerializer))
|
||||
JSON.dump(serialize_payload(follow_request, ActivityPub::RejectFollowSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ class RemoveDomainsFromFollowersService < BaseService
|
|||
end
|
||||
|
||||
def build_json(follow)
|
||||
Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer))
|
||||
JSON.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,6 @@ class RemoveFeaturedTagService < BaseService
|
|||
private
|
||||
|
||||
def build_json(featured_tag)
|
||||
Oj.dump(serialize_payload(featured_tag, ActivityPub::RemoveSerializer, signer: @account))
|
||||
JSON.dump(serialize_payload(featured_tag, ActivityPub::RemoveSerializer, signer: @account))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ class RemoveFromFollowersService < BaseService
|
|||
end
|
||||
|
||||
def build_json(follow)
|
||||
Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer))
|
||||
JSON.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class RemoveStatusService < BaseService
|
|||
# @option [Boolean] :original_removed
|
||||
# @option [Boolean] :skip_streaming
|
||||
def call(status, **options)
|
||||
@payload = Oj.dump(event: :delete, payload: status.id.to_s)
|
||||
@payload = JSON.dump(event: :delete, payload: status.id.to_s)
|
||||
@status = status
|
||||
@account = status.account
|
||||
@options = options
|
||||
|
@ -100,7 +100,7 @@ class RemoveStatusService < BaseService
|
|||
end
|
||||
|
||||
def signed_activity_json
|
||||
@signed_activity_json ||= Oj.dump(serialize_payload(@status, @status.reblog? ? ActivityPub::UndoAnnounceSerializer : ActivityPub::DeleteSerializer, signer: @account, always_sign: true))
|
||||
@signed_activity_json ||= JSON.dump(serialize_payload(@status, @status.reblog? ? ActivityPub::UndoAnnounceSerializer : ActivityPub::DeleteSerializer, signer: @account, always_sign: true))
|
||||
end
|
||||
|
||||
def remove_reblogs
|
||||
|
|
|
@ -92,7 +92,7 @@ class ReportService < BaseService
|
|||
end
|
||||
|
||||
def payload
|
||||
Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
|
||||
JSON.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
|
||||
end
|
||||
|
||||
def some_local_account
|
||||
|
|
|
@ -20,9 +20,9 @@ class SoftwareUpdateCheckService < BaseService
|
|||
|
||||
def fetch_update_notices
|
||||
Request.new(:get, "#{api_url}?version=#{version}").add_headers('Accept' => 'application/json', 'User-Agent' => 'Mastodon update checker').perform do |res|
|
||||
return Oj.load(res.body_with_limit, mode: :strict) if res.code == 200
|
||||
return JSON.parse(res.body_with_limit) if res.code == 200
|
||||
end
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, Oj::ParseError
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class SuspendAccountService < BaseService
|
|||
|
||||
Follow.where(account: @account).find_in_batches do |follows|
|
||||
ActivityPub::DeliveryWorker.push_bulk(follows) do |follow|
|
||||
[Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url]
|
||||
[JSON.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url]
|
||||
end
|
||||
|
||||
follows.each(&:destroy)
|
||||
|
@ -102,6 +102,6 @@ class SuspendAccountService < BaseService
|
|||
end
|
||||
|
||||
def signed_activity_json
|
||||
@signed_activity_json ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
|
||||
@signed_activity_json ||= JSON.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ class UnblockService < BaseService
|
|||
end
|
||||
|
||||
def build_json(unblock)
|
||||
Oj.dump(serialize_payload(unblock, ActivityPub::UndoBlockSerializer))
|
||||
JSON.dump(serialize_payload(unblock, ActivityPub::UndoBlockSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ class UnfavouriteService < BaseService
|
|||
end
|
||||
|
||||
def build_json(favourite)
|
||||
Oj.dump(serialize_payload(favourite, ActivityPub::UndoLikeSerializer))
|
||||
JSON.dump(serialize_payload(favourite, ActivityPub::UndoLikeSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,10 +63,10 @@ class UnfollowService < BaseService
|
|||
end
|
||||
|
||||
def build_json(follow)
|
||||
Oj.dump(serialize_payload(follow, ActivityPub::UndoFollowSerializer))
|
||||
JSON.dump(serialize_payload(follow, ActivityPub::UndoFollowSerializer))
|
||||
end
|
||||
|
||||
def build_reject_json(follow)
|
||||
Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer))
|
||||
JSON.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -98,6 +98,6 @@ class UnsuspendAccountService < BaseService
|
|||
end
|
||||
|
||||
def signed_activity_json
|
||||
@signed_activity_json ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
|
||||
@signed_activity_json ||= JSON.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -65,7 +65,7 @@ class VoteService < BaseService
|
|||
end
|
||||
|
||||
def build_json(vote)
|
||||
Oj.dump(serialize_payload(vote, ActivityPub::VoteSerializer))
|
||||
JSON.dump(serialize_payload(vote, ActivityPub::VoteSerializer))
|
||||
end
|
||||
|
||||
def increment_voters_count!
|
||||
|
|
|
@ -17,6 +17,6 @@ class WebhookService < BaseService
|
|||
end
|
||||
|
||||
def serialize_event
|
||||
Oj.dump(ActiveModelSerializers::SerializableResource.new(@event, serializer: REST::Admin::WebhookEventSerializer, scope: nil, scope_name: :current_user).as_json)
|
||||
JSON.dump(ActiveModelSerializers::SerializableResource.new(@event, serializer: REST::Admin::WebhookEventSerializer, scope: nil, scope_name: :current_user).as_json)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ReactionValidator < ActiveModel::Validator
|
||||
SUPPORTED_EMOJIS = Oj.load_file(Rails.root.join('app', 'javascript', 'mastodon', 'features', 'emoji', 'emoji_map.json').to_s).keys.freeze
|
||||
SUPPORTED_EMOJIS = JSON.load_file(Rails.root.join('app', 'javascript', 'mastodon', 'features', 'emoji', 'emoji_map.json').to_s).keys.freeze
|
||||
|
||||
LIMIT = 8
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
= render_initial_state
|
||||
= javascript_pack_tag 'application', crossorigin: 'anonymous'
|
||||
|
||||
.notranslate.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
|
||||
.notranslate.app-holder#mastodon{ data: { props: JSON.dump(default_props) } }
|
||||
%noscript
|
||||
= image_tag frontend_asset_path('images/logo.svg'), alt: 'Mastodon'
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
= render_initial_state
|
||||
= javascript_pack_tag 'share', crossorigin: 'anonymous'
|
||||
|
||||
#mastodon-compose{ data: { props: Oj.dump(default_props) } }
|
||||
#mastodon-compose{ data: { props: JSON.dump(default_props) } }
|
||||
|
|
|
@ -1 +1 @@
|
|||
#mastodon-status{ data: { props: Oj.dump(default_props.merge(id: @status.id.to_s)) } }
|
||||
#mastodon-status{ data: { props: JSON.dump(default_props.merge(id: @status.id.to_s)) } }
|
||||
|
|
|
@ -43,7 +43,7 @@ class ActivityPub::DistributePollUpdateWorker
|
|||
end
|
||||
|
||||
def payload
|
||||
@payload ||= Oj.dump(serialize_payload(@status, ActivityPub::UpdatePollSerializer, signer: @account))
|
||||
@payload ||= JSON.dump(serialize_payload(@status, ActivityPub::UpdatePollSerializer, signer: @account))
|
||||
end
|
||||
|
||||
def relay!
|
||||
|
|
|
@ -19,7 +19,7 @@ class ActivityPub::DistributionWorker < ActivityPub::RawDistributionWorker
|
|||
end
|
||||
|
||||
def payload
|
||||
@payload ||= Oj.dump(serialize_payload(activity, ActivityPub::ActivitySerializer, signer: @account))
|
||||
@payload ||= JSON.dump(serialize_payload(activity, ActivityPub::ActivitySerializer, signer: @account))
|
||||
end
|
||||
|
||||
def activity
|
||||
|
|
|
@ -28,6 +28,6 @@ class ActivityPub::MoveDistributionWorker
|
|||
end
|
||||
|
||||
def signed_payload
|
||||
@signed_payload ||= Oj.dump(serialize_payload(@migration, ActivityPub::MoveSerializer, signer: @account))
|
||||
@signed_payload ||= JSON.dump(serialize_payload(@migration, ActivityPub::MoveSerializer, signer: @account))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,6 @@ class ActivityPub::UpdateDistributionWorker < ActivityPub::RawDistributionWorker
|
|||
end
|
||||
|
||||
def payload
|
||||
@payload ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account, sign_with: @options[:sign_with]))
|
||||
@payload ||= JSON.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account, sign_with: @options[:sign_with]))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class PublishAnnouncementReactionWorker
|
|||
reaction ||= announcement.announcement_reactions.new(name: name)
|
||||
|
||||
payload = InlineRenderer.render(reaction, nil, :reaction).tap { |h| h[:announcement_id] = announcement_id.to_s }
|
||||
payload = Oj.dump(event: :'announcement.reaction', payload: payload)
|
||||
payload = JSON.dump(event: :'announcement.reaction', payload: payload)
|
||||
|
||||
FeedManager.instance.with_active_accounts do |account|
|
||||
redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
|
||||
|
|
|
@ -12,7 +12,7 @@ class PublishScheduledAnnouncementWorker
|
|||
@announcement.publish! unless @announcement.published?
|
||||
|
||||
payload = InlineRenderer.render(@announcement, nil, :announcement)
|
||||
payload = Oj.dump(event: :announcement, payload: payload)
|
||||
payload = JSON.dump(event: :announcement, payload: payload)
|
||||
|
||||
FeedManager.instance.with_active_accounts do |account|
|
||||
redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
|
||||
|
|
|
@ -9,7 +9,7 @@ class PushConversationWorker
|
|||
message = InlineRenderer.render(conversation, conversation.account, :conversation)
|
||||
timeline_id = "timeline:direct:#{conversation.account_id}"
|
||||
|
||||
redis.publish(timeline_id, Oj.dump(event: :conversation, payload: message))
|
||||
redis.publish(timeline_id, JSON.dump(event: :conversation, payload: message))
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ class PushUpdateWorker
|
|||
end
|
||||
|
||||
def message
|
||||
Oj.dump(
|
||||
JSON.dump(
|
||||
event: update? ? :'status.update' : :update,
|
||||
payload: @payload
|
||||
)
|
||||
|
|
|
@ -60,7 +60,7 @@ class Scheduler::SelfDestructScheduler
|
|||
adapter: ActivityPub::Adapter
|
||||
).as_json
|
||||
|
||||
json = Oj.dump(ActivityPub::LinkedDataSignature.new(payload).sign!(account))
|
||||
json = JSON.dump(ActivityPub::LinkedDataSignature.new(payload).sign!(account))
|
||||
|
||||
ActivityPub::DeliveryWorker.push_bulk(inboxes, limit: 1_000) do |inbox_url|
|
||||
[json, account.id, inbox_url]
|
||||
|
|
|
@ -54,7 +54,7 @@ class UnfilterNotificationsWorker
|
|||
end
|
||||
|
||||
def push_streaming_event!
|
||||
redis.publish("timeline:#{@recipient.id}:notifications", Oj.dump(event: :notifications_merged, payload: '1'))
|
||||
redis.publish("timeline:#{@recipient.id}:notifications", JSON.dump(event: :notifications_merged, payload: '1'))
|
||||
end
|
||||
|
||||
def subscribed_to_streaming_api?
|
||||
|
|
|
@ -5,7 +5,7 @@ class UnpublishAnnouncementWorker
|
|||
include Redisable
|
||||
|
||||
def perform(announcement_id)
|
||||
payload = Oj.dump(event: :'announcement.delete', payload: announcement_id.to_s)
|
||||
payload = JSON.dump(event: :'announcement.delete', payload: announcement_id.to_s)
|
||||
|
||||
FeedManager.instance.with_active_accounts do |account|
|
||||
redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
|
||||
|
|
|
@ -60,7 +60,7 @@ class Web::PushNotificationWorker
|
|||
|
||||
def push_notification_json
|
||||
I18n.with_locale(@subscription.locale.presence || I18n.default_locale) do
|
||||
Oj.dump(serialized_notification.as_json)
|
||||
JSON.dump(serialized_notification.as_json)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
27
bin/bundler-audit
Executable file
27
bin/bundler-audit
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'bundler-audit' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
|
||||
bundle_binstub = File.expand_path("bundle", __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
||||
load Gem.bin_path("bundler-audit", "bundler-audit")
|
27
bin/haml-lint
Executable file
27
bin/haml-lint
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'haml-lint' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
|
||||
bundle_binstub = File.expand_path("bundle", __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
||||
load Gem.bin_path("haml_lint", "haml-lint")
|
27
bin/i18n-tasks
Executable file
27
bin/i18n-tasks
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'i18n-tasks' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
|
||||
bundle_binstub = File.expand_path("bundle", __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
||||
load Gem.bin_path("i18n-tasks", "i18n-tasks")
|
16
bin/rspec
16
bin/rspec
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
|
@ -7,9 +8,18 @@
|
|||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
require "pathname"
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
||||
Pathname.new(__FILE__).realpath)
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
|
||||
bundle_binstub = File.expand_path("bundle", __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Oj.default_options = { mode: :compat, time_format: :ruby, use_to_json: true }
|
|
@ -28,7 +28,7 @@ class RejectFollowingBlockedUsers < ActiveRecord::Migration[5.2]
|
|||
|
||||
next follow.destroy! if blocked_account.local?
|
||||
|
||||
reject_follow_json = Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new(follow, serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).as_json).sign!(followed_account))
|
||||
reject_follow_json = JSON.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new(follow, serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).as_json).sign!(followed_account))
|
||||
|
||||
ActivityPub::DeliveryWorker.perform_async(reject_follow_json, followed_account, blocked_account.inbox_url)
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class MoveUserSettings < ActiveRecord::Migration[6.1]
|
|||
end
|
||||
end
|
||||
|
||||
user.update_column('settings', Oj.dump(user_settings))
|
||||
user.update_column('settings', JSON.dump(user_settings))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class MigrateInteractionSettingsToPolicy < ActiveRecord::Migration[7.1]
|
|||
private
|
||||
|
||||
def policy_for_user(user)
|
||||
deserialized_settings = Oj.load(user.attributes_before_type_cast['settings'])
|
||||
deserialized_settings = JSON.parse(user.attributes_before_type_cast['settings'])
|
||||
return if deserialized_settings.nil?
|
||||
|
||||
requires_new_policy = false
|
||||
|
|
|
@ -11,11 +11,11 @@ class FixKmrLocaleSettings < ActiveRecord::Migration[7.0]
|
|||
MigrationUser.reset_column_information
|
||||
|
||||
MigrationUser.where.not(settings: [nil, '{}']).find_each do |user|
|
||||
user_settings = Oj.load(user.settings)
|
||||
user_settings = JSON.parse(user.settings)
|
||||
next unless user_settings['default_language'] == 'kmr'
|
||||
|
||||
user_settings['default_language'] = 'ku'
|
||||
user.update!(settings: Oj.dump(user_settings))
|
||||
user.update!(settings: JSON.dump(user_settings))
|
||||
end
|
||||
|
||||
MigrationUser.where.not(chosen_languages: nil).where('chosen_languages && ?', '{kmr}').find_each do |user|
|
||||
|
|
|
@ -21,7 +21,7 @@ class MigrateInteractionSettingsToPolicyAgain < ActiveRecord::Migration[7.1]
|
|||
private
|
||||
|
||||
def policy_for_user(user)
|
||||
deserialized_settings = Oj.load(user.attributes_before_type_cast['settings'])
|
||||
deserialized_settings = JSON.parse(user.attributes_before_type_cast['settings'])
|
||||
return if deserialized_settings.nil?
|
||||
return if user.notification_policy.present?
|
||||
|
||||
|
|
|
@ -140,13 +140,13 @@ module Mastodon::CLI
|
|||
Request.new(:get, "https://#{domain}/api/v1/instance").perform do |res|
|
||||
next unless res.code == 200
|
||||
|
||||
stats[domain] = Oj.load(res.to_s)
|
||||
stats[domain] = JSON.parse(res.to_s)
|
||||
end
|
||||
|
||||
Request.new(:get, "https://#{domain}/api/v1/instance/peers").perform do |res|
|
||||
next unless res.code == 200
|
||||
|
||||
Oj.load(res.to_s).reject { |peer| stats.key?(peer) }.each do |peer|
|
||||
JSON.parse(res.to_s).reject { |peer| stats.key?(peer) }.each do |peer|
|
||||
pool.post(peer, &work_unit)
|
||||
end
|
||||
end
|
||||
|
@ -154,7 +154,7 @@ module Mastodon::CLI
|
|||
Request.new(:get, "https://#{domain}/api/v1/instance/activity").perform do |res|
|
||||
next unless res.code == 200
|
||||
|
||||
stats[domain]['activity'] = Oj.load(res.to_s)
|
||||
stats[domain]['activity'] = JSON.parse(res.to_s)
|
||||
end
|
||||
rescue
|
||||
failed.increment
|
||||
|
@ -214,7 +214,7 @@ module Mastodon::CLI
|
|||
|
||||
def stats_to_json(stats)
|
||||
stats.compact!
|
||||
say(Oj.dump(stats))
|
||||
say(JSON.dump(stats))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace :emojis do
|
|||
|
||||
map = map.sort { |a, b| a[0].size <=> b[0].size }.to_h
|
||||
|
||||
File.write(dest, Oj.dump(map))
|
||||
File.write(dest, JSON.dump(map))
|
||||
puts "Wrote emojo to destination! (#{dest})"
|
||||
end
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace :emojis do
|
|||
emojis_light = '👽⚾🐔☁️💨🕊️👀🍥👻🐐❕❔⛸️🌩️🔊🔇📃🌧️🐏🍚🍙🐓🐑💀☠️🌨️🔉🔈💬💭🏐🏳️⚪⬜◽◻️▫️🪽🪿'
|
||||
emojis_dark = '🎱🐜⚫🖤⬛◼️◾◼️✒️▪️💣🎳📷📸♣️🕶️✴️🔌💂♀️📽️🍳🦍💂🔪🕳️🕹️🕋🖊️🖋️💂♂️🎤🎓🎥🎼♠️🎩🦃📼📹🎮🐃🏴🐞🕺📱📲🚲🪮🐦⬛'
|
||||
|
||||
map = Oj.load(File.read(src))
|
||||
map = JSON.parse(File.read(src))
|
||||
|
||||
emojis_light.each_grapheme_cluster do |emoji|
|
||||
gen_border map[emoji], 'black'
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace :repo do
|
|||
|
||||
while url.present?
|
||||
response = HTTP.get(url)
|
||||
contributors = Oj.load(response.body)
|
||||
contributors = JSON.parse(response.body)
|
||||
|
||||
contributors.each do |c|
|
||||
file << "* [#{c['login']}](#{c['html_url']})\n" if c['login']
|
||||
|
@ -68,7 +68,7 @@ namespace :repo do
|
|||
end
|
||||
end
|
||||
|
||||
pull_request = Oj.load(response.to_s)
|
||||
pull_request = JSON.parse(response.to_s)
|
||||
pull_request['user']['login']
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const config = {
|
|||
'Capfile|Gemfile|*.{rb,ruby,ru,rake}': 'bin/rubocop --force-exclusion -a',
|
||||
'*.{js,jsx,ts,tsx}': 'eslint --fix',
|
||||
'*.{css,scss}': 'stylelint --fix',
|
||||
'*.haml': 'bundle exec haml-lint -a',
|
||||
'*.haml': 'bin/haml-lint -a',
|
||||
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
context 'when sender is followed by a local account' do
|
||||
before do
|
||||
Fabricate(:account).follow!(sender)
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: JSON.dump(unknown_object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
subject.perform
|
||||
end
|
||||
|
||||
|
@ -120,7 +120,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
let(:object_json) { 'https://example.com/actor/hello-world' }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: JSON.dump(unknown_object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
context 'when the relay is enabled' do
|
||||
|
|
|
@ -983,7 +983,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
before do
|
||||
stub_request(:get, object_json[:id])
|
||||
.with(headers: { Authorization: "Bearer #{token}" })
|
||||
.to_return(body: Oj.dump(object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
.to_return(body: JSON.dump(object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
|
||||
subject.perform
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe ActivityPub::Dereferencer do
|
|||
let(:uri) { nil }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/foo').to_return(body: Oj.dump(object), headers: { 'Content-Type' => 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/foo').to_return(body: JSON.dump(object), headers: { 'Content-Type' => 'application/activity+json' })
|
||||
end
|
||||
|
||||
context 'with a URI' do
|
||||
|
|
|
@ -522,7 +522,7 @@ RSpec.describe FeedManager do
|
|||
allow(redis).to receive_messages(publish: nil)
|
||||
subject.unpush_from_home(receiver, status)
|
||||
|
||||
deletion = Oj.dump(event: :delete, payload: status.id.to_s)
|
||||
deletion = JSON.dump(event: :delete, payload: status.id.to_s)
|
||||
expect(redis).to have_received(:publish).with("timeline:#{receiver.id}", deletion)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -87,7 +87,7 @@ RSpec.describe Mastodon::CLI::Domains do
|
|||
end
|
||||
|
||||
def json_summary
|
||||
Oj.dump('host.example': { activity: {} })
|
||||
JSON.dump('host.example': { activity: {} })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Webfinger do
|
|||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/activity+json' }] } }
|
||||
|
||||
it 'correctly parses the response' do
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: JSON.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
|
||||
response = described_class.new('acct:alice@example.com').perform
|
||||
|
||||
|
@ -20,7 +20,7 @@ RSpec.describe Webfinger do
|
|||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }] } }
|
||||
|
||||
it 'correctly parses the response' do
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: JSON.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
|
||||
response = described_class.new('acct:alice@example.com').perform
|
||||
|
||||
|
@ -32,7 +32,7 @@ RSpec.describe Webfinger do
|
|||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/json"' }] } }
|
||||
|
||||
it 'raises an error' do
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: JSON.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
|
||||
expect { described_class.new('acct:alice@example.com').perform }.to raise_error(Webfinger::Error)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe Webhooks::PayloadRenderer do
|
|||
|
||||
let(:event) { Webhooks::EventPresenter.new(type, object) }
|
||||
let(:payload) { ActiveModelSerializers::SerializableResource.new(event, serializer: REST::Admin::WebhookEventSerializer, scope: nil, scope_name: :current_user).as_json }
|
||||
let(:json) { Oj.dump(payload) }
|
||||
let(:json) { JSON.dump(payload) }
|
||||
|
||||
describe '#render' do
|
||||
context 'when event is account.approved' do
|
||||
|
|
|
@ -506,7 +506,7 @@ RSpec.describe User do
|
|||
expect { web_push_subscription.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(redis_pipeline_stub)
|
||||
.to have_received(:publish).with("timeline:access_token:#{access_token.id}", Oj.dump(event: :kill)).once
|
||||
.to have_received(:publish).with("timeline:access_token:#{access_token.id}", JSON.dump(event: :kill)).once
|
||||
end
|
||||
|
||||
def remove_activated_sessions
|
||||
|
|
|
@ -210,7 +210,7 @@ RSpec.describe 'Filters' do
|
|||
|
||||
expect(keyword.reload.keyword).to eq 'updated'
|
||||
|
||||
expect(redis).to have_received(:publish).with("timeline:#{user.account.id}", Oj.dump(event: :filters_changed)).once
|
||||
expect(redis).to have_received(:publish).with("timeline:#{user.account.id}", JSON.dump(event: :filters_changed)).once
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user