Fix missing terms of services link (#35115)
This commit is contained in:
1 parent
3f743b1a07
commit
adf812efb3
5 files changed
+60
-3
No files matched your search
@@ -15,8 +15,9 @@ class Api::V1::Instances::TermsOfServicesController < Api::V1::Instances::BaseCo
|
||||
if params[:date].present?
|
||||
TermsOfService.published.find_by!(effective_date: params[:date])
|
||||
else
|
||||
TermsOfService.live.first || TermsOfService.published.first! # For the case when none of the published terms have become effective yet
|
||||
TermsOfService.current
|
||||
end
|
||||
end
|
||||
not_found if @terms_of_service.nil?
|
||||
end
|
||||
end
|
||||
@@ -16,6 +16,7 @@
|
||||
class TermsOfService < ApplicationRecord
|
||||
scope :published, -> { where.not(published_at: nil).order(Arel.sql('coalesce(effective_date, published_at) DESC')) }
|
||||
scope :live, -> { published.where('effective_date IS NULL OR effective_date < now()').limit(1) }
|
||||
scope :upcoming, -> { published.reorder(effective_date: :asc).where('effective_date IS NOT NULL AND effective_date > now()').limit(1) }
|
||||
scope :draft, -> { where(published_at: nil).order(id: :desc).limit(1) }
|
||||
|
||||
validates :text, presence: true
|
||||
@@ -26,6 +27,10 @@ class TermsOfService < ApplicationRecord
|
||||
|
||||
NOTIFICATION_ACTIVITY_CUTOFF = 1.year.freeze
|
||||
|
||||
def self.current
|
||||
live.first || upcoming.first # For the case when none of the published terms have become effective yet
|
||||
end
|
||||
|
||||
def published?
|
||||
published_at.present?
|
||||
end
|
||||
|
||||
@@ -110,7 +110,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||
trends_as_landing_page: Setting.trends_as_landing_page,
|
||||
trends_enabled: Setting.trends,
|
||||
version: instance_presenter.version,
|
||||
terms_of_service_enabled: TermsOfService.live.exists?,
|
||||
terms_of_service_enabled: TermsOfService.current.present?,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
status: object.status_page_url,
|
||||
about: about_url,
|
||||
privacy_policy: privacy_policy_url,
|
||||
terms_of_service: TermsOfService.live.exists? ? terms_of_service_url : nil,
|
||||
terms_of_service: TermsOfService.current.present? ? terms_of_service_url : nil,
|
||||
},
|
||||
|
||||
vapid: {
|
||||
|
||||
Reference in new issue
Block a user