posts: remove unused flag! and approve! methods.

These methods were unused outside of the test suite
This commit is contained in:
evazion
2021-10-11 20:05:09 -05:00
parent f155023b77
commit 341be51f95
10 changed files with 71 additions and 190 deletions

View File

@@ -254,18 +254,6 @@ class Post < ApplicationRecord
!is_active? && uploader != user
end
def flag!(reason, is_deletion: false)
flag = flags.create(reason: reason, is_deletion: is_deletion, creator: CurrentUser.user)
if flag.errors.any?
raise PostFlag::Error, flag.errors.full_messages.join("; ")
end
end
def approve!(approver = CurrentUser.user)
approvals.create(user: approver)
end
def disapproved_by?(user)
PostDisapproval.exists?(user_id: user.id, post_id: id)
end

View File

@@ -29,7 +29,7 @@ class PostApproval < ApplicationRecord
post.appeals.pending.update!(status: :succeeded)
post.update(approver: user, is_flagged: false, is_pending: false, is_deleted: false)
ModAction.log("undeleted post ##{post_id}", :post_undelete) if is_undeletion
ModAction.log("undeleted post ##{post_id}", :post_undelete, user) if is_undeletion
post.uploader.upload_limit.update_limit!(is_pending, true)
end

View File

@@ -1,6 +1,4 @@
class PostFlag < ApplicationRecord
class Error < StandardError; end
module Reasons
UNAPPROVED = "Unapproved in three days"
REJECTED = "Unapproved in three days after returning to moderation queue%"