From e20895f251d28b3631b1f5768302517a5b687b04 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 5 Dec 2017 23:02:27 +0100 Subject: Add list of lists component to web UI (#5811) * Add list of lists component to web UI * Add list adding * Add list removing * List editor modal * Add API account search limited by following=true relation * Rework list editor modal * Remove mandatory pagination of GET /api/v1/lists/:id/accounts * Adjust search input placeholder * Fix rspec (#5890) * i18n: (zh-CN) Add missing translations for #5811 (#5891) * i18n: (zh-CN) yarn manage:translations -- zh-CN * i18n: (zh-CN) Add missing translations for #5811 * Fix some issues - Display loading/missing state for list timelines - Order lists alphabetically in overview - Fix async list editor reset - Redirect to /lists after deleting unpinned list - Redirect to / after pinning a list * Remove dead list columns when a list is deleted or fetch returns 404 --- app/controllers/api/v1/accounts/search_controller.rb | 9 +++++---- app/controllers/api/v1/lists/accounts_controller.rb | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/accounts/search_controller.rb b/app/controllers/api/v1/accounts/search_controller.rb index 2a5cac547..11e647c3c 100644 --- a/app/controllers/api/v1/accounts/search_controller.rb +++ b/app/controllers/api/v1/accounts/search_controller.rb @@ -17,12 +17,13 @@ class Api::V1::Accounts::SearchController < Api::BaseController AccountSearchService.new.call( params[:q], limit_param(DEFAULT_ACCOUNTS_LIMIT), - resolving_search?, - current_account + current_account, + resolve: truthy_param?(:resolve), + following: truthy_param?(:following) ) end - def resolving_search? - params[:resolve] == 'true' + def truthy_param?(key) + params[key] == 'true' end end diff --git a/app/controllers/api/v1/lists/accounts_controller.rb b/app/controllers/api/v1/lists/accounts_controller.rb index 40c485e8d..c29c73b3e 100644 --- a/app/controllers/api/v1/lists/accounts_controller.rb +++ b/app/controllers/api/v1/lists/accounts_controller.rb @@ -10,7 +10,7 @@ class Api::V1::Lists::AccountsController < Api::BaseController after_action :insert_pagination_headers, only: :show def show - @accounts = @list.accounts.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]) + @accounts = load_accounts render json: @accounts, each_serializer: REST::AccountSerializer end @@ -35,6 +35,14 @@ class Api::V1::Lists::AccountsController < Api::BaseController @list = List.where(account: current_account).find(params[:list_id]) end + def load_accounts + if unlimited? + @list.accounts.all + else + @list.accounts.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]) + end + end + def list_accounts Account.find(account_ids) end @@ -52,12 +60,16 @@ class Api::V1::Lists::AccountsController < Api::BaseController end def next_path + return if unlimited? + if records_continue? api_v1_list_accounts_url pagination_params(max_id: pagination_max_id) end end def prev_path + return if unlimited? + unless @accounts.empty? api_v1_list_accounts_url pagination_params(since_id: pagination_since_id) end @@ -78,4 +90,8 @@ class Api::V1::Lists::AccountsController < Api::BaseController def pagination_params(core_params) params.permit(:limit).merge(core_params) end + + def unlimited? + params[:limit] == '0' + end end -- cgit From 42bcbd36b72c7ddc5ae1ecced09614863ca382bd Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 6 Dec 2017 07:04:49 +0100 Subject: Remove rabl dependency (#5894) * Remove rabl dependency * Replicate old Oj configuration --- Gemfile | 1 - Gemfile.lock | 3 --- app/controllers/well_known/webfinger_controller.rb | 19 +--------------- app/models/account.rb | 15 +++++++++++++ app/serializers/webfinger_serializer.rb | 26 ++++++++++++++++++++++ app/views/well_known/webfinger/show.json.rabl | 18 --------------- app/views/well_known/webfinger/show.xml.ruby | 4 ++-- config/initializers/oj.rb | 1 + config/initializers/rabl_init.rb | 7 ------ 9 files changed, 45 insertions(+), 49 deletions(-) create mode 100644 app/serializers/webfinger_serializer.rb delete mode 100644 app/views/well_known/webfinger/show.json.rabl create mode 100644 config/initializers/oj.rb delete mode 100644 config/initializers/rabl_init.rb (limited to 'app/controllers') diff --git a/Gemfile b/Gemfile index d0b7aaef1..e43b1a256 100644 --- a/Gemfile +++ b/Gemfile @@ -49,7 +49,6 @@ gem 'oj', '~> 3.3' gem 'ostatus2', '~> 2.0' gem 'ox', '~> 2.8' gem 'pundit', '~> 1.1' -gem 'rabl', '~> 0.13' gem 'rack-attack', '~> 5.0' gem 'rack-cors', '~> 0.4', require: 'rack/cors' gem 'rack-timeout', '~> 0.4' diff --git a/Gemfile.lock b/Gemfile.lock index 37fc77fdf..5f050d031 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -334,8 +334,6 @@ GEM puma (3.11.0) pundit (1.1.0) activesupport (>= 3.0.0) - rabl (0.13.1) - activesupport (>= 2.3.14) rack (2.0.3) rack-attack (5.0.1) rack @@ -606,7 +604,6 @@ DEPENDENCIES pry-rails (~> 0.3) puma (~> 3.10) pundit (~> 1.1) - rabl (~> 0.13) rack-attack (~> 5.0) rack-cors (~> 0.4) rack-timeout (~> 0.4) diff --git a/app/controllers/well_known/webfinger_controller.rb b/app/controllers/well_known/webfinger_controller.rb index 1c27b2b18..5cc606808 100644 --- a/app/controllers/well_known/webfinger_controller.rb +++ b/app/controllers/well_known/webfinger_controller.rb @@ -6,12 +6,10 @@ module WellKnown def show @account = Account.find_local!(username_from_resource) - @canonical_account_uri = @account.to_webfinger_s - @magic_key = pem_to_magic_key(@account.keypair.public_key) respond_to do |format| format.any(:json, :html) do - render formats: :json, content_type: 'application/jrd+json' + render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json' end format.xml do @@ -35,21 +33,6 @@ module WellKnown WebfingerResource.new(resource_user).username end - def pem_to_magic_key(public_key) - modulus, exponent = [public_key.n, public_key.e].map do |component| - result = [] - - until component.zero? - result << [component % 256].pack('C') - component >>= 8 - end - - result.reverse.join - end - - (['RSA'] + [modulus, exponent].map { |n| Base64.urlsafe_encode64(n) }).join('.') - end - def resource_param params.require(:resource) end diff --git a/app/models/account.rb b/app/models/account.rb index 77b78ffef..e8a8c6560 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -184,6 +184,21 @@ class Account < ApplicationRecord @keypair ||= OpenSSL::PKey::RSA.new(private_key || public_key) end + def magic_key + modulus, exponent = [keypair.public_key.n, keypair.public_key.e].map do |component| + result = [] + + until component.zero? + result << [component % 256].pack('C') + component >>= 8 + end + + result.reverse.join + end + + (['RSA'] + [modulus, exponent].map { |n| Base64.urlsafe_encode64(n) }).join('.') + end + def subscription(webhook_url) @subscription ||= OStatus2::Subscription.new(remote_url, secret: secret, webhook: webhook_url, hub: hub_url) end diff --git a/app/serializers/webfinger_serializer.rb b/app/serializers/webfinger_serializer.rb new file mode 100644 index 000000000..f80d12c02 --- /dev/null +++ b/app/serializers/webfinger_serializer.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class WebfingerSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :subject, :aliases, :links + + def subject + object.to_webfinger_s + end + + def aliases + [short_account_url(object), account_url(object)] + end + + def links + [ + { rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: short_account_url(object) }, + { rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(object, format: 'atom') }, + { rel: 'self', type: 'application/activity+json', href: account_url(object) }, + { rel: 'salmon', href: api_salmon_url(object.id) }, + { rel: 'magic-public-key', href: "data:application/magic-public-key,#{object.magic_key}" }, + { rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}" }, + ] + end +end diff --git a/app/views/well_known/webfinger/show.json.rabl b/app/views/well_known/webfinger/show.json.rabl deleted file mode 100644 index 762d1860d..000000000 --- a/app/views/well_known/webfinger/show.json.rabl +++ /dev/null @@ -1,18 +0,0 @@ -object @account - -node(:subject) { @canonical_account_uri } - -node(:aliases) do - [short_account_url(@account), account_url(@account)] -end - -node(:links) do - [ - { rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: short_account_url(@account) }, - { rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }, - { rel: 'self', type: 'application/activity+json', href: account_url(@account) }, - { rel: 'salmon', href: api_salmon_url(@account.id) }, - { rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}" }, - { rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}" }, - ] -end diff --git a/app/views/well_known/webfinger/show.xml.ruby b/app/views/well_known/webfinger/show.xml.ruby index b0158b8bd..0c7289d6a 100644 --- a/app/views/well_known/webfinger/show.xml.ruby +++ b/app/views/well_known/webfinger/show.xml.ruby @@ -1,13 +1,13 @@ Nokogiri::XML::Builder.new do |xml| xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do - xml.Subject @canonical_account_uri + xml.Subject @account.to_webfinger_s xml.Alias short_account_url(@account) xml.Alias account_url(@account) xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: short_account_url(@account)) xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom')) xml.Link(rel: 'self', type: 'application/activity+json', href: account_url(@account)) xml.Link(rel: 'salmon', href: api_salmon_url(@account.id)) - xml.Link(rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}") + xml.Link(rel: 'magic-public-key', href: "data:application/magic-public-key,#{@account.magic_key}") xml.Link(rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}") end end.to_xml diff --git a/config/initializers/oj.rb b/config/initializers/oj.rb new file mode 100644 index 000000000..de3e17f2e --- /dev/null +++ b/config/initializers/oj.rb @@ -0,0 +1 @@ +Oj.default_options = { mode: :compat, time_format: :ruby, use_to_json: true } diff --git a/config/initializers/rabl_init.rb b/config/initializers/rabl_init.rb deleted file mode 100644 index 132a42144..000000000 --- a/config/initializers/rabl_init.rb +++ /dev/null @@ -1,7 +0,0 @@ -Rabl.configure do |config| - config.json_engine = Oj - config.cache_all_output = false - config.cache_sources = Rails.env.production? - config.include_json_root = false - config.view_paths = [Rails.root.join('app/views')] -end -- cgit From b21db9bbde3784556a5861e2cdec0c8c2184c72e Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Wed, 6 Dec 2017 19:41:57 +0900 Subject: Using double splat operator (#5859) --- app/controllers/api/v1/accounts_controller.rb | 2 +- app/helpers/admin/filter_helper.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/helpers/routing_helper.rb | 2 +- app/lib/activitypub/activity.rb | 4 ++-- app/lib/extractor.rb | 2 +- app/lib/formatter.rb | 2 +- app/lib/ostatus/activity/base.rb | 2 +- app/lib/ostatus/atom_serializer.rb | 2 +- app/lib/provider_discovery.rb | 2 +- app/lib/request.rb | 2 +- app/mailers/notification_mailer.rb | 2 +- app/mailers/user_mailer.rb | 6 +++--- app/models/remote_follow.rb | 4 ++-- app/models/session_activation.rb | 2 +- app/presenters/account_relationships_presenter.rb | 2 +- app/presenters/status_relationships_presenter.rb | 2 +- app/services/activitypub/process_collection_service.rb | 2 +- app/services/authorize_follow_service.rb | 2 +- app/services/post_status_service.rb | 2 +- app/services/process_feed_service.rb | 2 +- app/services/remove_status_service.rb | 2 +- app/services/suspend_account_service.rb | 2 +- lib/mastodon/migration_helpers.rb | 8 ++++---- spec/services/post_status_service_spec.rb | 2 +- 25 files changed, 32 insertions(+), 32 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index b1a2ed573..4e73e9e8b 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -51,7 +51,7 @@ class Api::V1::AccountsController < Api::BaseController @account = Account.find(params[:id]) end - def relationships(options = {}) + def relationships(**options) AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options) end end diff --git a/app/helpers/admin/filter_helper.rb b/app/helpers/admin/filter_helper.rb index 73250cbf5..9443934b3 100644 --- a/app/helpers/admin/filter_helper.rb +++ b/app/helpers/admin/filter_helper.rb @@ -13,7 +13,7 @@ module Admin::FilterHelper link_to text, new_url, class: filter_link_class(new_class) end - def table_link_to(icon, text, path, options = {}) + def table_link_to(icon, text, path, **options) link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link') end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7dfab1df1..8ed5c8bda 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,7 +5,7 @@ module ApplicationHelper current_page?(path) ? 'active' : '' end - def active_link_to(label, path, options = {}) + def active_link_to(label, path, **options) link_to label, path, options.merge(class: active_nav_class(path)) end diff --git a/app/helpers/routing_helper.rb b/app/helpers/routing_helper.rb index f4693358c..11894a895 100644 --- a/app/helpers/routing_helper.rb +++ b/app/helpers/routing_helper.rb @@ -11,7 +11,7 @@ module RoutingHelper end end - def full_asset_url(source, options = {}) + def full_asset_url(source, **options) source = ActionController::Base.helpers.asset_url(source, options) unless use_storage? URI.join(root_url, source).to_s diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 01144f595..820189d29 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -3,7 +3,7 @@ class ActivityPub::Activity include JsonLdHelper - def initialize(json, account, options = {}) + def initialize(json, account, **options) @json = json @account = account @object = @json['object'] @@ -15,7 +15,7 @@ class ActivityPub::Activity end class << self - def factory(json, account, options = {}) + def factory(json, account, **options) @json = json klass&.new(json, account, options) end diff --git a/app/lib/extractor.rb b/app/lib/extractor.rb index 738ec89a0..479689d60 100644 --- a/app/lib/extractor.rb +++ b/app/lib/extractor.rb @@ -32,7 +32,7 @@ module Extractor possible_entries end - def extract_hashtags_with_indices(text, _options = {}) + def extract_hashtags_with_indices(text, **) return [] unless text =~ /#/ tags = [] diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 9d8bc52db..f5bf64cc7 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -9,7 +9,7 @@ class Formatter include ActionView::Helpers::TextHelper - def format(status, options = {}) + def format(status, **options) if status.reblog? prepend_reblog = status.reblog.account.acct status = status.proper diff --git a/app/lib/ostatus/activity/base.rb b/app/lib/ostatus/activity/base.rb index 8b27b124f..c5933f3ad 100644 --- a/app/lib/ostatus/activity/base.rb +++ b/app/lib/ostatus/activity/base.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class OStatus::Activity::Base - def initialize(xml, account = nil, options = {}) + def initialize(xml, account = nil, **options) @xml = xml @account = account @options = options diff --git a/app/lib/ostatus/atom_serializer.rb b/app/lib/ostatus/atom_serializer.rb index 3ca6c5943..656e45822 100644 --- a/app/lib/ostatus/atom_serializer.rb +++ b/app/lib/ostatus/atom_serializer.rb @@ -319,7 +319,7 @@ class OStatus::AtomSerializer private - def append_element(parent, name, content = nil, attributes = {}) + def append_element(parent, name, content = nil, **attributes) element = Ox::Element.new(name) attributes.each { |k, v| element[k] = sanitize_str(v) } element << sanitize_str(content) unless content.nil? diff --git a/app/lib/provider_discovery.rb b/app/lib/provider_discovery.rb index 5e02e6806..bcc4ed500 100644 --- a/app/lib/provider_discovery.rb +++ b/app/lib/provider_discovery.rb @@ -2,7 +2,7 @@ class ProviderDiscovery < OEmbed::ProviderDiscovery class << self - def discover_provider(url, options = {}) + def discover_provider(url, **options) res = Request.new(:get, url).perform format = options[:format] diff --git a/app/lib/request.rb b/app/lib/request.rb index 30ea0e7ee..7671f4ffc 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -5,7 +5,7 @@ class Request include RoutingHelper - def initialize(verb, url, options = {}) + def initialize(verb, url, **options) @verb = verb @url = Addressable::URI.parse(url).normalize @options = options diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index d79f26366..fd2b0649a 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -63,7 +63,7 @@ class NotificationMailer < ApplicationMailer end end - def digest(recipient, opts = {}) + def digest(recipient, **opts) @me = recipient @since = opts[:since] || @me.user.last_emailed_at || @me.user.current_sign_in_at @notifications = Notification.where(account: @me, activity_type: 'Mention').where('created_at > ?', @since) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index bdb29ebad..5a062dc25 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -5,7 +5,7 @@ class UserMailer < Devise::Mailer helper :instance - def confirmation_instructions(user, token, _opts = {}) + def confirmation_instructions(user, token, **) @resource = user @token = token @instance = Rails.configuration.x.local_domain @@ -17,7 +17,7 @@ class UserMailer < Devise::Mailer end end - def reset_password_instructions(user, token, _opts = {}) + def reset_password_instructions(user, token, **) @resource = user @token = token @instance = Rails.configuration.x.local_domain @@ -29,7 +29,7 @@ class UserMailer < Devise::Mailer end end - def password_change(user, _opts = {}) + def password_change(user, **) @resource = user @instance = Rails.configuration.x.local_domain diff --git a/app/models/remote_follow.rb b/app/models/remote_follow.rb index c3f867743..070144e2d 100644 --- a/app/models/remote_follow.rb +++ b/app/models/remote_follow.rb @@ -7,8 +7,8 @@ class RemoteFollow validates :acct, presence: true - def initialize(attrs = {}) - @acct = attrs[:acct].gsub(/\A@/, '').strip unless attrs[:acct].nil? + def initialize(attrs = nil) + @acct = attrs[:acct].gsub(/\A@/, '').strip if !attrs.nil? && !attrs[:acct].nil? end def valid? diff --git a/app/models/session_activation.rb b/app/models/session_activation.rb index d19489b36..8b711d0d6 100644 --- a/app/models/session_activation.rb +++ b/app/models/session_activation.rb @@ -53,7 +53,7 @@ class SessionActivation < ApplicationRecord id && where(session_id: id).exists? end - def activate(options = {}) + def activate(**options) activation = create!(options) purge_old activation diff --git a/app/presenters/account_relationships_presenter.rb b/app/presenters/account_relationships_presenter.rb index a30558bac..bf1ba3716 100644 --- a/app/presenters/account_relationships_presenter.rb +++ b/app/presenters/account_relationships_presenter.rb @@ -4,7 +4,7 @@ class AccountRelationshipsPresenter attr_reader :following, :followed_by, :blocking, :muting, :requested, :domain_blocking - def initialize(account_ids, current_account_id, options = {}) + def initialize(account_ids, current_account_id, **options) @following = Account.following_map(account_ids, current_account_id).merge(options[:following_map] || {}) @followed_by = Account.followed_by_map(account_ids, current_account_id).merge(options[:followed_by_map] || {}) @blocking = Account.blocking_map(account_ids, current_account_id).merge(options[:blocking_map] || {}) diff --git a/app/presenters/status_relationships_presenter.rb b/app/presenters/status_relationships_presenter.rb index bc3887a44..b04e10e2f 100644 --- a/app/presenters/status_relationships_presenter.rb +++ b/app/presenters/status_relationships_presenter.rb @@ -3,7 +3,7 @@ class StatusRelationshipsPresenter attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map - def initialize(statuses, current_account_id = nil, options = {}) + def initialize(statuses, current_account_id = nil, **options) if current_account_id.nil? @reblogs_map = {} @favourites_map = {} diff --git a/app/services/activitypub/process_collection_service.rb b/app/services/activitypub/process_collection_service.rb index db4d1b4bc..eb93329e9 100644 --- a/app/services/activitypub/process_collection_service.rb +++ b/app/services/activitypub/process_collection_service.rb @@ -3,7 +3,7 @@ class ActivityPub::ProcessCollectionService < BaseService include JsonLdHelper - def call(body, account, options = {}) + def call(body, account, **options) @account = account @json = Oj.load(body, mode: :strict) @options = options diff --git a/app/services/authorize_follow_service.rb b/app/services/authorize_follow_service.rb index b1bff8962..f47d488f1 100644 --- a/app/services/authorize_follow_service.rb +++ b/app/services/authorize_follow_service.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class AuthorizeFollowService < BaseService - def call(source_account, target_account, options = {}) + def call(source_account, target_account, **options) if options[:skip_follow_request] follow_request = FollowRequest.new(account: source_account, target_account: target_account) else diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index de350f8e6..92d868afe 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -13,7 +13,7 @@ class PostStatusService < BaseService # @option [Doorkeeper::Application] :application # @option [String] :idempotency Optional idempotency key # @return [Status] - def call(account, text, in_reply_to = nil, options = {}) + def call(account, text, in_reply_to = nil, **options) if options[:idempotency].present? existing_id = redis.get("idempotency:status:#{account.id}:#{options[:idempotency]}") return Status.find(existing_id) if existing_id diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 60eff135e..30a9dd85e 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class ProcessFeedService < BaseService - def call(body, account, options = {}) + def call(body, account, **options) @options = options xml = Nokogiri::XML(body) diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 9f603bb36..a100f73ce 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -3,7 +3,7 @@ class RemoveStatusService < BaseService include StreamEntryRenderer - def call(status, options = {}) + def call(status, **options) @payload = Oj.dump(event: :delete, payload: status.id.to_s) @status = status @account = status.account diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb index 5b37ba9ba..958b28cdc 100644 --- a/app/services/suspend_account_service.rb +++ b/app/services/suspend_account_service.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class SuspendAccountService < BaseService - def call(account, options = {}) + def call(account, **options) @account = account @options = options diff --git a/lib/mastodon/migration_helpers.rb b/lib/mastodon/migration_helpers.rb index 2b5a6cd42..6f6f99f63 100644 --- a/lib/mastodon/migration_helpers.rb +++ b/lib/mastodon/migration_helpers.rb @@ -99,7 +99,7 @@ module Mastodon # default - The default value for the column. # null - When set to `true` the column will allow NULL values. # The default is to not allow NULL values. - def add_timestamps_with_timezone(table_name, options = {}) + def add_timestamps_with_timezone(table_name, **options) options[:null] = false if options[:null].nil? [:created_at, :updated_at].each do |column_name| @@ -134,7 +134,7 @@ module Mastodon # add_concurrent_index :users, :some_column # # See Rails' `add_index` for more info on the available arguments. - def add_concurrent_index(table_name, column_name, options = {}) + def add_concurrent_index(table_name, column_name, **options) if transaction_open? raise 'add_concurrent_index can not be run inside a transaction, ' \ 'you can disable transactions by calling disable_ddl_transaction! ' \ @@ -158,7 +158,7 @@ module Mastodon # remove_concurrent_index :users, :some_column # # See Rails' `remove_index` for more info on the available arguments. - def remove_concurrent_index(table_name, column_name, options = {}) + def remove_concurrent_index(table_name, column_name, **options) if transaction_open? raise 'remove_concurrent_index can not be run inside a transaction, ' \ 'you can disable transactions by calling disable_ddl_transaction! ' \ @@ -182,7 +182,7 @@ module Mastodon # remove_concurrent_index :users, "index_X_by_Y" # # See Rails' `remove_index` for more info on the available arguments. - def remove_concurrent_index_by_name(table_name, index_name, options = {}) + def remove_concurrent_index_by_name(table_name, index_name, **options) if transaction_open? raise 'remove_concurrent_index_by_name can not be run inside a transaction, ' \ 'you can disable transactions by calling disable_ddl_transaction! ' \ diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 91902ff69..92fbc73cd 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -182,7 +182,7 @@ RSpec.describe PostStatusService do expect(status2.id).to eq status1.id end - def create_status_with_options(options = {}) + def create_status_with_options(**options) subject.call(Fabricate(:account), 'test', nil, options) end end -- cgit