Move post/comment ID boilerplate inside getters.
Borrows code from the upstream which has been working in production reliably for ~months. Also, most of it was literally copy-pasted, and the casted ID values aren't used later in the route functions.
This commit is contained in:
parent
1018cf3412
commit
cc27f00124
6 changed files with 10 additions and 36 deletions
|
@ -65,8 +65,6 @@ def api_vote_post(post_id, new, v):
|
|||
new = int(new)
|
||||
|
||||
# get the post
|
||||
try: post_id = int(post_id)
|
||||
except: abort(404)
|
||||
post = get_post(post_id)
|
||||
|
||||
# get the old vote, if we have one
|
||||
|
@ -135,8 +133,6 @@ def api_vote_comment(comment_id, new, v):
|
|||
new = int(new)
|
||||
|
||||
# get the comment
|
||||
try: comment_id = int(comment_id)
|
||||
except: abort(404)
|
||||
comment = get_comment(comment_id)
|
||||
|
||||
# get the old vote, if we have one
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue