Merge pull request #309 from joppiesaus/commentsizelimitfix

Fix being able to comment more than size limit
This commit is contained in:
Kyle Drake 2019-06-30 12:51:01 -07:00 committed by GitHub
commit e1c4440612
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -16,7 +16,8 @@ post '/event/:event_id/comment' do |event_id|
if(site.is_blocking?(current_site) ||
site.profile_comments_enabled == false ||
current_site.commenting_allowed? == false ||
(current_site.is_a_jerk? && event.site_id != current_site.id && !site.is_following?(current_site)))
(current_site.is_a_jerk? && event.site_id != current_site.id && !site.is_following?(current_site)) ||
params[:message].length > Site::MAX_COMMENT_SIZE)
return {result: 'error'}.to_json
end
@ -28,7 +29,8 @@ post '/event/:event_id/update_profile_comment' do |event_id|
require_login
content_type :json
event = Event[id: event_id]
return {result: 'error'}.to_json unless current_site.id == event.profile_comment.actioning_site_id
return {result: 'error'}.to_json unless (current_site.id == event.profile_comment.actioning_site_id &&
params[:message].length <= Site::MAX_COMMENT_SIZE)
event.profile_comment.update message: params[:message]
return {result: 'success'}.to_json

View file

@ -163,6 +163,7 @@ post '/site/:username/comment' do |username|
if site.profile_comments_enabled == false ||
params[:message].empty? ||
params[:message].length > Site::MAX_COMMENT_SIZE ||
site.is_blocking?(current_site) ||
current_site.is_blocking?(site) ||
current_site.commenting_allowed? == false ||