2025-05-16 13:53:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2025-05-16 12:51:48 -04:00
|
|
|
class PointsLimitExceeded
|
|
|
|
|
def initialize(user)
|
|
|
|
|
@user = user
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def call
|
|
|
|
|
return false if DawarichSettings.self_hosted?
|
|
|
|
|
|
2025-07-21 16:27:20 -04:00
|
|
|
Rails.cache.fetch(cache_key, expires_in: 1.day) do
|
2025-08-21 16:32:29 -04:00
|
|
|
@user.points_count >= points_limit
|
2025-07-21 16:27:20 -04:00
|
|
|
end
|
2025-05-16 12:51:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
2025-07-21 16:27:20 -04:00
|
|
|
def cache_key
|
|
|
|
|
"points_limit_exceeded/#{@user.id}"
|
|
|
|
|
end
|
|
|
|
|
|
2025-05-16 12:51:48 -04:00
|
|
|
def points_limit
|
|
|
|
|
DawarichSettings::BASIC_PAID_PLAN_LIMIT
|
|
|
|
|
end
|
|
|
|
|
end
|