about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authoraschmitz <aschmitz@lardbucket.org>2017-11-11 14:37:23 -0600
committeraschmitz <aschmitz@lardbucket.org>2017-11-11 14:37:23 -0600
commit5128c4261e8c067321e70ffda560f14036f56bb0 (patch)
tree3dc0830509a5d8535f56e257fd034a7474570f02 /app
parentb95c48748cd4e7a1181cdf3f17e23d6e526a9d95 (diff)
Updates per code review
Thanks, @valerauko!
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v1/accounts_controller.rb2
-rw-r--r--app/models/concerns/account_interactions.rb5
-rw-r--r--app/services/follow_service.rb6
3 files changed, 4 insertions, 9 deletions
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb
index afdbf6e2d..85eb2d60e 100644
--- a/app/controllers/api/v1/accounts_controller.rb
+++ b/app/controllers/api/v1/accounts_controller.rb
@@ -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
diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb
index 60fd6ded5..a68f7c3d8 100644
--- a/app/models/concerns/account_interactions.rb
+++ b/app/models/concerns/account_interactions.rb
@@ -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
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb
index 6db591999..20579ca63 100644
--- a/app/services/follow_service.rb
+++ b/app/services/follow_service.rb
@@ -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