about summary refs log tree commit diff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-05-25 21:27:00 +0200
committermultiple creatures <dev@multiple-creature.party>2019-11-19 15:31:27 -0600
commite9a90ca12a000b058a8ffa7d6876912cc36ec5cc (patch)
treeb2489406ffaa9a4e89fc3b3d479e78b6e9b4bed9 /app/models/user.rb
parentf3d88f0c27d3f281444095aea2caa2ef303fb04c (diff)
Add responsive panels to the single-column layout (#10820)
* Add responsive panels to the single-column layout

* Fixes

* Fix not being able to save the preference

* Fix code style issues

* Set max-height on the compose textarea and add a link to relationship manager
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb75
1 files changed, 39 insertions, 36 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index f72acd452..427b32066 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -163,6 +163,9 @@ class User < ApplicationRecord
     :aggregate_reblogs,
     :show_application,
     :default_content_type,
+
+    :theme,
+    :advanced_layout,
     to: :settings,
     prefix: :setting,
     allow_nil: false
@@ -249,37 +252,6 @@ class User < ApplicationRecord
     save!
   end
 
-  def notify_staff_about_pending_account!
-    LogWorker.perform_async("\xf0\x9f\x86\x95 New account <#{self.account.username}> is awaiting admin approval.\n\nReview (moderators only): https://#{Rails.configuration.x.web_domain || Rails.configuration.x.local_domain}/admin/pending_accounts")
-    User.staff.includes(:account).each do |u|
-      next unless u.allows_pending_account_emails?
-      AdminMailer.new_pending_account(u.account, self).deliver_later
-    end
-  end
-
-  def detect_spam!
-    janitor = janitor_account || Account.representative
-
-    intro = self.invite_request&.text
-    # normalize it
-    intro = intro.gsub(/[\u200b-\u200d\ufeff\u200e\u200f]/, '').strip.downcase unless intro.nil?
-
-    return false unless intro.blank? || intro.split.count < 5 || SPAM_TRIGGERS.match?(intro)
-
-    user_friendly_action_log(janitor, :reject_registration, self.account.username, "Registration was spam filtered.")
-    Form::AccountBatch.new(current_account: janitor, account_ids: account_id, action: 'reject').save
-
-    true
-  rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
-    false
-  end
-
-  def janitor_account
-    account_id = ENV.fetch('JANITOR_USER', '').to_i
-    return if account_id == 0
-    Account.find_by(id: account_id)
-  end
-
   def wants_larger_menus?
     @wants_larger_menus ||= (settings.larger_menus || false)
   end
@@ -479,18 +451,18 @@ class User < ApplicationRecord
     super
   end
 
-  def send_reset_password_instructions
-    return false if encrypted_password.blank? && (Devise.pam_authentication || Devise.ldap_authentication)
+  def send_confirmation_instructions
+    return false if detect_spam!
     super
   end
 
-  def reset_password!(new_password, new_password_confirmation)
+  def send_reset_password_instructions
     return false if encrypted_password.blank? && (Devise.pam_authentication || Devise.ldap_authentication)
     super
   end
 
-  def send_confirmation_instructions
-    return false if detect_spam!
+  def reset_password!(new_password, new_password_confirmation)
+    return false if encrypted_password.blank? && (Devise.pam_authentication || Devise.ldap_authentication)
     super
   end
 
@@ -539,6 +511,37 @@ class User < ApplicationRecord
     regenerate_feed! if needs_feed_update?
   end
 
+  def notify_staff_about_pending_account!
+    LogWorker.perform_async("\xf0\x9f\x86\x95 New account <#{self.account.username}> is awaiting admin approval.\n\nReview (moderators only): https://#{Rails.configuration.x.web_domain || Rails.configuration.x.local_domain}/admin/pending_accounts")
+    User.staff.includes(:account).each do |u|
+      next unless u.allows_pending_account_emails?
+      AdminMailer.new_pending_account(u.account, self).deliver_later
+    end
+  end
+
+  def detect_spam!
+    janitor = janitor_account || Account.representative
+
+    intro = self.invite_request&.text
+    # normalize it
+    intro = intro.gsub(/[\u200b-\u200d\ufeff\u200e\u200f]/, '').strip.downcase unless intro.nil?
+
+    return false unless intro.blank? || intro.split.count < 5 || SPAM_TRIGGERS.match?(intro)
+
+    user_friendly_action_log(janitor, :reject_registration, self.account.username, "Registration was spam filtered.")
+    Form::AccountBatch.new(current_account: janitor, account_ids: account_id, action: 'reject').save
+
+    true
+  rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
+    false
+  end
+
+  def janitor_account
+    account_id = ENV.fetch('JANITOR_USER', '').to_i
+    return if account_id == 0
+    Account.find_by(id: account_id)
+  end
+
   def regenerate_feed!
     return unless Redis.current.setnx("account:#{account_id}:regeneration", true)
     Redis.current.expire("account:#{account_id}:regeneration", 1.day.seconds)