1
0
mirror of https://github.com/mastodon/mastodon synced 2024-12-03 17:28:19 +09:00

Replace Oj with plain JSON across app/

This commit is contained in:
Matt Jankowski 2024-10-30 15:37:58 -04:00
parent c66405cdf4
commit 0742632007
68 changed files with 89 additions and 89 deletions

View File

@ -21,7 +21,7 @@ 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
false

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -191,7 +191,7 @@ 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

View File

@ -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

View File

@ -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

View File

@ -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!

View File

@ -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

View File

@ -20,7 +20,7 @@ class ActivityPub::Forwarder
private
def payload
@payload ||= Oj.dump(@json)
@payload ||= JSON.dump(@json)
end
def reblogged_by_account_ids

View File

@ -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',

View File

@ -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|

View File

@ -74,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
@ -101,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

View File

@ -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

View File

@ -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|

View File

@ -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|

View File

@ -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

View File

@ -6,7 +6,7 @@ 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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -359,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)

View File

@ -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)

View File

@ -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)

View File

@ -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!

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
)

View File

@ -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

View File

@ -93,7 +93,7 @@ class FetchOEmbedService
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

View File

@ -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

View File

@ -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?

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -20,7 +20,7 @@ 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
nil

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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!

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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) } }

View File

@ -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)) } }

View File

@ -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!

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}")

View File

@ -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}")

View File

@ -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

View File

@ -23,7 +23,7 @@ class PushUpdateWorker
end
def message
Oj.dump(
JSON.dump(
event: update? ? :'status.update' : :update,
payload: @payload
)

View File

@ -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]

View File

@ -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?

View File

@ -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}")

View File

@ -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