2021-08-14 07:07:12 -07:00
|
|
|
class UserBan < ApplicationRecord
|
|
|
|
belongs_to :user
|
2022-06-26 02:01:39 -07:00
|
|
|
belongs_to :banned_by, class_name: "User", optional: true
|
2021-08-14 09:04:58 -07:00
|
|
|
|
2022-06-26 02:01:39 -07:00
|
|
|
scope :current, -> { where("expires_at IS NULL or expires_at > NOW()") }
|
|
|
|
|
|
|
|
def permanent?
|
|
|
|
expires_at.nil?
|
|
|
|
end
|
2022-07-02 03:53:14 -07:00
|
|
|
|
|
|
|
def current?
|
|
|
|
permanent? || expires_at > Time.now.utc
|
|
|
|
end
|
2021-08-14 07:07:12 -07:00
|
|
|
end
|