about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-05-31 14:38:17 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-05-31 20:38:17 +0200
commitb25e42a77f4b3472bc519e8a394b2cfe0e063e4c (patch)
tree7c541e3aab0268ffb9bbb7d4e2d97b91e413778c /app/models
parent5236a6286107f5731c5f57940592a46ebd3c6107 (diff)
Misc tidying and clean ups (#3445)
* Remove trailing whitespace in i18n mailers

* Use query methods instead of #present? on AR attributes

* Delegate Status#account_domain method

* Delegate Mention #account_username and #account_acct methods
Diffstat (limited to 'app/models')
-rw-r--r--app/models/mention.rb7
-rw-r--r--app/models/status.rb4
2 files changed, 10 insertions, 1 deletions
diff --git a/app/models/mention.rb b/app/models/mention.rb
index a8d243259..7450b1b85 100644
--- a/app/models/mention.rb
+++ b/app/models/mention.rb
@@ -17,4 +17,11 @@ class Mention < ApplicationRecord
   has_one :notification, as: :activity, dependent: :destroy
 
   validates :account, uniqueness: { scope: :status }
+
+  delegate(
+    :username,
+    :acct,
+    to: :account,
+    prefix: true
+  )
 end
diff --git a/app/models/status.rb b/app/models/status.rb
index a371083d0..e75ac7070 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -73,6 +73,8 @@ class Status < ApplicationRecord
 
   cache_associated :account, :application, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :application, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account
 
+  delegate :domain, to: :account, prefix: true
+
   def reply?
     !in_reply_to_id.nil? || attributes['reply']
   end
@@ -288,7 +290,7 @@ class Status < ApplicationRecord
 
   def filter_from_context?(status, account)
     should_filter   = account&.blocking?(status.account_id)
-    should_filter ||= account&.domain_blocking?(status.account.domain)
+    should_filter ||= account&.domain_blocking?(status.account_domain)
     should_filter ||= account&.muting?(status.account_id)
     should_filter ||= (status.account.silenced? && !account&.following?(status.account_id))
     should_filter ||= !StatusPolicy.new(account, status).show?