]> cat aescling's git repositories - mastodon.git/commitdiff
Updates per code review
authoraschmitz <aschmitz@lardbucket.org>
Sat, 11 Nov 2017 20:37:23 +0000 (14:37 -0600)
committeraschmitz <aschmitz@lardbucket.org>
Sat, 11 Nov 2017 20:37:23 +0000 (14:37 -0600)
Thanks, @valerauko!

app/controllers/api/v1/accounts_controller.rb
app/models/concerns/account_interactions.rb
app/services/follow_service.rb

index afdbf6e2db3b369befe8e1aa705a24270e798106..85eb2d60e297d8fdc07a819e38706c8340c76738 100644 (file)
@@ -17,7 +17,7 @@ class Api::V1::AccountsController < Api::BaseController
     
     FollowService.new.call(current_user.account, @account.acct, reblogs_arg)
 
-    options = @account.locked? ? {} : { following_map: reblogs_arg, requested_map: { @account.id => false } }
+    options = @account.locked? ? {} : { following_map: { @account.id => reblogs_arg }, requested_map: { @account.id => false } }
 
     render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships(options)
   end
index 60fd6ded598c96f5a8325d686cddaae6eb581617..a68f7c3d850df48a6dc2f232ca9483715f01890c 100644 (file)
@@ -77,10 +77,7 @@ module AccountInteractions
   def follow!(other_account, reblogs: nil)
     reblogs = true if reblogs.nil?
     rel = active_relationships.create_with(show_reblogs: reblogs).find_or_create_by!(target_account: other_account)
-    if rel.show_reblogs != reblogs
-      rel.show_reblogs = reblogs
-      rel.save!
-    end
+    rel.update!(show_reblogs: reblogs)
 
     rel
   end
index 6db591999f91b7a8e7e612bb2dc12f815dc672bf..20579ca63a2b7484bc5e987e79324f0e0f642495 100644 (file)
@@ -6,6 +6,7 @@ class FollowService < BaseService
   # Follow a remote user, notify remote user about the follow
   # @param [Account] source_account From which to follow
   # @param [String, Account] uri User URI to follow in the form of username@domain (or account record)
+  # @param [true, false, nil] reblogs Whether or not to show reblogs, defaults to true
   def call(source_account, uri, reblogs: nil)
     reblogs = true if reblogs.nil?
     target_account = uri.is_a?(Account) ? uri : ResolveRemoteAccountService.new.call(uri)
@@ -22,10 +23,7 @@ class FollowService < BaseService
       # This isn't managed by a method in AccountInteractions, so we modify it
       # ourselves if necessary.
       req = follow_requests.find_by(target_account: other_account)
-      if req.show_reblogs != reblogs
-        req.show_reblogs = reblogs
-        req.save!
-      end
+      req.update!(show_reblogs: reblogs)
       return
     end