From dd796aaef3bbc5383808b7a5c52b340ba22f24ee Mon Sep 17 00:00:00 2001 From: Gonzalo Ricco Date: Wed, 5 Feb 2020 14:25:26 -0300 Subject: [PATCH] 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 --- app/controllers/follows_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 67c840e3c..8744bde39 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -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)