From: Claire Date: Sat, 26 Mar 2022 18:18:55 +0000 (+0100) Subject: Merge branch 'main' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=aaa9ec340b7291bace3a899cfcfef7524ecdfe72;p=mastodon.git Merge branch 'main' into glitch-soc/merge-upstream Conflicts: - `app/lib/formatter.rb`: Upstream completely refactored the formatting code and removed that file, while glitch-soc had code for Markdown and HTML toots. Took upstream code, glitch-soc changes will be re-implemented on top of the refactored classes in a later commit. - `app/models/status.rb`: Upstream refactored status edit handling and moved code to `app/models/concerns/status_snapshot_concern.rb`. Applied glitch-soc's changes to that file. - `app/serializers/activitypub/note_serializer.rb`: Not really a conflict, just a line added too close to one modified by glitch-soc. Applied upstream changes while keeping the glitch-soc-modified one. - `app/services/update_status_service.rb`: Not really a conflict, upstream modified a line adjacent to one added by glitch-soc. Applied upstream changes while keeping the glitch-soc line. - `app/views/statuses/_simple_status.html.haml`: Upstream refactored formatting, glitch-soc changed the markup slightly. Applied upstream changes. - `spec/lib/formatter_spec.rb`: Upstream completely refactored the formatting code and removed that file, while glitch-soc had code for Markdown and HTML toots. Took upstream code, glitch-soc changes will be re-implemented on top of the refactored classes in a later commit. --- aaa9ec340b7291bace3a899cfcfef7524ecdfe72 diff --cc app/models/concerns/status_snapshot_concern.rb index 000000000,9741b9aeb..c728db7c3 mode 000000,100644..100644 --- a/app/models/concerns/status_snapshot_concern.rb +++ b/app/models/concerns/status_snapshot_concern.rb @@@ -1,0 -1,35 +1,36 @@@ + # 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 diff --cc app/models/user.rb index f657f1b27,f2d9c49eb..7c9ced6ae --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -205,11 -205,15 +205,15 @@@ class User < ApplicationRecor 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 diff --cc app/serializers/activitypub/note_serializer.rb index 05f2ee14f,27e058199..ca067ed9b --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@@ -1,7 -1,9 +1,9 @@@ # frozen_string_literal: true class ActivityPub::NoteSerializer < ActivityPub::Serializer + include FormattingHelper + - context_extensions :atom_uri, :conversation, :sensitive, :voters_count + context_extensions :atom_uri, :conversation, :sensitive, :voters_count, :direct_message attributes :id, :type, :summary, :in_reply_to, :published, :url, diff --cc app/services/update_status_service.rb index f5155a2f5,c4c934976..cc4ec670d --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@@ -91,9 -103,11 +104,12 @@@ class UpdateStatusService < BaseServic @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.content_type = @options[:content_type] || @status.content_type - @status.edited_at = Time.now.utc + # We raise here to rollback the entire transaction + raise NoChangesSubmittedError unless significant_changes? + + @status.edited_at = Time.now.utc @status.save! end diff --cc app/views/statuses/_simple_status.html.haml index a41656323,13b6613ce..7b672bda7 --- a/app/views/statuses/_simple_status.html.haml +++ b/app/views/statuses/_simple_status.html.haml @@@ -30,10 -30,11 +30,11 @@@ .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)