appeals: raise appeal limits.

The old limit was one appeal per day. The new limit is based on your
upload limit. Each appeal costs 3 upload slots. If you have 15 upload
slots, then you can appeal up to 5 posts at once, but you won't be able
to appeal or upload more until your appeals are approved or rejected. If
you have unlimited uploads, then you have unlimited appeals.
This commit is contained in:
evazion
2020-08-08 10:37:51 -05:00
parent 3a17b5a13e
commit e8dcc9c56e
4 changed files with 48 additions and 31 deletions

View File

@@ -1,8 +1,4 @@
class PostAppeal < ApplicationRecord
class Error < StandardError; end
MAX_APPEALS_PER_DAY = 1
belongs_to :creator, :class_name => "User"
belongs_to :post
@@ -33,19 +29,13 @@ class PostAppeal < ApplicationRecord
extend SearchMethods
def validate_creator_is_not_limited
if appeal_count_for_creator >= MAX_APPEALS_PER_DAY
errors[:creator] << "can appeal at most #{MAX_APPEALS_PER_DAY} post a day"
end
errors[:creator] << "have reached your appeal limit" if creator.is_appeal_limited?
end
def validate_post_is_appealable
errors[:post] << "cannot be appealed" if post.is_status_locked? || !post.is_appealable?
end
def appeal_count_for_creator
creator.post_appeals.recent.count
end
def self.available_includes
[:creator, :post]
end

View File

@@ -349,6 +349,11 @@ class User < ApplicationRecord
end
end
def is_appeal_limited?
return false if can_upload_free?
upload_limit.free_upload_slots < UploadLimit::APPEAL_COST
end
def upload_limit
@upload_limit ||= UploadLimit.new(self)
end