From b4d7ef9f2a24fe26fe47722d1742ae9a30739d2e Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 23 Aug 2020 13:00:34 -0500 Subject: [Federation] Filter Twitter crossposter retweets --- app/lib/activitypub/activity/create.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 9ab60107b..0303b236f 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -46,7 +46,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity end def create_status - return reject_payload! if unsupported_object_type? || invalid_origin?(object_uri) || Tombstone.exists?(uri: object_uri) + return reject_payload! if unsupported_object_type? || invalid_origin?(object_uri) || Tombstone.exists?(uri: object_uri) || twitter_retweet? RedisLock.acquire(lock_options) do |lock| if lock.acquired? @@ -504,13 +504,18 @@ class ActivityPub::Activity::Create < ActivityPub::Activity @reblog_uri = @object['reblog'].presence || @object['_misskey_quote'].presence end + def twitter_retweet? + text_from_content.present? && (text_from_content.include?('

🐦🔗') || text_from_content.include?('

RT @')) + end + def text_from_content - return Formatter.instance.linkify([[text_from_name, text_from_summary.presence].compact.join("\n\n"), object_url || object_uri].join(' ')) if converted_object_type? + return @status_text if defined?(@status_text) + return @status_text = Formatter.instance.linkify([[text_from_name, text_from_summary.presence].compact.join("\n\n"), object_url || object_uri].join(' ')) if converted_object_type? if @object['content'].present? - @object['type'] == 'Article' ? Formatter.instance.format_article(@object['content']) : @object['content'] + @status_text = @object['type'] == 'Article' ? Formatter.instance.format_article(@object['content']) : @object['content'] elsif content_language_map? - @object['contentMap'].values.first + @status_text = @object['contentMap'].values.first end end -- cgit