From: Claire Date: Thu, 10 Mar 2022 08:52:45 +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=24e83246f9efaa57ff025a606795ab8bc21a42df;p=mastodon.git Merge branch 'main' into glitch-soc/merge-upstream Conflicts: - `app/models/status.rb`: Upstream updated media and edit-related code textually close to glitch-soc additions (local-only and content-type). Ported upstream changes. - `app/models/status_edit.rb`: Upstream changes textually close to glitch-soc additions (content-type). Ported upstream changes. - `app/serializers/activitypub/note_serializer.rb`: Upstream changed how media attachments are handled. Not really a conflict, but textually close to glitch-soc additions (directMessage attribute). Ported upstream changes. - `app/services/remove_status_service.rb`: Upstream changed how media attachments are handled. Not really a conflict, but textually close to glitch-soc additions (DM timeline). Ported upstream changes. - `app/services/update_status_service.rb`: Upstream fixed an issue with language selection. Not really a conflict, but textually close to glitch-soc additions (content-type). Ported upstream changes. - `db/schema.rb`: Upstream added columns to the `status_edits` table, the conflict is because of an additional column (`content-type`) in glitch-soc. Ported upstream changes. - `package.json`: Upstream dependency (express) textually adjacent to a glitch-soc-specific one (favico.js) got updated. Updated it as well. --- 24e83246f9efaa57ff025a606795ab8bc21a42df diff --cc Gemfile.lock index 26429aec4,075a4e9cb..7201a0c0e --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -496,9 -521,8 +523,9 @@@ GE link_header (~> 0.0, >= 0.0.8) rdf-normalize (0.5.0) rdf (~> 3.2) + redcarpet (3.5.1) redis (4.5.1) - redis-namespace (1.8.1) + redis-namespace (1.8.2) redis (>= 3.0.4) regexp_parser (2.2.0) request_store (1.5.0) @@@ -720,8 -757,8 +760,9 @@@ DEPENDENCIE fog-core (<= 2.1.0) fog-openstack (~> 0.3) fuubar (~> 2.5) + gitlab-omniauth-openid-connect (~> 0.5.0) hamlit-rails (~> 0.2) + hcaptcha (~> 7.1) hiredis (~> 0.6) htmlentities (~> 4.3) http (~> 5.0) diff --cc app/models/status.rb index 6a848baee,f2c55090b..ba9d7f0aa --- a/app/models/status.rb +++ b/app/models/status.rb @@@ -3,31 -3,29 +3,31 @@@ # # Table name: statuses # - # id :bigint(8) not null, primary key - # uri :string - # text :text default(""), not null - # created_at :datetime not null - # updated_at :datetime not null - # in_reply_to_id :bigint(8) - # reblog_of_id :bigint(8) - # url :string - # sensitive :boolean default(FALSE), not null - # visibility :integer default("public"), not null - # spoiler_text :text default(""), not null - # reply :boolean default(FALSE), not null - # language :string - # conversation_id :bigint(8) - # local :boolean - # account_id :bigint(8) not null - # application_id :bigint(8) - # in_reply_to_account_id :bigint(8) - # local_only :boolean - # full_status_text :text default(""), not null - # poll_id :bigint(8) - # content_type :string - # deleted_at :datetime - # edited_at :datetime - # trendable :boolean + # id :bigint(8) not null, primary key + # uri :string + # text :text default(""), not null + # created_at :datetime not null + # updated_at :datetime not null + # in_reply_to_id :bigint(8) + # reblog_of_id :bigint(8) + # url :string + # sensitive :boolean default(FALSE), not null + # visibility :integer default("public"), not null + # spoiler_text :text default(""), not null + # reply :boolean default(FALSE), not null + # language :string + # conversation_id :bigint(8) + # local :boolean + # account_id :bigint(8) not null + # application_id :bigint(8) + # in_reply_to_account_id :bigint(8) ++# local_only :boolean + # poll_id :bigint(8) ++# content_type :string + # deleted_at :datetime + # edited_at :datetime + # trendable :boolean + # ordered_media_attachment_ids :bigint(8) is an Array # class Status < ApplicationRecord @@@ -221,10 -216,13 +221,14 @@@ edits.create!( text: text, spoiler_text: spoiler_text, - media_attachments_changed: media_attachments_changed, + sensitive: sensitive, + ordered_media_attachment_ids: ordered_media_attachment_ids || media_attachments.pluck(:id), + media_descriptions: ordered_media_attachments.map(&:description), + poll_options: preloadable_poll&.options, account_id: account_id || self.account_id, + content_type: content_type, - created_at: at_time || edited_at + created_at: at_time || edited_at, + rate_limit: rate_limit ) end diff --cc app/models/status_edit.rb index 3d8098fe7,e9c8fbe98..33528eb0d --- a/app/models/status_edit.rb +++ b/app/models/status_edit.rb @@@ -3,15 -3,17 +3,18 @@@ # # Table name: status_edits # - # id :bigint(8) not null, primary key - # status_id :bigint(8) not null - # account_id :bigint(8) - # text :text default(""), not null - # spoiler_text :text default(""), not null - # media_attachments_changed :boolean default(FALSE), not null - # created_at :datetime not null - # updated_at :datetime not null - # content_type :string + # id :bigint(8) not null, primary key + # status_id :bigint(8) not null + # account_id :bigint(8) + # text :text default(""), not null + # spoiler_text :text default(""), not null + # created_at :datetime not null + # updated_at :datetime not null ++# content_type :string + # ordered_media_attachment_ids :bigint(8) is an Array + # media_descriptions :text is an Array + # poll_options :string is an Array + # sensitive :boolean # class StatusEdit < ApplicationRecord diff --cc app/serializers/activitypub/note_serializer.rb index aa552a724,7be2e2647..05f2ee14f --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@@ -13,9 -13,7 +13,9 @@@ class ActivityPub::NoteSerializer < Act attribute :content_map, if: :language? attribute :updated, if: :edited? + attribute :direct_message, if: :non_public? + - has_many :media_attachments, key: :attachment + has_many :virtual_attachments, key: :attachment has_many :virtual_tags, key: :tag has_one :replies, serializer: ActivityPub::CollectionSerializer, if: :local? @@@ -114,9 -103,13 +114,13 @@@ end def sensitive - object.account.sensitized? || object.sensitive + object.account.sensitized? || object.sensitive || (!instance_options[:allow_local_only] && Setting.outgoing_spoilers.present?) end + def virtual_attachments + object.ordered_media_attachments + end + def virtual_tags object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis end diff --cc app/services/post_status_service.rb index c5061dd63,c132930a9..36592a531 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@@ -171,9 -166,8 +175,9 @@@ class PostStatusService < BaseServic sensitive: @sensitive, spoiler_text: @options[:spoiler_text] || '', visibility: @visibility, - language: valid_locale_or_nil(@options[:language].presence || @account.user&.preferred_posting_language || I18n.default_locale), + language: valid_locale_cascade(@options[:language], @account.user&.preferred_posting_language, I18n.default_locale), application: @options[:application], + content_type: @options[:content_type] || @account.user&.setting_default_content_type, rate_limit: @options[:with_rate_limit], }.compact end diff --cc app/services/remove_status_service.rb index 361cd4d82,159aec1f2..c28e16572 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@@ -40,8 -40,7 +40,8 @@@ class RemoveStatusService < BaseServic remove_reblogs remove_from_hashtags remove_from_public - remove_from_media if @status.media_attachments.any? + remove_from_media if @status.with_media? + remove_from_direct if status.direct_visibility? remove_media end diff --cc app/services/update_status_service.rb index 6cbbd2876,055e5968d..f5155a2f5 --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@@ -95,8 -89,7 +90,8 @@@ class UpdateStatusService < BaseServic @status.text = @options[:text].presence || @options.delete(:spoiler_text) || '' if @options.key?(:text) @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_or_nil(@options[:language] || @status.language || @status.account.user&.preferred_posting_language || I18n.default_locale) + @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 @status.save! diff --cc db/schema.rb index f8d85901d,79e9b0f4d..3f51b85d5 --- a/db/schema.rb +++ b/db/schema.rb @@@ -845,10 -844,12 +844,13 @@@ ActiveRecord::Schema.define(version: 20 t.bigint "account_id" t.text "text", default: "", null: false t.text "spoiler_text", default: "", null: false - t.boolean "media_attachments_changed", default: false, null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "content_type" + t.bigint "ordered_media_attachment_ids", array: true + t.text "media_descriptions", array: true + t.string "poll_options", array: true + t.boolean "sensitive" t.index ["account_id"], name: "index_status_edits_on_account_id" t.index ["status_id"], name: "index_status_edits_on_status_id" end diff --cc package.json index 96aab9ef1,d9e4ee137..463d47a8a --- a/package.json +++ b/package.json @@@ -95,8 -93,7 +95,8 @@@ "es6-symbol": "^3.1.3", "escape-html": "^1.0.3", "exif-js": "^2.3.0", - "express": "^4.17.1", + "express": "^4.17.3", + "favico.js": "^0.3.10", "file-loader": "^6.2.0", "font-awesome": "^4.7.0", "glob": "^7.2.0",