Add configurable upload limits

This commit is contained in:
GiantFrog
2022-01-17 13:28:24 -07:00
parent d0ce511465
commit b1b706aaff
2 changed files with 21 additions and 5 deletions

View File

@@ -24,8 +24,8 @@
class UploadLimit
extend Memoist
INITIAL_POINTS = 1000
MAXIMUM_POINTS = 10_000
INITIAL_POINTS = Danbooru.config.initial_upload_points
MAXIMUM_POINTS = Danbooru.config.maximum_upload_points
APPEAL_COST = 3
DELETION_COST = 5
@@ -65,7 +65,7 @@ class UploadLimit
# @return [Integer] The user's total number of upload slots. Ranges from 5 to 40.
def upload_slots
upload_level + 5
upload_level + Danbooru.config.extra_upload_slots
end
# @return [Integer] The user's current upload level. Ranges from 0 to 35.
@@ -121,7 +121,7 @@ class UploadLimit
points += upload_value(points, is_deleted)
points = points.clamp(0, MAXIMUM_POINTS)
# warn "slots: %2d, points: %3d, value: %2d" % [UploadLimit.points_to_level(points) + 5, points, UploadLimit.upload_value(level, is_deleted)]
# warn "slots: %2d, points: %3d, value: %2d" % [UploadLimit.points_to_level(points) + Danbooru.config.extra_upload_slots, points, UploadLimit.upload_value(level, is_deleted)]
end
points

View File

@@ -174,7 +174,23 @@ module Danbooru
# How long pending posts stay in the modqueue before being deleted.
def moderation_period
3.days
end
end
# Upload points can be earned or lost by users. They punish and reward users by adding and removing upload slots.
# 1000 points is enough for 10 uploads. See app/logical/upload_limit.rb for details on the level system.
def initial_upload_points
1000
end
# The cap on how many upload points a user can earn.
def maximum_upload_points
10_000
end
# These slots are added to the ones earned by upload levels and guaranteed to all users, even those at level 0.
def extra_upload_slots
5
end
# https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
# https://guides.rubyonrails.org/configuring.html#configuring-action-mailer