Skip to content

Commit

Permalink
Register TPU regardless of success state of spam flag
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Aug 31, 2018
1 parent 586ea34 commit 9330edb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ def delete_post
end

def cast_spam_flag
feedback = Feedback.new(feedback_type: 'tpu-',
user_id: current_user.id,
post_id: @post.id)

unless feedback.save
flash[:danger] = 'Unable to save feedback. Ping Undo.'
end

if current_user.api_token.blank?
flash[:warning] = 'You must be write-authenticated to cast a spam flag.'
redirect_to(authentication_status_path) && return
Expand All @@ -203,13 +211,6 @@ def cast_spam_flag
if result
flash[:success] = 'Spam flag cast successfully.'

feedback = Feedback.new(feedback_type: 'tpu-',
user_id: current_user.id,
post_id: @post.id)

unless feedback.save
flash[:danger] = 'Unable to save feedback. Ping Undo.'
end
else
flash[:danger] = "Spam flag not cast: #{message}"
end
Expand Down

0 comments on commit 9330edb

Please sign in to comment.