Add new upload limit system (fix #4234).
This commit is contained in:
@@ -1279,6 +1279,9 @@ class Post < ApplicationRecord
|
||||
# XXX This must happen *after* the `is_deleted` flag is set to true (issue #3419).
|
||||
give_favorites_to_parent(options) if options[:move_favorites]
|
||||
|
||||
is_automatic = (reason == "Unapproved in three days")
|
||||
uploader.new_upload_limit.update_limit!(self, incremental: is_automatic)
|
||||
|
||||
unless options[:without_mod_action]
|
||||
ModAction.log("deleted post ##{id}, reason: #{reason}", :post_delete)
|
||||
end
|
||||
|
||||
@@ -26,10 +26,13 @@ class PostApproval < ApplicationRecord
|
||||
end
|
||||
|
||||
def approve_post
|
||||
ModAction.log("undeleted post ##{post_id}", :post_undelete) if post.is_deleted
|
||||
is_undeletion = post.is_deleted
|
||||
|
||||
post.flags.each(&:resolve!)
|
||||
post.update(approver: user, is_flagged: false, is_pending: false, is_deleted: false)
|
||||
ModAction.log("undeleted post ##{post_id}", :post_undelete) if is_undeletion
|
||||
|
||||
post.uploader.new_upload_limit.update_limit!(post, incremental: !is_undeletion)
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
|
||||
@@ -468,6 +468,10 @@ class User < ApplicationRecord
|
||||
(is_moderator? && flag.not_uploaded_by?(id)) || flag.creator_id == id
|
||||
end
|
||||
|
||||
def new_upload_limit
|
||||
@new_upload_limit ||= UploadLimit.new(self)
|
||||
end
|
||||
|
||||
def upload_limit
|
||||
[max_upload_limit - used_upload_slots, 0].max
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user