Instead of using spoiler boolean and spoiler_text, simply check for non-blank spoiler_text

Federate spoiler_text using warning attribute on <content /> instead of a <category term="spoiler" />
Clean up schema file from accidental development migrations
This commit is contained in:
Eugen Rochko 2017-01-25 00:49:08 +01:00
parent f8da0dd490
commit 999cde94a6
23 changed files with 159 additions and 173 deletions

View file

@ -9,7 +9,7 @@ class FetchLinkCardService < BaseService
response = http_client.get(url)
return if response.code != 200
return if response.code != 200 || response.mime_type != 'text/html'
page = Nokogiri::HTML(response.to_s)
card = PreviewCard.where(status: status).first_or_initialize(status: status, url: url)
@ -18,6 +18,8 @@ class FetchLinkCardService < BaseService
card.description = meta_property(page, 'og:description') || meta_property(page, 'description')
card.image = URI.parse(meta_property(page, 'og:image')) if meta_property(page, 'og:image')
return if card.title.blank?
card.save_with_optional_image!
end

View file

@ -8,18 +8,16 @@ class PostStatusService < BaseService
# @param [Hash] options
# @option [Boolean] :sensitive
# @option [String] :visibility
# @option [Boolean] :spoiler
# @option [String] :spoiler_text
# @option [Enumerable] :media_ids Optional array of media IDs to attach
# @option [Doorkeeper::Application] :application
# @return [Status]
def call(account, text, in_reply_to = nil, options = {})
status = account.statuses.create!(text: text,
thread: in_reply_to,
sensitive: options[:sensitive],
spoiler: options[:spoiler],
spoiler_text: options[:spoiler_text],
visibility: options[:visibility],
status = account.statuses.create!(text: text,
thread: in_reply_to,
sensitive: options[:sensitive],
spoiler_text: options[:spoiler_text],
visibility: options[:visibility],
application: options[:application])
attach_media(status, options[:media_ids])

View file

@ -103,6 +103,7 @@ class ProcessFeedService < BaseService
url: url(entry),
account: account,
text: content(entry),
spoiler_text: content_warning(entry),
created_at: published(entry)
)
@ -223,6 +224,10 @@ class ProcessFeedService < BaseService
xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS).content
end
def content_warning(xml = @xml)
xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS)['warning']
end
def published(xml = @xml)
xml.at_xpath('./xmlns:published', xmlns: TagManager::XMLNS).content
end

View file

@ -9,6 +9,5 @@ class ProcessHashtagsService < BaseService
end
status.update(sensitive: true) if tags.include?('nsfw')
status.update(spoiler: true) if tags.include?('spoiler')
end
end