|
|
@ -45,7 +45,7 @@ class Status < ApplicationRecord
|
|
|
|
belongs_to :account, inverse_of: :statuses
|
|
|
|
belongs_to :account, inverse_of: :statuses
|
|
|
|
belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account', optional: true
|
|
|
|
belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account', optional: true
|
|
|
|
belongs_to :conversation, optional: true
|
|
|
|
belongs_to :conversation, optional: true
|
|
|
|
belongs_to :poll, optional: true
|
|
|
|
belongs_to :preloadable_poll, class_name: 'Poll', foreign_key: 'poll_id', optional: true
|
|
|
|
|
|
|
|
|
|
|
|
belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies, optional: true
|
|
|
|
belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies, optional: true
|
|
|
|
belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, optional: true
|
|
|
|
belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, optional: true
|
|
|
@ -63,7 +63,7 @@ class Status < ApplicationRecord
|
|
|
|
has_one :notification, as: :activity, dependent: :destroy
|
|
|
|
has_one :notification, as: :activity, dependent: :destroy
|
|
|
|
has_one :stream_entry, as: :activity, inverse_of: :status
|
|
|
|
has_one :stream_entry, as: :activity, inverse_of: :status
|
|
|
|
has_one :status_stat, inverse_of: :status
|
|
|
|
has_one :status_stat, inverse_of: :status
|
|
|
|
has_one :owned_poll, class_name: 'Poll', inverse_of: :status, dependent: :destroy
|
|
|
|
has_one :poll, inverse_of: :status, dependent: :destroy
|
|
|
|
|
|
|
|
|
|
|
|
validates :uri, uniqueness: true, presence: true, unless: :local?
|
|
|
|
validates :uri, uniqueness: true, presence: true, unless: :local?
|
|
|
|
validates :text, presence: true, unless: -> { with_media? || reblog? }
|
|
|
|
validates :text, presence: true, unless: -> { with_media? || reblog? }
|
|
|
@ -72,7 +72,7 @@ class Status < ApplicationRecord
|
|
|
|
validates :reblog, uniqueness: { scope: :account }, if: :reblog?
|
|
|
|
validates :reblog, uniqueness: { scope: :account }, if: :reblog?
|
|
|
|
validates :visibility, exclusion: { in: %w(direct limited) }, if: :reblog?
|
|
|
|
validates :visibility, exclusion: { in: %w(direct limited) }, if: :reblog?
|
|
|
|
|
|
|
|
|
|
|
|
accepts_nested_attributes_for :owned_poll
|
|
|
|
accepts_nested_attributes_for :poll
|
|
|
|
|
|
|
|
|
|
|
|
default_scope { recent }
|
|
|
|
default_scope { recent }
|
|
|
|
|
|
|
|
|
|
|
@ -107,7 +107,7 @@ class Status < ApplicationRecord
|
|
|
|
:tags,
|
|
|
|
:tags,
|
|
|
|
:preview_cards,
|
|
|
|
:preview_cards,
|
|
|
|
:stream_entry,
|
|
|
|
:stream_entry,
|
|
|
|
:poll,
|
|
|
|
:preloadable_poll,
|
|
|
|
account: :account_stat,
|
|
|
|
account: :account_stat,
|
|
|
|
active_mentions: { account: :account_stat },
|
|
|
|
active_mentions: { account: :account_stat },
|
|
|
|
reblog: [
|
|
|
|
reblog: [
|
|
|
@ -118,7 +118,7 @@ class Status < ApplicationRecord
|
|
|
|
:media_attachments,
|
|
|
|
:media_attachments,
|
|
|
|
:conversation,
|
|
|
|
:conversation,
|
|
|
|
:status_stat,
|
|
|
|
:status_stat,
|
|
|
|
:poll,
|
|
|
|
:preloadable_poll,
|
|
|
|
account: :account_stat,
|
|
|
|
account: :account_stat,
|
|
|
|
active_mentions: { account: :account_stat },
|
|
|
|
active_mentions: { account: :account_stat },
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -214,10 +214,11 @@ class Status < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
|
|
def emojis
|
|
|
|
def emojis
|
|
|
|
return @emojis if defined?(@emojis)
|
|
|
|
return @emojis if defined?(@emojis)
|
|
|
|
fields = [spoiler_text, text]
|
|
|
|
|
|
|
|
fields += owned_poll.options unless owned_poll.nil?
|
|
|
|
fields = [spoiler_text, text]
|
|
|
|
|
|
|
|
fields += preloadable_poll.options unless preloadable_poll.nil?
|
|
|
|
|
|
|
|
|
|
|
|
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
|
|
|
|
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
|
|
|
|
@emojis
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def mark_for_mass_destruction!
|
|
|
|
def mark_for_mass_destruction!
|
|
|
@ -453,7 +454,7 @@ class Status < ApplicationRecord
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def set_poll_id
|
|
|
|
def set_poll_id
|
|
|
|
update_column(:poll_id, owned_poll.id) unless owned_poll.nil?
|
|
|
|
update_column(:poll_id, poll.id) unless poll.nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def set_visibility
|
|
|
|
def set_visibility
|
|
|
|