diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-03-10 09:52:45 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-03-10 09:52:45 +0100 |
commit | 24e83246f9efaa57ff025a606795ab8bc21a42df (patch) | |
tree | 203ec54d28707f1615f4c2ce026bb3e11d2ddcea /app/models/status_edit.rb | |
parent | 02133866e6915e37431298b396e1aded1e4c44c5 (diff) | |
parent | d7fab238a891d2530c9937a2fa627b622972d409 (diff) |
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.
Diffstat (limited to 'app/models/status_edit.rb')
-rw-r--r-- | app/models/status_edit.rb | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/app/models/status_edit.rb b/app/models/status_edit.rb index 3d8098fe7..33528eb0d 100644 --- a/app/models/status_edit.rb +++ b/app/models/status_edit.rb @@ -3,18 +3,39 @@ # # 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 + include RateLimitable + + self.ignored_columns = %w( + media_attachments_changed + ) + + class PreservedMediaAttachment < ActiveModelSerializers::Model + attributes :media_attachment, :description + + delegate :id, :type, :url, :preview_url, :remote_url, + :preview_remote_url, :text_url, :meta, :blurhash, + :not_processed?, :needs_redownload?, :local?, + :file, :thumbnail, :thumbnail_remote_url, + :shortcode, to: :media_attachment + end + + rate_limit by: :account, family: :statuses + belongs_to :status belongs_to :account, optional: true @@ -26,4 +47,17 @@ class StatusEdit < ApplicationRecord return @emojis if defined?(@emojis) @emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain) end + + def ordered_media_attachments + return @ordered_media_attachments if defined?(@ordered_media_attachments) + + @ordered_media_attachments = begin + if ordered_media_attachment_ids.nil? + [] + else + map = status.media_attachments.index_by(&:id) + ordered_media_attachment_ids.map.with_index { |media_attachment_id, index| PreservedMediaAttachment.new(media_attachment: map[media_attachment_id], description: media_descriptions[index]) } + end + end + end end |