2024-02-02 09:05:04 -06:00
|
|
|
class ApplicationController < ActionController::Base
|
2024-10-23 11:20:55 -04:00
|
|
|
include Onboardable, Localize, AutoSync, Authentication, Invitable, SelfHostable, StoreLocation, Impersonatable
|
2024-03-08 15:11:58 -05:00
|
|
|
include Pagy::Backend
|
2024-02-05 06:05:13 +11:00
|
|
|
|
2024-10-24 11:02:27 -04:00
|
|
|
helper_method :require_upgrade?, :subscription_pending?
|
|
|
|
|
2024-11-23 01:57:07 +05:30
|
|
|
before_action :detect_os
|
|
|
|
|
2024-07-26 18:00:41 +02:00
|
|
|
private
|
2024-10-24 11:02:27 -04:00
|
|
|
def require_upgrade?
|
|
|
|
return false if self_hosted?
|
|
|
|
return false unless Current.session
|
|
|
|
return false if Current.family.subscribed?
|
|
|
|
return false if subscription_pending? || request.path == settings_billing_path
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def subscription_pending?
|
|
|
|
subscribed_at = Current.session.subscribed_at
|
|
|
|
subscribed_at.present? && subscribed_at <= Time.current && subscribed_at > 1.hour.ago
|
|
|
|
end
|
2024-07-26 18:00:41 +02:00
|
|
|
|
|
|
|
def with_sidebar
|
|
|
|
return "turbo_rails/frame" if turbo_frame_request?
|
|
|
|
|
|
|
|
"with_sidebar"
|
|
|
|
end
|
2024-11-23 01:57:07 +05:30
|
|
|
|
|
|
|
def detect_os
|
|
|
|
user_agent = request.user_agent
|
|
|
|
@os = case user_agent
|
|
|
|
when /Windows/i then "windows"
|
|
|
|
when /Macintosh/i then "mac"
|
|
|
|
when /Linux/i then "linux"
|
|
|
|
when /Android/i then "android"
|
|
|
|
when /iPhone|iPad/i then "ios"
|
|
|
|
else ""
|
|
|
|
end
|
|
|
|
end
|
2024-02-02 09:05:04 -06:00
|
|
|
end
|