Fix raising validation if followable already exist(race condition) (#5826)

* Fix raising validation if followable already exist(race condition)

* Change Rails Logger for DataDogStatsClient and remove 'begin' keyword in follow method

Co-authored-by: Gonzalo Ricco <gonzalo.ricco@leniolabs.com>
This commit is contained in:
Gonzalo Ricco 2020-02-05 14:25:26 -03:00 committed by GitHub
parent 28440d1fa1
commit dd796aaef3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -70,8 +70,10 @@ class FollowsController < ApplicationController
def follow(followable, need_notification: false)
user_follow = current_user.follow(followable)
Notification.send_new_follower_notification(user_follow) if need_notification
"followed"
rescue ActiveRecord::RecordInvalid
DataDogStatsClient.increment("users.invalid_follow")
"already followed"
end
def unfollow(followable, need_notification: false)