split `i:am` signatures into their very own `footer` column
parent
5c9aed40f6
commit
09b7532805
|
@ -28,6 +28,7 @@ class PostStatusService < BaseService
|
||||||
@account = account
|
@account = account
|
||||||
@options = options
|
@options = options
|
||||||
@text = @options[:text] || ''
|
@text = @options[:text] || ''
|
||||||
|
@footer = @options[:footer]
|
||||||
@in_reply_to = @options[:thread]
|
@in_reply_to = @options[:thread]
|
||||||
@tags = @options[:tags]
|
@tags = @options[:tags]
|
||||||
@local_only = @options[:local_only]
|
@local_only = @options[:local_only]
|
||||||
|
@ -53,12 +54,20 @@ class PostStatusService < BaseService
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_footer_from_i_am
|
||||||
|
name = @account.vars['_they:are']
|
||||||
|
return if name.blank?
|
||||||
|
@account.vars["_they:are:#{name}"]
|
||||||
|
end
|
||||||
|
|
||||||
def preprocess_attributes!
|
def preprocess_attributes!
|
||||||
if @text.blank? && @options[:spoiler_text].present?
|
if @text.blank? && @options[:spoiler_text].present?
|
||||||
@text = '.'
|
@text = '.'
|
||||||
@text = @media.find(&:video?) ? '📹' : '🖼' if @media.size > 0
|
@text = @media.find(&:video?) ? '📹' : '🖼' if @media.size > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@footer = set_footer_from_i_am if @footer.nil?
|
||||||
|
|
||||||
@visibility = @options[:visibility] || @account.user_default_visibility
|
@visibility = @options[:visibility] || @account.user_default_visibility
|
||||||
@visibility = :unlisted if @visibility.in?([nil, 'public']) && @account.silenced? || @account.force_unlisted
|
@visibility = :unlisted if @visibility.in?([nil, 'public']) && @account.silenced? || @account.force_unlisted
|
||||||
|
|
||||||
|
@ -178,6 +187,7 @@ class PostStatusService < BaseService
|
||||||
{
|
{
|
||||||
created_at: @options[:created_at] ? @options[:created_at].to_datetime : Time.now.utc,
|
created_at: @options[:created_at] ? @options[:created_at].to_datetime : Time.now.utc,
|
||||||
text: @text,
|
text: @text,
|
||||||
|
footer: @footer,
|
||||||
media_attachments: @media || [],
|
media_attachments: @media || [],
|
||||||
thread: @in_reply_to,
|
thread: @in_reply_to,
|
||||||
poll_attributes: poll_attributes,
|
poll_attributes: poll_attributes,
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddFooterToStatuses < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :statuses, :footer, :text
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
class ReformatLocalStatuses < ActiveRecord::Migration[5.2]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
def up
|
||||||
|
Status.local.without_reblogs.find_each do |status|
|
||||||
|
status.content_type = 'text/x-bbcode+markdown'
|
||||||
|
text = status.text
|
||||||
|
matches = text.match(/\[(right|rfloat)\][\u200c\u200b—–-]+ *(.*?)\[\/\1\]\u200c?\Z/)
|
||||||
|
if matches
|
||||||
|
status.footer = matches[2].strip
|
||||||
|
text = text.sub(/\[(right|rfloat)\][\u200c\u200b—–-]+.*?\[\/\1\]\u200c?\Z/, '').rstrip
|
||||||
|
end
|
||||||
|
text = text.gsub(/\[(color|colorhex|hexcolor)=\w+\](.*?)\[\/\1\]/, '[b]\2[/b]')
|
||||||
|
text = text.gsub(/\[(spin|pulse)\](.*?)\[\/\1\]/, '[b]\2[/b]')
|
||||||
|
status.text = text unless text.blank?
|
||||||
|
Rails.logger.info("Rewrote status ID #{status.id}")
|
||||||
|
status.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -644,11 +644,12 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
|
||||||
t.bigint "in_reply_to_account_id"
|
t.bigint "in_reply_to_account_id"
|
||||||
t.boolean "local_only"
|
t.boolean "local_only"
|
||||||
t.bigint "poll_id"
|
t.bigint "poll_id"
|
||||||
t.string "content_type"
|
|
||||||
t.tsvector "tsv"
|
t.tsvector "tsv"
|
||||||
t.boolean "curated", default: false, null: false
|
t.boolean "curated", default: false, null: false
|
||||||
t.string "sharekey"
|
t.string "sharekey"
|
||||||
t.boolean "network", default: false, null: false
|
t.boolean "network", default: false, null: false
|
||||||
|
t.string "content_type"
|
||||||
|
t.text "footer"
|
||||||
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
|
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
|
||||||
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
|
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
|
||||||
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
|
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
|
||||||
|
|
Loading…
Reference in New Issue