mirror of
https://github.com/kikobar/mastodon.git
synced 2024-12-25 07:14:21 +00:00
Do not run FetchLinkCardService on local URLs, increase file size limit to 8MB,
fix ProcessFeedService pushing status into distribution if called a second time while the first is still running (i.e. when a PuSH comes after a Salmon slap), fix not running escape on spoiler text before emojify
This commit is contained in:
parent
9f57c7d4a6
commit
450ad43180
|
@ -1,5 +1,6 @@
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
import escapeTextContentForBrowser from 'react/lib/escapeTextContentForBrowser';
|
||||||
import emojify from '../emoji';
|
import emojify from '../emoji';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ const StatusContent = React.createClass({
|
||||||
const { hidden } = this.state;
|
const { hidden } = this.state;
|
||||||
|
|
||||||
const content = { __html: emojify(status.get('content')) };
|
const content = { __html: emojify(status.get('content')) };
|
||||||
const spoilerContent = { __html: emojify(status.get('spoiler_text', '')) };
|
const spoilerContent = { __html: emojify(escapeTextContentForBrowser(status.get('spoiler_text', ''))) };
|
||||||
|
|
||||||
if (status.get('spoiler_text').length > 0) {
|
if (status.get('spoiler_text').length > 0) {
|
||||||
const toggleText = hidden ? <FormattedMessage id='status.show_more' defaultMessage='Show more' /> : <FormattedMessage id='status.show_less' defaultMessage='Show less' />;
|
const toggleText = hidden ? <FormattedMessage id='status.show_more' defaultMessage='Show more' /> : <FormattedMessage id='status.show_less' defaultMessage='Show less' />;
|
||||||
|
|
|
@ -56,6 +56,12 @@ class TagManager
|
||||||
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
|
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def local_url?(url)
|
||||||
|
uri = Addressable::URI.parse(url)
|
||||||
|
domain = uri.host + (uri.port ? ":#{uri.port}" : '')
|
||||||
|
TagManager.instance.local_domain?(domain)
|
||||||
|
end
|
||||||
|
|
||||||
def uri_for(target)
|
def uri_for(target)
|
||||||
return target.uri if target.respond_to?(:local?) && !target.local?
|
return target.uri if target.respond_to?(:local?) && !target.local?
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
processors: -> (f) { f.video? ? [:transcoder] : [:thumbnail] },
|
processors: -> (f) { f.video? ? [:transcoder] : [:thumbnail] },
|
||||||
convert_options: { all: '-quality 90 -strip' }
|
convert_options: { all: '-quality 90 -strip' }
|
||||||
validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES
|
validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES
|
||||||
validates_attachment_size :file, less_than: 4.megabytes
|
validates_attachment_size :file, less_than: 8.megabytes
|
||||||
|
|
||||||
validates :account, presence: true
|
validates :account, presence: true
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
class FetchLinkCardService < BaseService
|
class FetchLinkCardService < BaseService
|
||||||
def call(status)
|
def call(status)
|
||||||
# Get first URL
|
# Get first http/https URL that isn't local
|
||||||
url = URI.extract(status.text).reject { |uri| (uri =~ /\Ahttps?:\/\//).nil? }.first
|
url = URI.extract(status.text).reject { |uri| (uri =~ /\Ahttps?:\/\//).nil? || TagManager.instance.local_url?(uri) }.first
|
||||||
|
|
||||||
return if url.nil?
|
return if url.nil?
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,13 @@ class ProcessFeedService < BaseService
|
||||||
|
|
||||||
def create_status
|
def create_status
|
||||||
Rails.logger.debug "Creating remote status #{id}"
|
Rails.logger.debug "Creating remote status #{id}"
|
||||||
status = status_from_xml(@xml)
|
status, just_created = status_from_xml(@xml)
|
||||||
|
|
||||||
return if status.nil?
|
return if status.nil?
|
||||||
|
return status unless just_created
|
||||||
|
|
||||||
if verb == :share
|
if verb == :share
|
||||||
original_status = status_from_xml(@xml.at_xpath('.//activity:object', activity: TagManager::AS_XMLNS))
|
original_status, = status_from_xml(@xml.at_xpath('.//activity:object', activity: TagManager::AS_XMLNS))
|
||||||
status.reblog = original_status
|
status.reblog = original_status
|
||||||
|
|
||||||
if original_status.nil?
|
if original_status.nil?
|
||||||
|
@ -61,7 +62,6 @@ class ProcessFeedService < BaseService
|
||||||
status.save!
|
status.save!
|
||||||
|
|
||||||
NotifyService.new.call(status.reblog.account, status) if status.reblog? && status.reblog.account.local?
|
NotifyService.new.call(status.reblog.account, status) if status.reblog? && status.reblog.account.local?
|
||||||
# LinkCrawlWorker.perform_async(status.reblog? ? status.reblog_of_id : status.id)
|
|
||||||
Rails.logger.debug "Queuing remote status #{status.id} (#{id}) for distribution"
|
Rails.logger.debug "Queuing remote status #{status.id} (#{id}) for distribution"
|
||||||
DistributionWorker.perform_async(status.id)
|
DistributionWorker.perform_async(status.id)
|
||||||
status
|
status
|
||||||
|
@ -81,22 +81,23 @@ class ProcessFeedService < BaseService
|
||||||
def status_from_xml(entry)
|
def status_from_xml(entry)
|
||||||
# Return early if status already exists in db
|
# Return early if status already exists in db
|
||||||
status = find_status(id(entry))
|
status = find_status(id(entry))
|
||||||
return status unless status.nil?
|
|
||||||
|
return [status, false] unless status.nil?
|
||||||
|
|
||||||
# If status embeds an author, find that author
|
# If status embeds an author, find that author
|
||||||
# If that author cannot be found, don't record the status (do not misattribute)
|
# If that author cannot be found, don't record the status (do not misattribute)
|
||||||
if account?(entry)
|
if account?(entry)
|
||||||
begin
|
begin
|
||||||
account = find_or_resolve_account(acct(entry))
|
account = find_or_resolve_account(acct(entry))
|
||||||
return nil if account.nil?
|
return [nil, false] if account.nil?
|
||||||
rescue Goldfinger::Error
|
rescue Goldfinger::Error
|
||||||
return nil
|
return [nil, false]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
account = @account
|
account = @account
|
||||||
end
|
end
|
||||||
|
|
||||||
return if account.suspended?
|
return [nil, false] if account.suspended?
|
||||||
|
|
||||||
status = Status.create!(
|
status = Status.create!(
|
||||||
uri: id(entry),
|
uri: id(entry),
|
||||||
|
@ -116,7 +117,7 @@ class ProcessFeedService < BaseService
|
||||||
hashtags_from_xml(status, entry)
|
hashtags_from_xml(status, entry)
|
||||||
media_from_xml(status, entry)
|
media_from_xml(status, entry)
|
||||||
|
|
||||||
status
|
[status, true]
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_or_resolve_account(acct)
|
def find_or_resolve_account(acct)
|
||||||
|
|
Loading…
Reference in a new issue