--- /dev/null
+ # frozen_string_literal: true
+
+ module StatusSnapshotConcern
+ extend ActiveSupport::Concern
+
+ included do
+ has_many :edits, class_name: 'StatusEdit', inverse_of: :status, dependent: :destroy
+ end
+
+ def edited?
+ edited_at.present?
+ end
+
+ def build_snapshot(account_id: nil, at_time: nil, rate_limit: true)
+ # We don't use `edits#new` here to avoid it having saved when the
+ # status is saved, since we want to control that manually
+
+ StatusEdit.new(
+ status_id: id,
+ text: text,
+ spoiler_text: spoiler_text,
+ sensitive: sensitive,
+ ordered_media_attachment_ids: ordered_media_attachment_ids&.dup || media_attachments.pluck(:id),
+ media_descriptions: ordered_media_attachments.map(&:description),
+ poll_options: preloadable_poll&.options&.dup,
+ account_id: account_id || self.account_id,
++ content_type: content_type,
+ created_at: at_time || edited_at,
+ rate_limit: rate_limit
+ )
+ end
+
+ def snapshot!(**options)
+ build_snapshot(**options).save!
+ end
+ end
end
def functional?
- confirmed? && approved? && !disabled? && !account.suspended? && !account.memorial? && account.moved_to_account_id.nil?
+ confirmed? && approved? && !disabled? && !account.suspended? && !account.memorial?
end
+ def unconfirmed?
+ !confirmed?
+ end
+
def unconfirmed_or_pending?
- !(confirmed? && approved?)
+ unconfirmed? || pending?
end
def inactive_message
# frozen_string_literal: true
class ActivityPub::NoteSerializer < ActivityPub::Serializer
- context_extensions :atom_uri, :conversation, :sensitive, :voters_count
+ include FormattingHelper
+
+ context_extensions :atom_uri, :conversation, :sensitive, :voters_count, :direct_message
attributes :id, :type, :summary,
:in_reply_to, :published, :url,
@status.spoiler_text = @options[:spoiler_text] || '' if @options.key?(:spoiler_text)
@status.sensitive = @options[:sensitive] || @options[:spoiler_text].present? if @options.key?(:sensitive) || @options.key?(:spoiler_text)
@status.language = valid_locale_cascade(@options[:language], @status.language, @status.account.user&.preferred_posting_language, I18n.default_locale)
- @status.edited_at = Time.now.utc
+ @status.content_type = @options[:content_type] || @status.content_type
+ # We raise here to rollback the entire transaction
+ raise NoChangesSubmittedError unless significant_changes?
+
+ @status.edited_at = Time.now.utc
@status.save!
end
.status__content.emojify{ :data => ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }<
- if status.spoiler_text?
%p<
- %span.p-summary> #{Formatter.instance.format_spoiler(status, autoplay: prefers_autoplay?)}
+ %span.p-summary> #{prerender_custom_emojis(h(status.spoiler_text), status.emojis)}
%button.status__content__spoiler-link= t('statuses.show_more')
- .e-content
+ .e-content<
- = Formatter.instance.format(status, custom_emojify: true, autoplay: prefers_autoplay?)
+ = prerender_custom_emojis(status_content_format(status), status.emojis)
+
- if status.preloadable_poll
= render_poll_component(status)