Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/controllers/votes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ def create
post = Post.find(params[:post_id])

if post.user == current_user && !SiteSetting['AllowSelfVotes']
render(json: { status: 'failed', message: 'You may not vote on your own posts.' }, status: :forbidden)
render(json: { status: 'failed', message: I18n.t('votes.limits.own_post') },
status: :forbidden)
return
end

if !current_user.privilege?('unrestricted') && !current_user.owns_post_or_parent?(post)
render(json: { status: 'failed', message: I18n.t('votes.limits.restricted_ability') },
status: :forbidden)
return
end

Expand Down
5 changes: 4 additions & 1 deletion config/locales/strings/en.votes.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
en:
votes:
summary:
post_missing: 'Post not found'
post_missing: 'Post not found'
limits:
own_post: 'You may not vote on your own posts.'
restricted_ability: 'You must have the Participate Everywhere ability to vote on this post.'
Loading