diff options
Diffstat (limited to 'app/models/status.rb')
-rw-r--r-- | app/models/status.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index 514cab2e4..ea4c097bf 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -30,7 +30,6 @@ class Status < ApplicationRecord include Streamable include Cacheable include StatusThreadingConcern - include EmojiHelper enum visibility: [:public, :unlisted, :private, :direct], _suffix: :visibility @@ -55,7 +54,7 @@ class Status < ApplicationRecord has_one :notification, as: :activity, dependent: :destroy has_one :stream_entry, as: :activity, inverse_of: :status - validates :uri, uniqueness: true, unless: :local? + validates :uri, uniqueness: true, presence: true, unless: :local? validates :text, presence: true, unless: :reblog? validates_with StatusLengthValidator validates :reblog, uniqueness: { scope: :account }, if: :reblog? @@ -70,7 +69,6 @@ class Status < ApplicationRecord scope :without_reblogs, -> { where('statuses.reblog_of_id IS NULL') } scope :with_public_visibility, -> { where(visibility: :public) } scope :tagged_with, ->(tag) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag }) } - scope :local_only, -> { left_outer_joins(:account).where(accounts: { domain: nil }) } scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced: false }) } scope :including_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced: true }) } scope :not_excluded_by_account, ->(account) { where.not(account_id: account.excluded_from_timeline_account_ids) } @@ -132,6 +130,10 @@ class Status < ApplicationRecord !sensitive? && media_attachments.any? end + def emojis + CustomEmoji.from_text([spoiler_text, text].join(' '), account.domain) + end + after_create :store_uri, if: :local? before_validation :prepare_contents, if: :local? @@ -143,7 +145,7 @@ class Status < ApplicationRecord class << self def not_in_filtered_languages(account) - where.not(language: account.filtered_languages) + where(language: nil).or where.not(language: account.filtered_languages) end def as_home_timeline(account) @@ -221,7 +223,7 @@ class Status < ApplicationRecord private def timeline_scope(local_only = false) - starting_scope = local_only ? Status.local_only : Status + starting_scope = local_only ? Status.local : Status starting_scope .with_public_visibility .without_reblogs @@ -264,9 +266,6 @@ class Status < ApplicationRecord def prepare_contents text&.strip! spoiler_text&.strip! - - self.text = emojify(text) - self.spoiler_text = emojify(spoiler_text) end def set_reblog |