check for recently submitted urls before showing the story submission page

this is already done after submitting, which turns it into an
upvote, but now it will catch it when hitting the page from the
bookmarklet so the user doesn't have to fill out tags and stuff
first just to find out it's already submitted.

since this requires no confirmation, don't count it as an upvote
automatically, just redirect to the story page
This commit is contained in:
joshua stein 2013-07-29 15:31:57 -05:00
parent 5c0dad2c4a
commit 2d18a3529d

View file

@ -87,6 +87,13 @@ class StoriesController < ApplicationController
if params[:url].present?
@story.url = params[:url]
# if this story was already submitted, don't bother the user filling out
# tags and stuff, just redirect them right away
if s = Story.find_recent_similar_by_url(@story.url)
flash[:success] = "This URL has already been submitted recently."
return redirect_to s.comments_url
end
if params[:title].present?
@story.title = params[:title]
end