]> cat aescling's git repositories - mastodon.git/commitdiff
Less gross passing of notifications flag
authorSurinna Curtis <ekiru.0@gmail.com>
Fri, 28 Jul 2017 05:12:34 +0000 (00:12 -0500)
committerSurinna Curtis <ekiru.0@gmail.com>
Thu, 14 Sep 2017 02:47:30 +0000 (21:47 -0500)
app/controllers/api/v1/accounts_controller.rb
app/services/mute_service.rb

index ec3abfbf588c384c11b37882064804dfd6c6fa1f..de2cb0d97cbd65e31b7a3f786c1087672da47628 100644 (file)
@@ -33,7 +33,7 @@ class Api::V1::AccountsController < Api::BaseController
   end
 
   def mute
-    MuteService.new.call(current_user.account, @account, notifications: params[:notifications])
+    MuteService.new.call(current_user.account, @account, **params.permit(:notifications).to_hash.symbolize_keys)
     render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
   end
 
index d8a95f94bdea9697ce59fd61c40a224b84f9a9c6..fc63f83e92614e79c4a015b2ee9b960e6e0560e2 100644 (file)
@@ -1,13 +1,9 @@
 # frozen_string_literal: true
 
 class MuteService < BaseService
-  def call(account, target_account, notifications: nil)
+  def call(account, target_account, **opts)
     return if account.id == target_account.id
     FeedManager.instance.clear_from_timeline(account, target_account)
-    # This unwieldy approach avoids duplicating the default value here
-    # and in mute!.
-    opts = {}
-    opts[:notifications] = notifications unless notifications.nil?
-    account.mute!(target_account, **opts)
+    account.mute!(target_account, **opts.slice(:notifications))
   end
 end
This page took 0.021668 seconds and 3 git commands to generate.