From 8ce1fd6edb8e5dc1335cdac6c46711441220dbf7 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Tue, 28 Jul 2020 09:14:21 -0500 Subject: [Feature] Use unprocessed text for edits --- app/models/status.rb | 1 + app/serializers/rest/status_serializer.rb | 4 ++++ app/services/post_status_service.rb | 1 + app/services/update_status_service.rb | 2 ++ 4 files changed, 8 insertions(+) (limited to 'app') diff --git a/app/models/status.rb b/app/models/status.rb index c92d00935..edddffcc6 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -30,6 +30,7 @@ # published :boolean default(TRUE), not null # title :text # semiprivate :boolean default(FALSE), not null +# original_text :text # # rubocop:disable Metrics/ClassLength diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 4b06ec268..96ae59c62 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -85,6 +85,10 @@ class REST::StatusSerializer < ActiveModel::Serializer Formatter.instance.format(object) end + def text + object.original_text.presence || object.text + end + def url ActivityPub::TagManager.instance.url_for(object) end diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 33440a5a4..82588d254 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -196,6 +196,7 @@ class PostStatusService < BaseService def status_attributes { text: @text, + original_text: @text, media_attachments: @media || [], thread: @in_reply_to, poll_attributes: poll_attributes, diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb index 18fee3e17..887384991 100644 --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@ -8,6 +8,7 @@ class UpdateStatusService < BaseService spoiler_text title text + original_text content_type language sensitive @@ -33,6 +34,7 @@ class UpdateStatusService < BaseService @tags = (tags.nil? ? @status.tags : (tags || [])).to_set @params[:text] ||= '' + @params[:original_text] = @params[:text] @params[:published] = true if @status.published? (@params[:edited] ||= 1 + @status.edited) if @params[:published].presence || @status.published? -- cgit