diff options
author | trwnh <a@trwnh.com> | 2022-11-08 09:39:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-08 16:39:15 +0100 |
commit | 89e1974f30709fdb98d7484561c371980f37b700 (patch) | |
tree | 845360fc4c5a44c619b0a940546a424ee934840c /app/controllers/api/v1/accounts | |
parent | 455a754081cd5ba7b5b4979cc62cb1d2f7867ed5 (diff) |
Make account endorsements idempotent (fix #19045) (#20118)
* Make account endorsements idempotent (fix #19045) * Accept suggestion to use exists? instead of find_by + nil check Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh> * fix logic (unless, not if) * switch to using `find_or_create_by!` Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>
Diffstat (limited to 'app/controllers/api/v1/accounts')
-rw-r--r-- | app/controllers/api/v1/accounts/pins_controller.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/controllers/api/v1/accounts/pins_controller.rb b/app/controllers/api/v1/accounts/pins_controller.rb index 3915b5669..73f845c61 100644 --- a/app/controllers/api/v1/accounts/pins_controller.rb +++ b/app/controllers/api/v1/accounts/pins_controller.rb @@ -8,7 +8,7 @@ class Api::V1::Accounts::PinsController < Api::BaseController before_action :set_account def create - AccountPin.create!(account: current_account, target_account: @account) + AccountPin.find_or_create_by!(account: current_account, target_account: @account) render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter end |