about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/omniauthable.rb3
-rw-r--r--app/models/concerns/remotable.rb4
-rw-r--r--app/models/form/admin_settings.rb2
-rw-r--r--app/models/session_activation.rb2
-rw-r--r--app/models/setting.rb3
-rw-r--r--app/models/trends/history.rb4
-rw-r--r--app/models/user.rb2
7 files changed, 10 insertions, 10 deletions
diff --git a/app/models/concerns/omniauthable.rb b/app/models/concerns/omniauthable.rb
index feac0a1f5..7d54e9d6d 100644
--- a/app/models/concerns/omniauthable.rb
+++ b/app/models/concerns/omniauthable.rb
@@ -97,8 +97,7 @@ module Omniauthable
     def ensure_valid_username(starting_username)
       starting_username = starting_username.split('@')[0]
       temp_username = starting_username.gsub(/[^a-z0-9_]+/i, '')
-      validated_username = temp_username.truncate(30, omission: '')
-      validated_username
+      temp_username.truncate(30, omission: '')
     end
   end
 end
diff --git a/app/models/concerns/remotable.rb b/app/models/concerns/remotable.rb
index ffe8a7565..cb8f46e68 100644
--- a/app/models/concerns/remotable.rb
+++ b/app/models/concerns/remotable.rb
@@ -27,11 +27,11 @@ module Remotable
             public_send("#{attachment_name}=", ResponseWithLimit.new(response, limit))
           end
         rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError => e
-          Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
+          Rails.logger.debug { "Error fetching remote #{attachment_name}: #{e}" }
           public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present?
           raise e unless suppress_errors
         rescue Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Paperclip::Error, Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => e
-          Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
+          Rails.logger.debug { "Error fetching remote #{attachment_name}: #{e}" }
           public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present?
         end
 
diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb
index f76ee42e7..6b468e3ea 100644
--- a/app/models/form/admin_settings.rb
+++ b/app/models/form/admin_settings.rb
@@ -40,6 +40,7 @@ class Form::AdminSettings
     media_cache_retention_period
     content_cache_retention_period
     backups_retention_period
+    status_page_url
   ).freeze
 
   INTEGER_KEYS = %i(
@@ -85,6 +86,7 @@ class Form::AdminSettings
   validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks_rationale) }
   validates :media_cache_retention_period, :content_cache_retention_period, :backups_retention_period, numericality: { only_integer: true }, allow_blank: true, if: -> { defined?(@media_cache_retention_period) || defined?(@content_cache_retention_period) || defined?(@backups_retention_period) }
   validates :site_short_description, length: { maximum: 200 }, if: -> { defined?(@site_short_description) }
+  validates :status_page_url, url: true
   validate :validate_site_uploads
 
   KEYS.each do |key|
diff --git a/app/models/session_activation.rb b/app/models/session_activation.rb
index 3a59bad93..0b7fa6fe4 100644
--- a/app/models/session_activation.rb
+++ b/app/models/session_activation.rb
@@ -59,7 +59,7 @@ class SessionActivation < ApplicationRecord
     end
 
     def exclusive(id)
-      where('session_id != ?', id).destroy_all
+      where.not(session_id: id).destroy_all
     end
   end
 
diff --git a/app/models/setting.rb b/app/models/setting.rb
index 4bcaa060f..c6558d692 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -23,7 +23,7 @@ class Setting < RailsSettings::Base
     def [](key)
       return super(key) unless rails_initialized?
 
-      val = Rails.cache.fetch(cache_key(key, nil)) do
+      Rails.cache.fetch(cache_key(key, nil)) do
         db_val = object(key)
 
         if db_val
@@ -35,7 +35,6 @@ class Setting < RailsSettings::Base
           default_settings[key]
         end
       end
-      val
     end
 
     def all_as_records
diff --git a/app/models/trends/history.rb b/app/models/trends/history.rb
index 74723e35c..83532e7bc 100644
--- a/app/models/trends/history.rb
+++ b/app/models/trends/history.rb
@@ -87,8 +87,8 @@ class Trends::History
   end
 
   def each(&block)
-    if block_given?
-      (0...7).map { |i| block.call(get(i.days.ago)) }
+    if block
+      (0...7).map { |i| yield(get(i.days.ago)) }
     else
       to_enum(:each)
     end
diff --git a/app/models/user.rb b/app/models/user.rb
index a813ac83c..5ac1f663c 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -266,7 +266,7 @@ class User < ApplicationRecord
   end
 
   def inactive_message
-    !approved? ? :pending : super
+    approved? ? super : :pending
   end
 
   def approve!