[Cleanup] Remove ban check when sending dmails

Banned users can't login in the first place
This commit is contained in:
Earlopain 2023-09-17 14:38:43 +02:00
parent 1c4a79d2ef
commit 9e2c7b2b5b
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
2 changed files with 0 additions and 23 deletions

View File

@ -2,7 +2,6 @@ class Dmail < ApplicationRecord
validates :title, :body, presence: { on: :create }
validates :title, length: { minimum: 1, maximum: 250 }
validates :body, length: { minimum: 1, maximum: Danbooru.config.dmail_max_size }
validate :sender_is_not_banned, on: :create
validate :recipient_accepts_dmails, on: :create
validate :user_not_limited, on: :create
@ -150,15 +149,6 @@ class Dmail < ApplicationRecord
true
end
def sender_is_not_banned
if from.try(:is_banned?)
errors.add(:base, "Sender is banned and cannot send messages")
return false
else
return true
end
end
def recipient_accepts_dmails
unless to
errors.add(:to_name, "not found")

View File

@ -54,19 +54,6 @@ class DmailTest < ActiveSupport::TestCase
end
end
context "from a banned user" do
setup do
@user.update_attribute(:is_banned, true)
end
should "not validate" do
dmail = build(:dmail, title: "xxx", owner: @user)
dmail.save
assert_equal(1, dmail.errors.size)
assert_equal(["Sender is banned and cannot send messages"], dmail.errors.full_messages)
end
end
context "search" do
should "return results based on title contents" do
dmail = create(:dmail, title: "xxx", body: "bbb", owner: @user)